index-BoyoYwvX.js 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614
  1. function Ere(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 s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).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 hv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vA={exports:{}},nx={};var eF;function Are(){if(eF)return nx;eF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var s=null;if(a!==void 0&&(s=""+a),i.key!==void 0&&(s=""+i.key),"key"in i){a={};for(var o in i)o!=="key"&&(a[o]=i[o])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:s,ref:i!==void 0?i:null,props:a}}return nx.Fragment=e,nx.jsx=n,nx.jsxs=n,nx}var tF;function Tre(){return tF||(tF=1,vA.exports=Are()),vA.exports}var l=Tre(),_A={exports:{}},en={};var nF;function Cre(){if(nF)return en;nF=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"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function m(U){return U===null||typeof U!="object"?null:(U=g&&U[g]||U["@@iterator"],typeof U=="function"?U:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function x(U,$,X){this.props=U,this.context=$,this.refs=v,this.updater=X||b}x.prototype.isReactComponent={},x.prototype.setState=function(U,$){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,$,"setState")},x.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function M(){}M.prototype=x.prototype;function S(U,$,X){this.props=U,this.context=$,this.refs=v,this.updater=X||b}var A=S.prototype=new M;A.constructor=S,y(A,x.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function k(){}var N={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function C(U,$,X){var te=X.ref;return{$$typeof:t,type:U,key:$,ref:te!==void 0?te:null,props:X}}function D(U,$){return C(U.type,$,U.props)}function F(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function O(U){var $={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(X){return $[X]})}var q=/\/+/g;function R(U,$){return typeof U=="object"&&U!==null&&U.key!=null?O(""+U.key):$.toString(36)}function W(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($){U.status==="pending"&&(U.status="fulfilled",U.value=$)},function($){U.status==="pending"&&(U.status="rejected",U.reason=$)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function K(U,$,X,te,fe){var pe=typeof U;(pe==="undefined"||pe==="boolean")&&(U=null);var be=!1;if(U===null)be=!0;else switch(pe){case"bigint":case"string":case"number":be=!0;break;case"object":switch(U.$$typeof){case t:case e:be=!0;break;case d:return be=U._init,K(be(U._payload),$,X,te,fe)}}if(be)return fe=fe(U),be=te===""?"."+R(U,0):te,T(fe)?(X="",be!=null&&(X=be.replace(q,"$&/")+"/"),K(fe,$,X,"",function(xe){return xe})):fe!=null&&(F(fe)&&(fe=D(fe,X+(fe.key==null||U&&U.key===fe.key?"":(""+fe.key).replace(q,"$&/")+"/")+be)),$.push(fe)),1;be=0;var Ne=te===""?".":te+":";if(T(U))for(var ie=0;ie<U.length;ie++)te=U[ie],pe=Ne+R(te,ie),be+=K(te,$,X,pe,fe);else if(ie=m(U),typeof ie=="function")for(U=ie.call(U),ie=0;!(te=U.next()).done;)te=te.value,pe=Ne+R(te,ie++),be+=K(te,$,X,pe,fe);else if(pe==="object"){if(typeof U.then=="function")return K(W(U),$,X,te,fe);throw $=String(U),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.")}return be}function G(U,$,X){if(U==null)return U;var te=[],fe=0;return K(U,te,"","",function(pe){return $.call(X,pe,fe++)}),te}function ee(U){if(U._status===-1){var $=U._result;$=$(),$.then(function(X){(U._status===0||U._status===-1)&&(U._status=1,U._result=X)},function(X){(U._status===0||U._status===-1)&&(U._status=2,U._result=X)}),U._status===-1&&(U._status=0,U._result=$)}if(U._status===1)return U._result.default;throw U._result}var Z=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var $=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($))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},Q={map:G,forEach:function(U,$,X){G(U,function(){$.apply(this,arguments)},X)},count:function(U){var $=0;return G(U,function(){$++}),$},toArray:function(U){return G(U,function($){return $})||[]},only:function(U){if(!F(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return en.Activity=f,en.Children=Q,en.Component=x,en.Fragment=n,en.Profiler=i,en.PureComponent=S,en.StrictMode=r,en.Suspense=c,en.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,en.__COMPILER_RUNTIME={__proto__:null,c:function(U){return N.H.useMemoCache(U)}},en.cache=function(U){return function(){return U.apply(null,arguments)}},en.cacheSignal=function(){return null},en.cloneElement=function(U,$,X){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var te=y({},U.props),fe=U.key;if($!=null)for(pe in $.key!==void 0&&(fe=""+$.key),$)!I.call($,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&$.ref===void 0||(te[pe]=$[pe]);var pe=arguments.length-2;if(pe===1)te.children=X;else if(1<pe){for(var be=Array(pe),Ne=0;Ne<pe;Ne++)be[Ne]=arguments[Ne+2];te.children=be}return C(U.type,fe,te)},en.createContext=function(U){return U={$$typeof:s,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:a,_context:U},U},en.createElement=function(U,$,X){var te,fe={},pe=null;if($!=null)for(te in $.key!==void 0&&(pe=""+$.key),$)I.call($,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(fe[te]=$[te]);var be=arguments.length-2;if(be===1)fe.children=X;else if(1<be){for(var Ne=Array(be),ie=0;ie<be;ie++)Ne[ie]=arguments[ie+2];fe.children=Ne}if(U&&U.defaultProps)for(te in be=U.defaultProps,be)fe[te]===void 0&&(fe[te]=be[te]);return C(U,pe,fe)},en.createRef=function(){return{current:null}},en.forwardRef=function(U){return{$$typeof:o,render:U}},en.isValidElement=F,en.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:ee}},en.memo=function(U,$){return{$$typeof:u,type:U,compare:$===void 0?null:$}},en.startTransition=function(U){var $=N.T,X={};N.T=X;try{var te=U(),fe=N.S;fe!==null&&fe(X,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(k,Z)}catch(pe){Z(pe)}finally{$!==null&&X.types!==null&&($.types=X.types),N.T=$}},en.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},en.use=function(U){return N.H.use(U)},en.useActionState=function(U,$,X){return N.H.useActionState(U,$,X)},en.useCallback=function(U,$){return N.H.useCallback(U,$)},en.useContext=function(U){return N.H.useContext(U)},en.useDebugValue=function(){},en.useDeferredValue=function(U,$){return N.H.useDeferredValue(U,$)},en.useEffect=function(U,$){return N.H.useEffect(U,$)},en.useEffectEvent=function(U){return N.H.useEffectEvent(U)},en.useId=function(){return N.H.useId()},en.useImperativeHandle=function(U,$,X){return N.H.useImperativeHandle(U,$,X)},en.useInsertionEffect=function(U,$){return N.H.useInsertionEffect(U,$)},en.useLayoutEffect=function(U,$){return N.H.useLayoutEffect(U,$)},en.useMemo=function(U,$){return N.H.useMemo(U,$)},en.useOptimistic=function(U,$){return N.H.useOptimistic(U,$)},en.useReducer=function(U,$,X){return N.H.useReducer(U,$,X)},en.useRef=function(U){return N.H.useRef(U)},en.useState=function(U){return N.H.useState(U)},en.useSyncExternalStore=function(U,$,X){return N.H.useSyncExternalStore(U,$,X)},en.useTransition=function(){return N.H.useTransition()},en.version="19.2.0",en}var rF;function $m(){return rF||(rF=1,_A.exports=Cre()),_A.exports}var E=$m();const mr=fo(E),Nre=Ere({__proto__:null,default:mr},[E]);var wA={exports:{}},rx={},SA={exports:{}},MA={};var iF;function kre(){return iF||(iF=1,(function(t){function e(K,G){var ee=K.length;K.push(G);e:for(;0<ee;){var Z=ee-1>>>1,Q=K[Z];if(0<i(Q,G))K[Z]=G,K[ee]=Q,ee=Z;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var G=K[0],ee=K.pop();if(ee!==G){K[0]=ee;e:for(var Z=0,Q=K.length,U=Q>>>1;Z<U;){var $=2*(Z+1)-1,X=K[$],te=$+1,fe=K[te];if(0>i(X,ee))te<Q&&0>i(fe,X)?(K[Z]=fe,K[te]=ee,Z=te):(K[Z]=X,K[$]=ee,Z=$);else if(te<Q&&0>i(fe,ee))K[Z]=fe,K[te]=ee,Z=te;else break e}}return G}function i(K,G){var ee=K.sortIndex-G.sortIndex;return ee!==0?ee:K.id-G.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var c=[],u=[],d=1,f=null,g=3,m=!1,b=!1,y=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=K)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function T(K){if(y=!1,A(K),!b)if(n(c)!==null)b=!0,k||(k=!0,O());else{var G=n(u);G!==null&&W(T,G.startTime-K)}}var k=!1,N=-1,I=5,C=-1;function D(){return v?!0:!(t.unstable_now()-C<I)}function F(){if(v=!1,k){var K=t.unstable_now();C=K;var G=!0;try{e:{b=!1,y&&(y=!1,M(N),N=-1),m=!0;var ee=g;try{t:{for(A(K),f=n(c);f!==null&&!(f.expirationTime>K&&D());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,g=f.priorityLevel;var Q=Z(f.expirationTime<=K);if(K=t.unstable_now(),typeof Q=="function"){f.callback=Q,A(K),G=!0;break t}f===n(c)&&r(c),A(K)}else r(c);f=n(c)}if(f!==null)G=!0;else{var U=n(u);U!==null&&W(T,U.startTime-K),G=!1}}break e}finally{f=null,g=ee,m=!1}G=void 0}}finally{G?O():k=!1}}}var O;if(typeof S=="function")O=function(){S(F)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=F,O=function(){R.postMessage(null)}}else O=function(){x(F,0)};function W(K,G){N=x(function(){K(t.unstable_now())},G)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(K){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var ee=g;g=G;try{return K()}finally{g=ee}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(K,G){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var ee=g;g=K;try{return G()}finally{g=ee}},t.unstable_scheduleCallback=function(K,G,ee){var Z=t.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?Z+ee:Z):ee=Z,K){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=ee+Q,K={id:d++,callback:G,priorityLevel:K,startTime:ee,expirationTime:Q,sortIndex:-1},ee>Z?(K.sortIndex=ee,e(u,K),n(c)===null&&K===n(u)&&(y?(M(N),N=-1):y=!0,W(T,ee-Z))):(K.sortIndex=Q,e(c,K),b||m||(b=!0,k||(k=!0,O()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var G=g;return function(){var ee=g;g=G;try{return K.apply(this,arguments)}finally{g=ee}}}})(MA)),MA}var aF;function Pre(){return aF||(aF=1,SA.exports=kre()),SA.exports}var EA={exports:{}},ia={};var sF;function Rre(){if(sF)return ia;sF=1;var t=$m();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 s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ia.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ia.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)},ia.flushSync=function(c){var u=s.T,d=r.p;try{if(s.T=null,r.p=2,c)return c()}finally{s.T=u,r.p=d,r.d.f()}},ia.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))},ia.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ia.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ia.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=o(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)},ia.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=o(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})}},ia.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=o(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)},ia.requestFormReset=function(c){r.d.r(c)},ia.unstable_batchedUpdates=function(c,u){return c(u)},ia.useFormState=function(c,u,d){return s.H.useFormState(c,u,d)},ia.useFormStatus=function(){return s.H.useHostTransitionStatus()},ia.version="19.2.0",ia}var oF;function _9(){if(oF)return EA.exports;oF=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(),EA.exports=Rre(),EA.exports}var lF;function Dre(){if(lF)return rx;lF=1;var t=Pre(),e=$m(),n=_9();function r(h){var p="https://react.dev/errors/"+h;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+p+" 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 p=h,_=h;if(h.alternate)for(;p.return;)p=p.return;else{h=p;do p=h,(p.flags&4098)!==0&&(_=p.return),h=p.return;while(h)}return p.tag===3?_:null}function s(h){if(h.tag===13){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function o(h){if(h.tag===31){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var p=h.alternate;if(!p){if(p=a(h),p===null)throw Error(r(188));return p!==h?null:h}for(var _=h,w=p;;){var P=_.return;if(P===null)break;var j=P.alternate;if(j===null){if(w=P.return,w!==null){_=w;continue}break}if(P.child===j.child){for(j=P.child;j;){if(j===_)return c(P),h;if(j===w)return c(P),p;j=j.sibling}throw Error(r(188))}if(_.return!==w.return)_=P,w=j;else{for(var Y=!1,le=P.child;le;){if(le===_){Y=!0,_=P,w=j;break}if(le===w){Y=!0,w=P,_=j;break}le=le.sibling}if(!Y){for(le=j.child;le;){if(le===_){Y=!0,_=j,w=P;break}if(le===w){Y=!0,w=j,_=P;break}le=le.sibling}if(!Y)throw Error(r(189))}}if(_.alternate!==w)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:p}function d(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h;for(h=h.child;h!==null;){if(p=d(h),p!==null)return p;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=F&&h[F]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function R(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case x:return"Profiler";case v:return"StrictMode";case T:return"Suspense";case k:return"SuspenseList";case C:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case b:return"Portal";case S:return h.displayName||"Context";case M:return(h._context.displayName||"Context")+".Consumer";case A:var p=h.render;return h=h.displayName,h||(h=p.displayName||p.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case N:return p=h.displayName||null,p!==null?p:R(h.type)||"Memo";case I:p=h._payload,h=h._init;try{return R(h(p))}catch{}}return null}var W=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee={pending:!1,data:null,method:null,action:null},Z=[],Q=-1;function U(h){return{current:h}}function $(h){0>Q||(h.current=Z[Q],Z[Q]=null,Q--)}function X(h,p){Q++,Z[Q]=h.current,h.current=p}var te=U(null),fe=U(null),pe=U(null),be=U(null);function Ne(h,p){switch(X(pe,p),X(fe,h),X(te,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?S5(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=S5(p),h=M5(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}$(te),X(te,h)}function ie(){$(te),$(fe),$(pe)}function xe(h){h.memoizedState!==null&&X(be,h);var p=te.current,_=M5(p,h.type);p!==_&&(X(fe,h),X(te,_))}function Re(h){fe.current===h&&($(te),$(fe)),be.current===h&&($(be),Qg._currentValue=ee)}var he,ht;function H(h){if(he===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);he=p&&p[1]||"",ht=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+he+h+ht}var B=!1;function re(h,p){if(!h||B)return"";B=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var w={DetermineComponentFrameRoot:function(){try{if(p){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(at){var Ze=at}Reflect.construct(h,[],dt)}else{try{dt.call()}catch(at){Ze=at}h.call(dt.prototype)}}else{try{throw Error()}catch(at){Ze=at}(dt=h())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(at){if(at&&Ze&&typeof at.stack=="string")return[at.stack,Ze.stack]}return[null,null]}};w.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(w.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(w.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=w.DetermineComponentFrameRoot(),Y=j[0],le=j[1];if(Y&&le){var Ee=Y.split(`
  4. `),Xe=le.split(`
  5. `);for(P=w=0;w<Ee.length&&!Ee[w].includes("DetermineComponentFrameRoot");)w++;for(;P<Xe.length&&!Xe[P].includes("DetermineComponentFrameRoot");)P++;if(w===Ee.length||P===Xe.length)for(w=Ee.length-1,P=Xe.length-1;1<=w&&0<=P&&Ee[w]!==Xe[P];)P--;for(;1<=w&&0<=P;w--,P--)if(Ee[w]!==Xe[P]){if(w!==1||P!==1)do if(w--,P--,0>P||Ee[w]!==Xe[P]){var lt=`
  6. `+Ee[w].replace(" at new "," at ");return h.displayName&&lt.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",h.displayName)),lt}while(1<=w&&0<=P);break}}}finally{B=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?H(_):""}function V(h,p){switch(h.tag){case 26:case 27:case 5:return H(h.type);case 16:return H("Lazy");case 13:return h.child!==p&&p!==null?H("Suspense Fallback"):H("Suspense");case 19:return H("SuspenseList");case 0:case 15:return re(h.type,!1);case 11:return re(h.type.render,!1);case 1:return re(h.type,!0);case 31:return H("Activity");default:return""}}function J(h){try{var p="",_=null;do p+=V(h,_),_=h,h=h.return;while(h);return p}catch(w){return`
  7. Error generating stack: `+w.message+`
  8. `+w.stack}}var se=Object.prototype.hasOwnProperty,Ae=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,Se=t.unstable_shouldYield,z=t.unstable_requestPaint,L=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,ve=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,nt=t.unstable_LowPriority,Be=t.unstable_IdlePriority,ue=t.log,Ve=t.unstable_setDisableYieldValue,Fe=null,oe=null;function et(h){if(typeof ue=="function"&&Ve(h),oe&&typeof oe.setStrictMode=="function")try{oe.setStrictMode(Fe,h)}catch{}}var He=Math.clz32?Math.clz32:de,Ke=Math.log,ct=Math.LN2;function de(h){return h>>>=0,h===0?32:31-(Ke(h)/ct|0)|0}var Ye=256,ge=262144,Ue=4194304;function Ce(h){var p=h&42;if(p!==0)return p;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 _e(h,p,_){var w=h.pendingLanes;if(w===0)return 0;var P=0,j=h.suspendedLanes,Y=h.pingedLanes;h=h.warmLanes;var le=w&134217727;return le!==0?(w=le&~j,w!==0?P=Ce(w):(Y&=le,Y!==0?P=Ce(Y):_||(_=le&~h,_!==0&&(P=Ce(_))))):(le=w&~j,le!==0?P=Ce(le):Y!==0?P=Ce(Y):_||(_=w&~h,_!==0&&(P=Ce(_)))),P===0?0:p!==0&&p!==P&&(p&j)===0&&(j=P&-P,_=p&-p,j>=_||j===32&&(_&4194048)!==0)?p:P}function ce(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function st(h,p){switch(h){case 1:case 2:case 4:case 8:case 64:return p+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 p+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 xt(){var h=Ue;return Ue<<=1,(Ue&62914560)===0&&(Ue=4194304),h}function St(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function Qt(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ot(h,p,_,w,P,j){var Y=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var le=h.entanglements,Ee=h.expirationTimes,Xe=h.hiddenUpdates;for(_=Y&~_;0<_;){var lt=31-He(_),dt=1<<lt;le[lt]=0,Ee[lt]=-1;var Ze=Xe[lt];if(Ze!==null)for(Xe[lt]=null,lt=0;lt<Ze.length;lt++){var at=Ze[lt];at!==null&&(at.lane&=-536870913)}_&=~dt}w!==0&&Vt(h,w,0),j!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=j&~(Y&~p))}function Vt(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var w=31-He(p);h.entangledLanes|=p,h.entanglements[w]=h.entanglements[w]|1073741824|_&261930}function On(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var w=31-He(_),P=1<<w;P&p|h[w]&p&&(h[w]|=p),_&=~P}}function Mi(h,p){var _=p&-p;return _=(_&42)!==0?1:si(_),(_&(h.suspendedLanes|p))!==0?0:_}function si(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 Ei(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function zi(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:q5(h.type))}function ra(h,p){var _=G.p;try{return G.p=h,p()}finally{G.p=_}}var Hr=Math.random().toString(36).slice(2),br="__reactFiber$"+Hr,jr="__reactProps$"+Hr,mo="__reactContainer$"+Hr,$c="__reactEvents$"+Hr,me="__reactListeners$"+Hr,$e="__reactHandles$"+Hr,rt="__reactResources$"+Hr,it="__reactMarker$"+Hr;function tt(h){delete h[br],delete h[jr],delete h[$c],delete h[me],delete h[$e]}function Mt(h){var p=h[br];if(p)return p;for(var _=h.parentNode;_;){if(p=_[mo]||_[br]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=P5(h);h!==null;){if(_=h[br])return _;h=P5(h)}return p}h=_,_=h.parentNode}return null}function ae(h){if(h=h[br]||h[mo]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function Me(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Ie(h){var p=h[rt];return p||(p=h[rt]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Oe(h){h[it]=!0}var Te=new Set,ot={};function ft(h,p){yt(h,p),yt(h+"Capture",p)}function yt(h,p){for(ot[h]=p,h=0;h<p.length;h++)Te.add(p[h])}var bt=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]*$"),Lt={},Tt={};function mt(h){return se.call(Tt,h)?!0:se.call(Lt,h)?!1:bt.test(h)?Tt[h]=!0:(Lt[h]=!0,!1)}function Xt(h,p,_){if(mt(p))if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(p);return;case"boolean":var w=p.toLowerCase().slice(0,5);if(w!=="data-"&&w!=="aria-"){h.removeAttribute(p);return}}h.setAttribute(p,""+_)}}function Ut(h,p,_){if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(p);return}h.setAttribute(p,""+_)}}function an(h,p,_,w){if(w===null)h.removeAttribute(_);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(p,_,""+w)}}function hn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function bn(h){var p=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Ft(h,p,_){var w=Object.getOwnPropertyDescriptor(h.constructor.prototype,p);if(!h.hasOwnProperty(p)&&typeof w<"u"&&typeof w.get=="function"&&typeof w.set=="function"){var P=w.get,j=w.set;return Object.defineProperty(h,p,{configurable:!0,get:function(){return P.call(this)},set:function(Y){_=""+Y,j.call(this,Y)}}),Object.defineProperty(h,p,{enumerable:w.enumerable}),{getValue:function(){return _},setValue:function(Y){_=""+Y},stopTracking:function(){h._valueTracker=null,delete h[p]}}}}function Jt(h){if(!h._valueTracker){var p=bn(h)?"checked":"value";h._valueTracker=Ft(h,p,""+h[p])}}function tn(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),w="";return h&&(w=bn(h)?h.checked?"true":"false":h.value),h=w,h!==_?(p.setValue(h),!0):!1}function Ar(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 Or=/[\n"\\]/g;function Dn(h){return h.replace(Or,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function go(h,p,_,w,P,j,Y,le){h.name="",Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?h.type=Y:h.removeAttribute("type"),p!=null?Y==="number"?(p===0&&h.value===""||h.value!=p)&&(h.value=""+hn(p)):h.value!==""+hn(p)&&(h.value=""+hn(p)):Y!=="submit"&&Y!=="reset"||h.removeAttribute("value"),p!=null?Ai(h,Y,hn(p)):_!=null?Ai(h,Y,hn(_)):w!=null&&h.removeAttribute("value"),P==null&&j!=null&&(h.defaultChecked=!!j),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),le!=null&&typeof le!="function"&&typeof le!="symbol"&&typeof le!="boolean"?h.name=""+hn(le):h.removeAttribute("name")}function Ln(h,p,_,w,P,j,Y,le){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(h.type=j),p!=null||_!=null){if(!(j!=="submit"&&j!=="reset"||p!=null)){Jt(h);return}_=_!=null?""+hn(_):"",p=p!=null?""+hn(p):_,le||p===h.value||(h.value=p),h.defaultValue=p}w=w??P,w=typeof w!="function"&&typeof w!="symbol"&&!!w,h.checked=le?h.checked:!!w,h.defaultChecked=!!w,Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"&&(h.name=Y),Jt(h)}function Ai(h,p,_){p==="number"&&Ar(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function oi(h,p,_,w){if(h=h.options,p){p={};for(var P=0;P<_.length;P++)p["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=p.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&w&&(h[_].defaultSelected=!0)}else{for(_=""+hn(_),p=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,w&&(h[P].defaultSelected=!0);return}p!==null||h[P].disabled||(p=h[P])}p!==null&&(p.selected=!0)}}function Ti(h,p,_){if(p!=null&&(p=""+hn(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+hn(_):""}function Bi(h,p,_,w){if(p==null){if(w!=null){if(_!=null)throw Error(r(92));if(W(w)){if(1<w.length)throw Error(r(93));w=w[0]}_=w}_==null&&(_=""),p=_}_=hn(p),h.defaultValue=_,w=h.textContent,w===_&&w!==""&&w!==null&&(h.value=w),Jt(h)}function Vo(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var Al=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 vL(h,p,_){var w=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?w?h.setProperty(p,""):p==="float"?h.cssFloat="":h[p]="":w?h.setProperty(p,_):typeof _!="number"||_===0||Al.has(p)?p==="float"?h.cssFloat=_:h[p]=(""+_).trim():h[p]=_+"px"}function _L(h,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(h=h.style,_!=null){for(var w in _)!_.hasOwnProperty(w)||p!=null&&p.hasOwnProperty(w)||(w.indexOf("--")===0?h.setProperty(w,""):w==="float"?h.cssFloat="":h[w]="");for(var P in p)w=p[P],p.hasOwnProperty(P)&&_[P]!==w&&vL(h,P,w)}else for(var j in p)p.hasOwnProperty(j)&&vL(h,j,p[j])}function gE(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 _te=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"]]),wte=/^[\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 ry(h){return wte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Tl(){}var xE=null;function bE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var xf=null,bf=null;function wL(h){var p=ae(h);if(p&&(h=p.stateNode)){var _=h[jr]||null;e:switch(h=p.stateNode,p.type){case"input":if(go(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Dn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var w=_[p];if(w!==h&&w.form===h.form){var P=w[jr]||null;if(!P)throw Error(r(90));go(w,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(p=0;p<_.length;p++)w=_[p],w.form===h.form&&tn(w)}break e;case"textarea":Ti(h,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&oi(h,!!_.multiple,p,!1)}}}var yE=!1;function SL(h,p,_){if(yE)return h(p,_);yE=!0;try{var w=h(p);return w}finally{if(yE=!1,(xf!==null||bf!==null)&&(Vy(),xf&&(p=xf,h=bf,bf=xf=null,wL(p),h)))for(p=0;p<h.length;p++)wL(h[p])}}function mg(h,p){var _=h.stateNode;if(_===null)return null;var w=_[jr]||null;if(w===null)return null;_=w[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(h=h.type,w=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!w;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var Cl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vE=!1;if(Cl)try{var gg={};Object.defineProperty(gg,"passive",{get:function(){vE=!0}}),window.addEventListener("test",gg,gg),window.removeEventListener("test",gg,gg)}catch{vE=!1}var Vc=null,_E=null,iy=null;function ML(){if(iy)return iy;var h,p=_E,_=p.length,w,P="value"in Vc?Vc.value:Vc.textContent,j=P.length;for(h=0;h<_&&p[h]===P[h];h++);var Y=_-h;for(w=1;w<=Y&&p[_-w]===P[j-w];w++);return iy=P.slice(h,1<w?1-w:void 0)}function ay(h){var p=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&p===13&&(h=13)):h=p,h===10&&(h=13),32<=h||h===13?h:0}function sy(){return!0}function EL(){return!1}function ja(h){function p(_,w,P,j,Y){this._reactName=_,this._targetInst=P,this.type=w,this.nativeEvent=j,this.target=Y,this.currentTarget=null;for(var le in h)h.hasOwnProperty(le)&&(_=h[le],this[le]=_?_(j):j[le]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?sy:EL,this.isPropagationStopped=EL,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=sy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=sy)},persist:function(){},isPersistent:sy}),p}var Td={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},oy=ja(Td),xg=f({},Td,{view:0,detail:0}),Ste=ja(xg),wE,SE,bg,ly=f({},xg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:EE,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!==bg&&(bg&&h.type==="mousemove"?(wE=h.screenX-bg.screenX,SE=h.screenY-bg.screenY):SE=wE=0,bg=h),wE)},movementY:function(h){return"movementY"in h?h.movementY:SE}}),AL=ja(ly),Mte=f({},ly,{dataTransfer:0}),Ete=ja(Mte),Ate=f({},xg,{relatedTarget:0}),ME=ja(Ate),Tte=f({},Td,{animationName:0,elapsedTime:0,pseudoElement:0}),Cte=ja(Tte),Nte=f({},Td,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),kte=ja(Nte),Pte=f({},Td,{data:0}),TL=ja(Pte),Rte={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Dte={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"},jte={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ote(h){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(h):(h=jte[h])?!!p[h]:!1}function EE(){return Ote}var Lte=f({},xg,{key:function(h){if(h.key){var p=Rte[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=ay(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Dte[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:EE,charCode:function(h){return h.type==="keypress"?ay(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?ay(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Ite=ja(Lte),Fte=f({},ly,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),CL=ja(Fte),Ute=f({},xg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:EE}),zte=ja(Ute),Bte=f({},Td,{propertyName:0,elapsedTime:0,pseudoElement:0}),Hte=ja(Bte),$te=f({},ly,{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}),Vte=ja($te),Gte=f({},Td,{newState:0,oldState:0}),Wte=ja(Gte),qte=[9,13,27,32],AE=Cl&&"CompositionEvent"in window,yg=null;Cl&&"documentMode"in document&&(yg=document.documentMode);var Kte=Cl&&"TextEvent"in window&&!yg,NL=Cl&&(!AE||yg&&8<yg&&11>=yg),kL=" ",PL=!1;function RL(h,p){switch(h){case"keyup":return qte.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function DL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var yf=!1;function Xte(h,p){switch(h){case"compositionend":return DL(p);case"keypress":return p.which!==32?null:(PL=!0,kL);case"textInput":return h=p.data,h===kL&&PL?null:h;default:return null}}function Yte(h,p){if(yf)return h==="compositionend"||!AE&&RL(h,p)?(h=ML(),iy=_E=Vc=null,yf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return NL&&p.locale!=="ko"?null:p.data;default:return null}}var Zte={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 jL(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p==="input"?!!Zte[h.type]:p==="textarea"}function OL(h,p,_,w){xf?bf?bf.push(w):bf=[w]:xf=w,p=Zy(p,"onChange"),0<p.length&&(_=new oy("onChange","change",null,_,w),h.push({event:_,listeners:p}))}var vg=null,_g=null;function Qte(h){x5(h,0)}function cy(h){var p=Me(h);if(tn(p))return h}function LL(h,p){if(h==="change")return p}var IL=!1;if(Cl){var TE;if(Cl){var CE="oninput"in document;if(!CE){var FL=document.createElement("div");FL.setAttribute("oninput","return;"),CE=typeof FL.oninput=="function"}TE=CE}else TE=!1;IL=TE&&(!document.documentMode||9<document.documentMode)}function UL(){vg&&(vg.detachEvent("onpropertychange",zL),_g=vg=null)}function zL(h){if(h.propertyName==="value"&&cy(_g)){var p=[];OL(p,_g,h,bE(h)),SL(Qte,p)}}function Jte(h,p,_){h==="focusin"?(UL(),vg=p,_g=_,vg.attachEvent("onpropertychange",zL)):h==="focusout"&&UL()}function ene(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return cy(_g)}function tne(h,p){if(h==="click")return cy(p)}function nne(h,p){if(h==="input"||h==="change")return cy(p)}function rne(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var ts=typeof Object.is=="function"?Object.is:rne;function wg(h,p){if(ts(h,p))return!0;if(typeof h!="object"||h===null||typeof p!="object"||p===null)return!1;var _=Object.keys(h),w=Object.keys(p);if(_.length!==w.length)return!1;for(w=0;w<_.length;w++){var P=_[w];if(!se.call(p,P)||!ts(h[P],p[P]))return!1}return!0}function BL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function HL(h,p){var _=BL(h);h=0;for(var w;_;){if(_.nodeType===3){if(w=h+_.textContent.length,h<=p&&w>=p)return{node:_,offset:p-h};h=w}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=BL(_)}}function $L(h,p){return h&&p?h===p?!0:h&&h.nodeType===3?!1:p&&p.nodeType===3?$L(h,p.parentNode):"contains"in h?h.contains(p):h.compareDocumentPosition?!!(h.compareDocumentPosition(p)&16):!1:!1}function VL(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var p=Ar(h.document);p instanceof h.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)h=p.contentWindow;else break;p=Ar(h.document)}return p}function NE(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p&&(p==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||p==="textarea"||h.contentEditable==="true")}var ine=Cl&&"documentMode"in document&&11>=document.documentMode,vf=null,kE=null,Sg=null,PE=!1;function GL(h,p,_){var w=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;PE||vf==null||vf!==Ar(w)||(w=vf,"selectionStart"in w&&NE(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Sg&&wg(Sg,w)||(Sg=w,w=Zy(kE,"onSelect"),0<w.length&&(p=new oy("onSelect","select",null,p,_),h.push({event:p,listeners:w}),p.target=vf)))}function Cd(h,p){var _={};return _[h.toLowerCase()]=p.toLowerCase(),_["Webkit"+h]="webkit"+p,_["Moz"+h]="moz"+p,_}var _f={animationend:Cd("Animation","AnimationEnd"),animationiteration:Cd("Animation","AnimationIteration"),animationstart:Cd("Animation","AnimationStart"),transitionrun:Cd("Transition","TransitionRun"),transitionstart:Cd("Transition","TransitionStart"),transitioncancel:Cd("Transition","TransitionCancel"),transitionend:Cd("Transition","TransitionEnd")},RE={},WL={};Cl&&(WL=document.createElement("div").style,"AnimationEvent"in window||(delete _f.animationend.animation,delete _f.animationiteration.animation,delete _f.animationstart.animation),"TransitionEvent"in window||delete _f.transitionend.transition);function Nd(h){if(RE[h])return RE[h];if(!_f[h])return h;var p=_f[h],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in WL)return RE[h]=p[_];return h}var qL=Nd("animationend"),KL=Nd("animationiteration"),XL=Nd("animationstart"),ane=Nd("transitionrun"),sne=Nd("transitionstart"),one=Nd("transitioncancel"),YL=Nd("transitionend"),ZL=new Map,DE="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(" ");DE.push("scrollEnd");function xo(h,p){ZL.set(h,p),ft(p,[h])}var uy=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=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(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},ks=[],wf=0,jE=0;function dy(){for(var h=wf,p=jE=wf=0;p<h;){var _=ks[p];ks[p++]=null;var w=ks[p];ks[p++]=null;var P=ks[p];ks[p++]=null;var j=ks[p];if(ks[p++]=null,w!==null&&P!==null){var Y=w.pending;Y===null?P.next=P:(P.next=Y.next,Y.next=P),w.pending=P}j!==0&&QL(_,P,j)}}function hy(h,p,_,w){ks[wf++]=h,ks[wf++]=p,ks[wf++]=_,ks[wf++]=w,jE|=w,h.lanes|=w,h=h.alternate,h!==null&&(h.lanes|=w)}function OE(h,p,_,w){return hy(h,p,_,w),fy(h)}function kd(h,p){return hy(h,null,null,p),fy(h)}function QL(h,p,_){h.lanes|=_;var w=h.alternate;w!==null&&(w.lanes|=_);for(var P=!1,j=h.return;j!==null;)j.childLanes|=_,w=j.alternate,w!==null&&(w.childLanes|=_),j.tag===22&&(h=j.stateNode,h===null||h._visibility&1||(P=!0)),h=j,j=j.return;return h.tag===3?(j=h.stateNode,P&&p!==null&&(P=31-He(_),h=j.hiddenUpdates,w=h[P],w===null?h[P]=[p]:w.push(p),p.lane=_|536870912),j):null}function fy(h){if(50<Gg)throw Gg=0,V2=null,Error(r(185));for(var p=h.return;p!==null;)h=p,p=h.return;return h.tag===3?h.stateNode:null}var Sf={};function lne(h,p,_,w){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=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ns(h,p,_,w){return new lne(h,p,_,w)}function LE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Nl(h,p){var _=h.alternate;return _===null?(_=ns(h.tag,p,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=p,_.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,p=h.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function JL(h,p){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=p,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,p=_.dependencies,h.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),h}function py(h,p,_,w,P,j){var Y=0;if(w=h,typeof h=="function")LE(h)&&(Y=1);else if(typeof h=="string")Y=fre(h,_,te.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case C:return h=ns(31,_,p,P),h.elementType=C,h.lanes=j,h;case y:return Pd(_.children,P,j,p);case v:Y=8,P|=24;break;case x:return h=ns(12,_,p,P|2),h.elementType=x,h.lanes=j,h;case T:return h=ns(13,_,p,P),h.elementType=T,h.lanes=j,h;case k:return h=ns(19,_,p,P),h.elementType=k,h.lanes=j,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:Y=10;break e;case M:Y=9;break e;case A:Y=11;break e;case N:Y=14;break e;case I:Y=16,w=null;break e}Y=29,_=Error(r(130,h===null?"null":typeof h,"")),w=null}return p=ns(Y,_,p,P),p.elementType=h,p.type=w,p.lanes=j,p}function Pd(h,p,_,w){return h=ns(7,h,w,p),h.lanes=_,h}function IE(h,p,_){return h=ns(6,h,null,p),h.lanes=_,h}function e4(h){var p=ns(18,null,null,0);return p.stateNode=h,p}function FE(h,p,_){return p=ns(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}var t4=new WeakMap;function Ps(h,p){if(typeof h=="object"&&h!==null){var _=t4.get(h);return _!==void 0?_:(p={value:h,source:p,stack:J(p)},t4.set(h,p),p)}return{value:h,source:p,stack:J(p)}}var Mf=[],Ef=0,my=null,Mg=0,Rs=[],Ds=0,Gc=null,Go=1,Wo="";function kl(h,p){Mf[Ef++]=Mg,Mf[Ef++]=my,my=h,Mg=p}function n4(h,p,_){Rs[Ds++]=Go,Rs[Ds++]=Wo,Rs[Ds++]=Gc,Gc=h;var w=Go;h=Wo;var P=32-He(w)-1;w&=~(1<<P),_+=1;var j=32-He(p)+P;if(30<j){var Y=P-P%5;j=(w&(1<<Y)-1).toString(32),w>>=Y,P-=Y,Go=1<<32-He(p)+P|_<<P|w,Wo=j+h}else Go=1<<j|_<<P|w,Wo=h}function UE(h){h.return!==null&&(kl(h,1),n4(h,1,0))}function zE(h){for(;h===my;)my=Mf[--Ef],Mf[Ef]=null,Mg=Mf[--Ef],Mf[Ef]=null;for(;h===Gc;)Gc=Rs[--Ds],Rs[Ds]=null,Wo=Rs[--Ds],Rs[Ds]=null,Go=Rs[--Ds],Rs[Ds]=null}function r4(h,p){Rs[Ds++]=Go,Rs[Ds++]=Wo,Rs[Ds++]=Gc,Go=p.id,Wo=p.overflow,Gc=h}var Hi=null,sr=null,wn=!1,Wc=null,js=!1,BE=Error(r(519));function qc(h){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Eg(Ps(p,h)),BE}function i4(h){var p=h.stateNode,_=h.type,w=h.memoizedProps;switch(p[br]=h,p[jr]=w,_){case"dialog":mn("cancel",p),mn("close",p);break;case"iframe":case"object":case"embed":mn("load",p);break;case"video":case"audio":for(_=0;_<qg.length;_++)mn(qg[_],p);break;case"source":mn("error",p);break;case"img":case"image":case"link":mn("error",p),mn("load",p);break;case"details":mn("toggle",p);break;case"input":mn("invalid",p),Ln(p,w.value,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name,!0);break;case"select":mn("invalid",p);break;case"textarea":mn("invalid",p),Bi(p,w.value,w.defaultValue,w.children)}_=w.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||w.suppressHydrationWarning===!0||_5(p.textContent,_)?(w.popover!=null&&(mn("beforetoggle",p),mn("toggle",p)),w.onScroll!=null&&mn("scroll",p),w.onScrollEnd!=null&&mn("scrollend",p),w.onClick!=null&&(p.onclick=Tl),p=!0):p=!1,p||qc(h,!0)}function a4(h){for(Hi=h.return;Hi;)switch(Hi.tag){case 5:case 31:case 13:js=!1;return;case 27:case 3:js=!0;return;default:Hi=Hi.return}}function Af(h){if(h!==Hi)return!1;if(!wn)return a4(h),wn=!0,!1;var p=h.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||aA(h.type,h.memoizedProps)),_=!_),_&&sr&&qc(h),a4(h),p===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));sr=k5(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));sr=k5(h)}else p===27?(p=sr,ou(h.type)?(h=uA,uA=null,sr=h):sr=p):sr=Hi?Ls(h.stateNode.nextSibling):null;return!0}function Rd(){sr=Hi=null,wn=!1}function HE(){var h=Wc;return h!==null&&(Fa===null?Fa=h:Fa.push.apply(Fa,h),Wc=null),h}function Eg(h){Wc===null?Wc=[h]:Wc.push(h)}var $E=U(null),Dd=null,Pl=null;function Kc(h,p,_){X($E,p._currentValue),p._currentValue=_}function Rl(h){h._currentValue=$E.current,$($E)}function VE(h,p,_){for(;h!==null;){var w=h.alternate;if((h.childLanes&p)!==p?(h.childLanes|=p,w!==null&&(w.childLanes|=p)):w!==null&&(w.childLanes&p)!==p&&(w.childLanes|=p),h===_)break;h=h.return}}function GE(h,p,_,w){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var j=P.dependencies;if(j!==null){var Y=P.child;j=j.firstContext;e:for(;j!==null;){var le=j;j=P;for(var Ee=0;Ee<p.length;Ee++)if(le.context===p[Ee]){j.lanes|=_,le=j.alternate,le!==null&&(le.lanes|=_),VE(j.return,_,h),w||(Y=null);break e}j=le.next}}else if(P.tag===18){if(Y=P.return,Y===null)throw Error(r(341));Y.lanes|=_,j=Y.alternate,j!==null&&(j.lanes|=_),VE(Y,_,h),Y=null}else Y=P.child;if(Y!==null)Y.return=P;else for(Y=P;Y!==null;){if(Y===h){Y=null;break}if(P=Y.sibling,P!==null){P.return=Y.return,Y=P;break}Y=Y.return}P=Y}}function Tf(h,p,_,w){h=null;for(var P=p,j=!1;P!==null;){if(!j){if((P.flags&524288)!==0)j=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var Y=P.alternate;if(Y===null)throw Error(r(387));if(Y=Y.memoizedProps,Y!==null){var le=P.type;ts(P.pendingProps.value,Y.value)||(h!==null?h.push(le):h=[le])}}else if(P===be.current){if(Y=P.alternate,Y===null)throw Error(r(387));Y.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Qg):h=[Qg])}P=P.return}h!==null&&GE(p,h,_,w),p.flags|=262144}function gy(h){for(h=h.firstContext;h!==null;){if(!ts(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function jd(h){Dd=h,Pl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function $i(h){return s4(Dd,h)}function xy(h,p){return Dd===null&&jd(h),s4(h,p)}function s4(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},Pl===null){if(h===null)throw Error(r(308));Pl=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else Pl=Pl.next=p;return _}var cne=typeof AbortController<"u"?AbortController:function(){var h=[],p=this.signal={aborted:!1,addEventListener:function(_,w){h.push(w)}};this.abort=function(){p.aborted=!0,h.forEach(function(_){return _()})}},une=t.unstable_scheduleCallback,dne=t.unstable_NormalPriority,$r={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function WE(){return{controller:new cne,data:new Map,refCount:0}}function Ag(h){h.refCount--,h.refCount===0&&une(dne,function(){h.controller.abort()})}var Tg=null,qE=0,Cf=0,Nf=null;function hne(h,p){if(Tg===null){var _=Tg=[];qE=0,Cf=Y2(),Nf={status:"pending",value:void 0,then:function(w){_.push(w)}}}return qE++,p.then(o4,o4),p}function o4(){if(--qE===0&&Tg!==null){Nf!==null&&(Nf.status="fulfilled");var h=Tg;Tg=null,Cf=0,Nf=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function fne(h,p){var _=[],w={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){w.status="fulfilled",w.value=p;for(var P=0;P<_.length;P++)(0,_[P])(p)},function(P){for(w.status="rejected",w.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),w}var l4=K.S;K.S=function(h,p){GI=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&hne(h,p),l4!==null&&l4(h,p)};var Od=U(null);function KE(){var h=Od.current;return h!==null?h:Jn.pooledCache}function by(h,p){p===null?X(Od,Od.current):X(Od,p.pool)}function c4(){var h=KE();return h===null?null:{parent:$r._currentValue,pool:h}}var kf=Error(r(460)),XE=Error(r(474)),yy=Error(r(542)),vy={then:function(){}};function u4(h){return h=h.status,h==="fulfilled"||h==="rejected"}function d4(h,p,_){switch(_=h[_],_===void 0?h.push(p):_!==p&&(p.then(Tl,Tl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,f4(h),h;default:if(typeof p.status=="string")p.then(Tl,Tl);else{if(h=Jn,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=p,h.status="pending",h.then(function(w){if(p.status==="pending"){var P=p;P.status="fulfilled",P.value=w}},function(w){if(p.status==="pending"){var P=p;P.status="rejected",P.reason=w}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,f4(h),h}throw Id=p,kf}}function Ld(h){try{var p=h._init;return p(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Id=_,kf):_}}var Id=null;function h4(){if(Id===null)throw Error(r(459));var h=Id;return Id=null,h}function f4(h){if(h===kf||h===yy)throw Error(r(483))}var Pf=null,Cg=0;function _y(h){var p=Cg;return Cg+=1,Pf===null&&(Pf=[]),d4(Pf,h,p)}function Ng(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function wy(h,p){throw p.$$typeof===g?Error(r(525)):(h=Object.prototype.toString.call(p),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":h)))}function p4(h){function p(ze,De){if(h){var We=ze.deletions;We===null?(ze.deletions=[De],ze.flags|=16):We.push(De)}}function _(ze,De){if(!h)return null;for(;De!==null;)p(ze,De),De=De.sibling;return null}function w(ze){for(var De=new Map;ze!==null;)ze.key!==null?De.set(ze.key,ze):De.set(ze.index,ze),ze=ze.sibling;return De}function P(ze,De){return ze=Nl(ze,De),ze.index=0,ze.sibling=null,ze}function j(ze,De,We){return ze.index=We,h?(We=ze.alternate,We!==null?(We=We.index,We<De?(ze.flags|=67108866,De):We):(ze.flags|=67108866,De)):(ze.flags|=1048576,De)}function Y(ze){return h&&ze.alternate===null&&(ze.flags|=67108866),ze}function le(ze,De,We,ut){return De===null||De.tag!==6?(De=IE(We,ze.mode,ut),De.return=ze,De):(De=P(De,We),De.return=ze,De)}function Ee(ze,De,We,ut){var zt=We.type;return zt===y?lt(ze,De,We.props.children,ut,We.key):De!==null&&(De.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Ld(zt)===De.type)?(De=P(De,We.props),Ng(De,We),De.return=ze,De):(De=py(We.type,We.key,We.props,null,ze.mode,ut),Ng(De,We),De.return=ze,De)}function Xe(ze,De,We,ut){return De===null||De.tag!==4||De.stateNode.containerInfo!==We.containerInfo||De.stateNode.implementation!==We.implementation?(De=FE(We,ze.mode,ut),De.return=ze,De):(De=P(De,We.children||[]),De.return=ze,De)}function lt(ze,De,We,ut,zt){return De===null||De.tag!==7?(De=Pd(We,ze.mode,ut,zt),De.return=ze,De):(De=P(De,We),De.return=ze,De)}function dt(ze,De,We){if(typeof De=="string"&&De!==""||typeof De=="number"||typeof De=="bigint")return De=IE(""+De,ze.mode,We),De.return=ze,De;if(typeof De=="object"&&De!==null){switch(De.$$typeof){case m:return We=py(De.type,De.key,De.props,null,ze.mode,We),Ng(We,De),We.return=ze,We;case b:return De=FE(De,ze.mode,We),De.return=ze,De;case I:return De=Ld(De),dt(ze,De,We)}if(W(De)||O(De))return De=Pd(De,ze.mode,We,null),De.return=ze,De;if(typeof De.then=="function")return dt(ze,_y(De),We);if(De.$$typeof===S)return dt(ze,xy(ze,De),We);wy(ze,De)}return null}function Ze(ze,De,We,ut){var zt=De!==null?De.key:null;if(typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint")return zt!==null?null:le(ze,De,""+We,ut);if(typeof We=="object"&&We!==null){switch(We.$$typeof){case m:return We.key===zt?Ee(ze,De,We,ut):null;case b:return We.key===zt?Xe(ze,De,We,ut):null;case I:return We=Ld(We),Ze(ze,De,We,ut)}if(W(We)||O(We))return zt!==null?null:lt(ze,De,We,ut,null);if(typeof We.then=="function")return Ze(ze,De,_y(We),ut);if(We.$$typeof===S)return Ze(ze,De,xy(ze,We),ut);wy(ze,We)}return null}function at(ze,De,We,ut,zt){if(typeof ut=="string"&&ut!==""||typeof ut=="number"||typeof ut=="bigint")return ze=ze.get(We)||null,le(De,ze,""+ut,zt);if(typeof ut=="object"&&ut!==null){switch(ut.$$typeof){case m:return ze=ze.get(ut.key===null?We:ut.key)||null,Ee(De,ze,ut,zt);case b:return ze=ze.get(ut.key===null?We:ut.key)||null,Xe(De,ze,ut,zt);case I:return ut=Ld(ut),at(ze,De,We,ut,zt)}if(W(ut)||O(ut))return ze=ze.get(We)||null,lt(De,ze,ut,zt,null);if(typeof ut.then=="function")return at(ze,De,We,_y(ut),zt);if(ut.$$typeof===S)return at(ze,De,We,xy(De,ut),zt);wy(De,ut)}return null}function jt(ze,De,We,ut){for(var zt=null,An=null,It=De,rn=De=0,vn=null;It!==null&&rn<We.length;rn++){It.index>rn?(vn=It,It=null):vn=It.sibling;var Tn=Ze(ze,It,We[rn],ut);if(Tn===null){It===null&&(It=vn);break}h&&It&&Tn.alternate===null&&p(ze,It),De=j(Tn,De,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn,It=vn}if(rn===We.length)return _(ze,It),wn&&kl(ze,rn),zt;if(It===null){for(;rn<We.length;rn++)It=dt(ze,We[rn],ut),It!==null&&(De=j(It,De,rn),An===null?zt=It:An.sibling=It,An=It);return wn&&kl(ze,rn),zt}for(It=w(It);rn<We.length;rn++)vn=at(It,ze,rn,We[rn],ut),vn!==null&&(h&&vn.alternate!==null&&It.delete(vn.key===null?rn:vn.key),De=j(vn,De,rn),An===null?zt=vn:An.sibling=vn,An=vn);return h&&It.forEach(function(hu){return p(ze,hu)}),wn&&kl(ze,rn),zt}function Gt(ze,De,We,ut){if(We==null)throw Error(r(151));for(var zt=null,An=null,It=De,rn=De=0,vn=null,Tn=We.next();It!==null&&!Tn.done;rn++,Tn=We.next()){It.index>rn?(vn=It,It=null):vn=It.sibling;var hu=Ze(ze,It,Tn.value,ut);if(hu===null){It===null&&(It=vn);break}h&&It&&hu.alternate===null&&p(ze,It),De=j(hu,De,rn),An===null?zt=hu:An.sibling=hu,An=hu,It=vn}if(Tn.done)return _(ze,It),wn&&kl(ze,rn),zt;if(It===null){for(;!Tn.done;rn++,Tn=We.next())Tn=dt(ze,Tn.value,ut),Tn!==null&&(De=j(Tn,De,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn);return wn&&kl(ze,rn),zt}for(It=w(It);!Tn.done;rn++,Tn=We.next())Tn=at(It,ze,rn,Tn.value,ut),Tn!==null&&(h&&Tn.alternate!==null&&It.delete(Tn.key===null?rn:Tn.key),De=j(Tn,De,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn);return h&&It.forEach(function(Mre){return p(ze,Mre)}),wn&&kl(ze,rn),zt}function Gn(ze,De,We,ut){if(typeof We=="object"&&We!==null&&We.type===y&&We.key===null&&(We=We.props.children),typeof We=="object"&&We!==null){switch(We.$$typeof){case m:e:{for(var zt=We.key;De!==null;){if(De.key===zt){if(zt=We.type,zt===y){if(De.tag===7){_(ze,De.sibling),ut=P(De,We.props.children),ut.return=ze,ze=ut;break e}}else if(De.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Ld(zt)===De.type){_(ze,De.sibling),ut=P(De,We.props),Ng(ut,We),ut.return=ze,ze=ut;break e}_(ze,De);break}else p(ze,De);De=De.sibling}We.type===y?(ut=Pd(We.props.children,ze.mode,ut,We.key),ut.return=ze,ze=ut):(ut=py(We.type,We.key,We.props,null,ze.mode,ut),Ng(ut,We),ut.return=ze,ze=ut)}return Y(ze);case b:e:{for(zt=We.key;De!==null;){if(De.key===zt)if(De.tag===4&&De.stateNode.containerInfo===We.containerInfo&&De.stateNode.implementation===We.implementation){_(ze,De.sibling),ut=P(De,We.children||[]),ut.return=ze,ze=ut;break e}else{_(ze,De);break}else p(ze,De);De=De.sibling}ut=FE(We,ze.mode,ut),ut.return=ze,ze=ut}return Y(ze);case I:return We=Ld(We),Gn(ze,De,We,ut)}if(W(We))return jt(ze,De,We,ut);if(O(We)){if(zt=O(We),typeof zt!="function")throw Error(r(150));return We=zt.call(We),Gt(ze,De,We,ut)}if(typeof We.then=="function")return Gn(ze,De,_y(We),ut);if(We.$$typeof===S)return Gn(ze,De,xy(ze,We),ut);wy(ze,We)}return typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint"?(We=""+We,De!==null&&De.tag===6?(_(ze,De.sibling),ut=P(De,We),ut.return=ze,ze=ut):(_(ze,De),ut=IE(We,ze.mode,ut),ut.return=ze,ze=ut),Y(ze)):_(ze,De)}return function(ze,De,We,ut){try{Cg=0;var zt=Gn(ze,De,We,ut);return Pf=null,zt}catch(It){if(It===kf||It===yy)throw It;var An=ns(29,It,null,ze.mode);return An.lanes=ut,An.return=ze,An}finally{}}}var Fd=p4(!0),m4=p4(!1),Xc=!1;function YE(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ZE(h,p){h=h.updateQueue,p.updateQueue===h&&(p.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function Yc(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Zc(h,p,_){var w=h.updateQueue;if(w===null)return null;if(w=w.shared,(kn&2)!==0){var P=w.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),w.pending=p,p=fy(h),QL(h,null,_),p}return hy(h,w,p,_),fy(h)}function kg(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,On(h,_)}}function QE(h,p){var _=h.updateQueue,w=h.alternate;if(w!==null&&(w=w.updateQueue,_===w)){var P=null,j=null;if(_=_.firstBaseUpdate,_!==null){do{var Y={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};j===null?P=j=Y:j=j.next=Y,_=_.next}while(_!==null);j===null?P=j=p:j=j.next=p}else P=j=p;_={baseState:w.baseState,firstBaseUpdate:P,lastBaseUpdate:j,shared:w.shared,callbacks:w.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=p:h.next=p,_.lastBaseUpdate=p}var JE=!1;function Pg(){if(JE){var h=Nf;if(h!==null)throw h}}function Rg(h,p,_,w){JE=!1;var P=h.updateQueue;Xc=!1;var j=P.firstBaseUpdate,Y=P.lastBaseUpdate,le=P.shared.pending;if(le!==null){P.shared.pending=null;var Ee=le,Xe=Ee.next;Ee.next=null,Y===null?j=Xe:Y.next=Xe,Y=Ee;var lt=h.alternate;lt!==null&&(lt=lt.updateQueue,le=lt.lastBaseUpdate,le!==Y&&(le===null?lt.firstBaseUpdate=Xe:le.next=Xe,lt.lastBaseUpdate=Ee))}if(j!==null){var dt=P.baseState;Y=0,lt=Xe=Ee=null,le=j;do{var Ze=le.lane&-536870913,at=Ze!==le.lane;if(at?(yn&Ze)===Ze:(w&Ze)===Ze){Ze!==0&&Ze===Cf&&(JE=!0),lt!==null&&(lt=lt.next={lane:0,tag:le.tag,payload:le.payload,callback:null,next:null});e:{var jt=h,Gt=le;Ze=p;var Gn=_;switch(Gt.tag){case 1:if(jt=Gt.payload,typeof jt=="function"){dt=jt.call(Gn,dt,Ze);break e}dt=jt;break e;case 3:jt.flags=jt.flags&-65537|128;case 0:if(jt=Gt.payload,Ze=typeof jt=="function"?jt.call(Gn,dt,Ze):jt,Ze==null)break e;dt=f({},dt,Ze);break e;case 2:Xc=!0}}Ze=le.callback,Ze!==null&&(h.flags|=64,at&&(h.flags|=8192),at=P.callbacks,at===null?P.callbacks=[Ze]:at.push(Ze))}else at={lane:Ze,tag:le.tag,payload:le.payload,callback:le.callback,next:null},lt===null?(Xe=lt=at,Ee=dt):lt=lt.next=at,Y|=Ze;if(le=le.next,le===null){if(le=P.shared.pending,le===null)break;at=le,le=at.next,at.next=null,P.lastBaseUpdate=at,P.shared.pending=null}}while(!0);lt===null&&(Ee=dt),P.baseState=Ee,P.firstBaseUpdate=Xe,P.lastBaseUpdate=lt,j===null&&(P.shared.lanes=0),nu|=Y,h.lanes=Y,h.memoizedState=dt}}function g4(h,p){if(typeof h!="function")throw Error(r(191,h));h.call(p)}function x4(h,p){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)g4(_[h],p)}var Rf=U(null),Sy=U(0);function b4(h,p){h=Bl,X(Sy,h),X(Rf,p),Bl=h|p.baseLanes}function e2(){X(Sy,Bl),X(Rf,Rf.current)}function t2(){Bl=Sy.current,$(Rf),$(Sy)}var rs=U(null),Os=null;function Qc(h){var p=h.alternate;X(Lr,Lr.current&1),X(rs,h),Os===null&&(p===null||Rf.current!==null||p.memoizedState!==null)&&(Os=h)}function n2(h){X(Lr,Lr.current),X(rs,h),Os===null&&(Os=h)}function y4(h){h.tag===22?(X(Lr,Lr.current),X(rs,h),Os===null&&(Os=h)):Jc()}function Jc(){X(Lr,Lr.current),X(rs,rs.current)}function is(h){$(rs),Os===h&&(Os=null),$(Lr)}var Lr=U(0);function My(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||lA(_)||cA(_)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var Dl=0,nn=null,$n=null,Vr=null,Ey=!1,Df=!1,Ud=!1,Ay=0,Dg=0,jf=null,pne=0;function Tr(){throw Error(r(321))}function r2(h,p){if(p===null)return!1;for(var _=0;_<p.length&&_<h.length;_++)if(!ts(h[_],p[_]))return!1;return!0}function i2(h,p,_,w,P,j){return Dl=j,nn=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,K.H=h===null||h.memoizedState===null?nI:y2,Ud=!1,j=_(w,P),Ud=!1,Df&&(j=_4(p,_,w,P)),v4(h),j}function v4(h){K.H=Lg;var p=$n!==null&&$n.next!==null;if(Dl=0,Vr=$n=nn=null,Ey=!1,Dg=0,jf=null,p)throw Error(r(300));h===null||Gr||(h=h.dependencies,h!==null&&gy(h)&&(Gr=!0))}function _4(h,p,_,w){nn=h;var P=0;do{if(Df&&(jf=null),Dg=0,Df=!1,25<=P)throw Error(r(301));if(P+=1,Vr=$n=null,h.updateQueue!=null){var j=h.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}K.H=rI,j=p(_,w)}while(Df);return j}function mne(){var h=K.H,p=h.useState()[0];return p=typeof p.then=="function"?jg(p):p,h=h.useState()[0],($n!==null?$n.memoizedState:null)!==h&&(nn.flags|=1024),p}function a2(){var h=Ay!==0;return Ay=0,h}function s2(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function o2(h){if(Ey){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}Ey=!1}Dl=0,Vr=$n=nn=null,Df=!1,Dg=Ay=0,jf=null}function ba(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vr===null?nn.memoizedState=Vr=h:Vr=Vr.next=h,Vr}function Ir(){if($n===null){var h=nn.alternate;h=h!==null?h.memoizedState:null}else h=$n.next;var p=Vr===null?nn.memoizedState:Vr.next;if(p!==null)Vr=p,$n=h;else{if(h===null)throw nn.alternate===null?Error(r(467)):Error(r(310));$n=h,h={memoizedState:$n.memoizedState,baseState:$n.baseState,baseQueue:$n.baseQueue,queue:$n.queue,next:null},Vr===null?nn.memoizedState=Vr=h:Vr=Vr.next=h}return Vr}function Ty(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function jg(h){var p=Dg;return Dg+=1,jf===null&&(jf=[]),h=d4(jf,h,p),p=nn,(Vr===null?p.memoizedState:Vr.next)===null&&(p=p.alternate,K.H=p===null||p.memoizedState===null?nI:y2),h}function Cy(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return jg(h);if(h.$$typeof===S)return $i(h)}throw Error(r(438,String(h)))}function l2(h){var p=null,_=nn.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var w=nn.alternate;w!==null&&(w=w.updateQueue,w!==null&&(w=w.memoCache,w!=null&&(p={data:w.data.map(function(P){return P.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=Ty(),nn.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(h),w=0;w<h;w++)_[w]=D;return p.index++,_}function jl(h,p){return typeof p=="function"?p(h):p}function Ny(h){var p=Ir();return c2(p,$n,h)}function c2(h,p,_){var w=h.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=_;var P=h.baseQueue,j=w.pending;if(j!==null){if(P!==null){var Y=P.next;P.next=j.next,j.next=Y}p.baseQueue=P=j,w.pending=null}if(j=h.baseState,P===null)h.memoizedState=j;else{p=P.next;var le=Y=null,Ee=null,Xe=p,lt=!1;do{var dt=Xe.lane&-536870913;if(dt!==Xe.lane?(yn&dt)===dt:(Dl&dt)===dt){var Ze=Xe.revertLane;if(Ze===0)Ee!==null&&(Ee=Ee.next={lane:0,revertLane:0,gesture:null,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null}),dt===Cf&&(lt=!0);else if((Dl&Ze)===Ze){Xe=Xe.next,Ze===Cf&&(lt=!0);continue}else dt={lane:0,revertLane:Xe.revertLane,gesture:null,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},Ee===null?(le=Ee=dt,Y=j):Ee=Ee.next=dt,nn.lanes|=Ze,nu|=Ze;dt=Xe.action,Ud&&_(j,dt),j=Xe.hasEagerState?Xe.eagerState:_(j,dt)}else Ze={lane:dt,revertLane:Xe.revertLane,gesture:Xe.gesture,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},Ee===null?(le=Ee=Ze,Y=j):Ee=Ee.next=Ze,nn.lanes|=dt,nu|=dt;Xe=Xe.next}while(Xe!==null&&Xe!==p);if(Ee===null?Y=j:Ee.next=le,!ts(j,h.memoizedState)&&(Gr=!0,lt&&(_=Nf,_!==null)))throw _;h.memoizedState=j,h.baseState=Y,h.baseQueue=Ee,w.lastRenderedState=j}return P===null&&(w.lanes=0),[h.memoizedState,w.dispatch]}function u2(h){var p=Ir(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var w=_.dispatch,P=_.pending,j=p.memoizedState;if(P!==null){_.pending=null;var Y=P=P.next;do j=h(j,Y.action),Y=Y.next;while(Y!==P);ts(j,p.memoizedState)||(Gr=!0),p.memoizedState=j,p.baseQueue===null&&(p.baseState=j),_.lastRenderedState=j}return[j,w]}function w4(h,p,_){var w=nn,P=Ir(),j=wn;if(j){if(_===void 0)throw Error(r(407));_=_()}else _=p();var Y=!ts(($n||P).memoizedState,_);if(Y&&(P.memoizedState=_,Gr=!0),P=P.queue,f2(E4.bind(null,w,P,h),[h]),P.getSnapshot!==p||Y||Vr!==null&&Vr.memoizedState.tag&1){if(w.flags|=2048,Of(9,{destroy:void 0},M4.bind(null,w,P,_,p),null),Jn===null)throw Error(r(349));j||(Dl&127)!==0||S4(w,p,_)}return _}function S4(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=nn.updateQueue,p===null?(p=Ty(),nn.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function M4(h,p,_,w){p.value=_,p.getSnapshot=w,A4(p)&&T4(h)}function E4(h,p,_){return _(function(){A4(p)&&T4(h)})}function A4(h){var p=h.getSnapshot;h=h.value;try{var _=p();return!ts(h,_)}catch{return!0}}function T4(h){var p=kd(h,2);p!==null&&Ua(p,h,2)}function d2(h){var p=ba();if(typeof h=="function"){var _=h;if(h=_(),Ud){et(!0);try{_()}finally{et(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:jl,lastRenderedState:h},p}function C4(h,p,_,w){return h.baseState=_,c2(h,$n,typeof w=="function"?w:jl)}function gne(h,p,_,w,P){if(Ry(h))throw Error(r(485));if(h=p.action,h!==null){var j={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Y){j.listeners.push(Y)}};K.T!==null?_(!0):j.isTransition=!1,w(j),_=p.pending,_===null?(j.next=p.pending=j,N4(p,j)):(j.next=_.next,p.pending=_.next=j)}}function N4(h,p){var _=p.action,w=p.payload,P=h.state;if(p.isTransition){var j=K.T,Y={};K.T=Y;try{var le=_(P,w),Ee=K.S;Ee!==null&&Ee(Y,le),k4(h,p,le)}catch(Xe){h2(h,p,Xe)}finally{j!==null&&Y.types!==null&&(j.types=Y.types),K.T=j}}else try{j=_(P,w),k4(h,p,j)}catch(Xe){h2(h,p,Xe)}}function k4(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(w){P4(h,p,w)},function(w){return h2(h,p,w)}):P4(h,p,_)}function P4(h,p,_){p.status="fulfilled",p.value=_,R4(p),h.state=_,p=h.pending,p!==null&&(_=p.next,_===p?h.pending=null:(_=_.next,p.next=_,N4(h,_)))}function h2(h,p,_){var w=h.pending;if(h.pending=null,w!==null){w=w.next;do p.status="rejected",p.reason=_,R4(p),p=p.next;while(p!==w)}h.action=null}function R4(h){h=h.listeners;for(var p=0;p<h.length;p++)(0,h[p])()}function D4(h,p){return p}function j4(h,p){if(wn){var _=Jn.formState;if(_!==null){e:{var w=nn;if(wn){if(sr){t:{for(var P=sr,j=js;P.nodeType!==8;){if(!j){P=null;break t}if(P=Ls(P.nextSibling),P===null){P=null;break t}}j=P.data,P=j==="F!"||j==="F"?P:null}if(P){sr=Ls(P.nextSibling),w=P.data==="F!";break e}}qc(w)}w=!1}w&&(p=_[0])}}return _=ba(),_.memoizedState=_.baseState=p,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:D4,lastRenderedState:p},_.queue=w,_=J4.bind(null,nn,w),w.dispatch=_,w=d2(!1),j=b2.bind(null,nn,!1,w.queue),w=ba(),P={state:p,dispatch:null,action:h,pending:null},w.queue=P,_=gne.bind(null,nn,P,j,_),P.dispatch=_,w.memoizedState=h,[p,_,!1]}function O4(h){var p=Ir();return L4(p,$n,h)}function L4(h,p,_){if(p=c2(h,p,D4)[0],h=Ny(jl)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var w=jg(p)}catch(Y){throw Y===kf?yy:Y}else w=p;p=Ir();var P=p.queue,j=P.dispatch;return _!==p.memoizedState&&(nn.flags|=2048,Of(9,{destroy:void 0},xne.bind(null,P,_),null)),[w,j,h]}function xne(h,p){h.action=p}function I4(h){var p=Ir(),_=$n;if(_!==null)return L4(p,_,h);Ir(),p=p.memoizedState,_=Ir();var w=_.queue.dispatch;return _.memoizedState=h,[p,w,!1]}function Of(h,p,_,w){return h={tag:h,create:_,deps:w,inst:p,next:null},p=nn.updateQueue,p===null&&(p=Ty(),nn.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(w=_.next,_.next=h,h.next=w,p.lastEffect=h),h}function F4(){return Ir().memoizedState}function ky(h,p,_,w){var P=ba();nn.flags|=h,P.memoizedState=Of(1|p,{destroy:void 0},_,w===void 0?null:w)}function Py(h,p,_,w){var P=Ir();w=w===void 0?null:w;var j=P.memoizedState.inst;$n!==null&&w!==null&&r2(w,$n.memoizedState.deps)?P.memoizedState=Of(p,j,_,w):(nn.flags|=h,P.memoizedState=Of(1|p,j,_,w))}function U4(h,p){ky(8390656,8,h,p)}function f2(h,p){Py(2048,8,h,p)}function bne(h){nn.flags|=4;var p=nn.updateQueue;if(p===null)p=Ty(),nn.updateQueue=p,p.events=[h];else{var _=p.events;_===null?p.events=[h]:_.push(h)}}function z4(h){var p=Ir().memoizedState;return bne({ref:p,nextImpl:h}),function(){if((kn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function B4(h,p){return Py(4,2,h,p)}function H4(h,p){return Py(4,4,h,p)}function $4(h,p){if(typeof p=="function"){h=h();var _=p(h);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return h=h(),p.current=h,function(){p.current=null}}function V4(h,p,_){_=_!=null?_.concat([h]):null,Py(4,4,$4.bind(null,p,h),_)}function p2(){}function G4(h,p){var _=Ir();p=p===void 0?null:p;var w=_.memoizedState;return p!==null&&r2(p,w[1])?w[0]:(_.memoizedState=[h,p],h)}function W4(h,p){var _=Ir();p=p===void 0?null:p;var w=_.memoizedState;if(p!==null&&r2(p,w[1]))return w[0];if(w=h(),Ud){et(!0);try{h()}finally{et(!1)}}return _.memoizedState=[w,p],w}function m2(h,p,_){return _===void 0||(Dl&1073741824)!==0&&(yn&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=qI(),nn.lanes|=h,nu|=h,_)}function q4(h,p,_,w){return ts(_,p)?_:Rf.current!==null?(h=m2(h,_,w),ts(h,p)||(Gr=!0),h):(Dl&42)===0||(Dl&1073741824)!==0&&(yn&261930)===0?(Gr=!0,h.memoizedState=_):(h=qI(),nn.lanes|=h,nu|=h,p)}function K4(h,p,_,w,P){var j=G.p;G.p=j!==0&&8>j?j:8;var Y=K.T,le={};K.T=le,b2(h,!1,p,_);try{var Ee=P(),Xe=K.S;if(Xe!==null&&Xe(le,Ee),Ee!==null&&typeof Ee=="object"&&typeof Ee.then=="function"){var lt=fne(Ee,w);Og(h,p,lt,ls(h))}else Og(h,p,w,ls(h))}catch(dt){Og(h,p,{then:function(){},status:"rejected",reason:dt},ls())}finally{G.p=j,Y!==null&&le.types!==null&&(Y.types=le.types),K.T=Y}}function yne(){}function g2(h,p,_,w){if(h.tag!==5)throw Error(r(476));var P=X4(h).queue;K4(h,P,p,ee,_===null?yne:function(){return Y4(h),_(w)})}function X4(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:ee,baseState:ee,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jl,lastRenderedState:ee},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jl,lastRenderedState:_},next:null},h.memoizedState=p,h=h.alternate,h!==null&&(h.memoizedState=p),p}function Y4(h){var p=X4(h);p.next===null&&(p=h.alternate.memoizedState),Og(h,p.next.queue,{},ls())}function x2(){return $i(Qg)}function Z4(){return Ir().memoizedState}function Q4(){return Ir().memoizedState}function vne(h){for(var p=h.return;p!==null;){switch(p.tag){case 24:case 3:var _=ls();h=Yc(_);var w=Zc(p,h,_);w!==null&&(Ua(w,p,_),kg(w,p,_)),p={cache:WE()},h.payload=p;return}p=p.return}}function _ne(h,p,_){var w=ls();_={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Ry(h)?eI(p,_):(_=OE(h,p,_,w),_!==null&&(Ua(_,h,w),tI(_,p,w)))}function J4(h,p,_){var w=ls();Og(h,p,_,w)}function Og(h,p,_,w){var P={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Ry(h))eI(p,P);else{var j=h.alternate;if(h.lanes===0&&(j===null||j.lanes===0)&&(j=p.lastRenderedReducer,j!==null))try{var Y=p.lastRenderedState,le=j(Y,_);if(P.hasEagerState=!0,P.eagerState=le,ts(le,Y))return hy(h,p,P,0),Jn===null&&dy(),!1}catch{}finally{}if(_=OE(h,p,P,w),_!==null)return Ua(_,h,w),tI(_,p,w),!0}return!1}function b2(h,p,_,w){if(w={lane:2,revertLane:Y2(),gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Ry(h)){if(p)throw Error(r(479))}else p=OE(h,_,w,2),p!==null&&Ua(p,h,2)}function Ry(h){var p=h.alternate;return h===nn||p!==null&&p===nn}function eI(h,p){Df=Ey=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function tI(h,p,_){if((_&4194048)!==0){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,On(h,_)}}var Lg={readContext:$i,use:Cy,useCallback:Tr,useContext:Tr,useEffect:Tr,useImperativeHandle:Tr,useLayoutEffect:Tr,useInsertionEffect:Tr,useMemo:Tr,useReducer:Tr,useRef:Tr,useState:Tr,useDebugValue:Tr,useDeferredValue:Tr,useTransition:Tr,useSyncExternalStore:Tr,useId:Tr,useHostTransitionStatus:Tr,useFormState:Tr,useActionState:Tr,useOptimistic:Tr,useMemoCache:Tr,useCacheRefresh:Tr};Lg.useEffectEvent=Tr;var nI={readContext:$i,use:Cy,useCallback:function(h,p){return ba().memoizedState=[h,p===void 0?null:p],h},useContext:$i,useEffect:U4,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,ky(4194308,4,$4.bind(null,p,h),_)},useLayoutEffect:function(h,p){return ky(4194308,4,h,p)},useInsertionEffect:function(h,p){ky(4,2,h,p)},useMemo:function(h,p){var _=ba();p=p===void 0?null:p;var w=h();if(Ud){et(!0);try{h()}finally{et(!1)}}return _.memoizedState=[w,p],w},useReducer:function(h,p,_){var w=ba();if(_!==void 0){var P=_(p);if(Ud){et(!0);try{_(p)}finally{et(!1)}}}else P=p;return w.memoizedState=w.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},w.queue=h,h=h.dispatch=_ne.bind(null,nn,h),[w.memoizedState,h]},useRef:function(h){var p=ba();return h={current:h},p.memoizedState=h},useState:function(h){h=d2(h);var p=h.queue,_=J4.bind(null,nn,p);return p.dispatch=_,[h.memoizedState,_]},useDebugValue:p2,useDeferredValue:function(h,p){var _=ba();return m2(_,h,p)},useTransition:function(){var h=d2(!1);return h=K4.bind(null,nn,h.queue,!0,!1),ba().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var w=nn,P=ba();if(wn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Jn===null)throw Error(r(349));(yn&127)!==0||S4(w,p,_)}P.memoizedState=_;var j={value:_,getSnapshot:p};return P.queue=j,U4(E4.bind(null,w,j,h),[h]),w.flags|=2048,Of(9,{destroy:void 0},M4.bind(null,w,j,_,p),null),_},useId:function(){var h=ba(),p=Jn.identifierPrefix;if(wn){var _=Wo,w=Go;_=(w&~(1<<32-He(w)-1)).toString(32)+_,p="_"+p+"R_"+_,_=Ay++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=pne++,p="_"+p+"r_"+_.toString(32)+"_";return h.memoizedState=p},useHostTransitionStatus:x2,useFormState:j4,useActionState:j4,useOptimistic:function(h){var p=ba();p.memoizedState=p.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=b2.bind(null,nn,!0,_),_.dispatch=p,[h,p]},useMemoCache:l2,useCacheRefresh:function(){return ba().memoizedState=vne.bind(null,nn)},useEffectEvent:function(h){var p=ba(),_={impl:h};return p.memoizedState=_,function(){if((kn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},y2={readContext:$i,use:Cy,useCallback:G4,useContext:$i,useEffect:f2,useImperativeHandle:V4,useInsertionEffect:B4,useLayoutEffect:H4,useMemo:W4,useReducer:Ny,useRef:F4,useState:function(){return Ny(jl)},useDebugValue:p2,useDeferredValue:function(h,p){var _=Ir();return q4(_,$n.memoizedState,h,p)},useTransition:function(){var h=Ny(jl)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:jg(h),p]},useSyncExternalStore:w4,useId:Z4,useHostTransitionStatus:x2,useFormState:O4,useActionState:O4,useOptimistic:function(h,p){var _=Ir();return C4(_,$n,h,p)},useMemoCache:l2,useCacheRefresh:Q4};y2.useEffectEvent=z4;var rI={readContext:$i,use:Cy,useCallback:G4,useContext:$i,useEffect:f2,useImperativeHandle:V4,useInsertionEffect:B4,useLayoutEffect:H4,useMemo:W4,useReducer:u2,useRef:F4,useState:function(){return u2(jl)},useDebugValue:p2,useDeferredValue:function(h,p){var _=Ir();return $n===null?m2(_,h,p):q4(_,$n.memoizedState,h,p)},useTransition:function(){var h=u2(jl)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:jg(h),p]},useSyncExternalStore:w4,useId:Z4,useHostTransitionStatus:x2,useFormState:I4,useActionState:I4,useOptimistic:function(h,p){var _=Ir();return $n!==null?C4(_,$n,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:l2,useCacheRefresh:Q4};rI.useEffectEvent=z4;function v2(h,p,_,w){p=h.memoizedState,_=_(w,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var _2={enqueueSetState:function(h,p,_){h=h._reactInternals;var w=ls(),P=Yc(w);P.payload=p,_!=null&&(P.callback=_),p=Zc(h,P,w),p!==null&&(Ua(p,h,w),kg(p,h,w))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var w=ls(),P=Yc(w);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=Zc(h,P,w),p!==null&&(Ua(p,h,w),kg(p,h,w))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=ls(),w=Yc(_);w.tag=2,p!=null&&(w.callback=p),p=Zc(h,w,_),p!==null&&(Ua(p,h,_),kg(p,h,_))}};function iI(h,p,_,w,P,j,Y){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(w,j,Y):p.prototype&&p.prototype.isPureReactComponent?!wg(_,w)||!wg(P,j):!0}function aI(h,p,_,w){h=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,w),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,w),p.state!==h&&_2.enqueueReplaceState(p,p.state,null)}function zd(h,p){var _=p;if("ref"in p){_={};for(var w in p)w!=="ref"&&(_[w]=p[w])}if(h=h.defaultProps){_===p&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function sI(h){uy(h)}function oI(h){console.error(h)}function lI(h){uy(h)}function Dy(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(w){setTimeout(function(){throw w})}}function cI(h,p,_){try{var w=h.onCaughtError;w(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function w2(h,p,_){return _=Yc(_),_.tag=3,_.payload={element:null},_.callback=function(){Dy(h,p)},_}function uI(h){return h=Yc(h),h.tag=3,h}function dI(h,p,_,w){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var j=w.value;h.payload=function(){return P(j)},h.callback=function(){cI(p,_,w)}}var Y=_.stateNode;Y!==null&&typeof Y.componentDidCatch=="function"&&(h.callback=function(){cI(p,_,w),typeof P!="function"&&(ru===null?ru=new Set([this]):ru.add(this));var le=w.stack;this.componentDidCatch(w.value,{componentStack:le!==null?le:""})})}function wne(h,p,_,w,P){if(_.flags|=32768,w!==null&&typeof w=="object"&&typeof w.then=="function"){if(p=_.alternate,p!==null&&Tf(p,_,P,!0),_=rs.current,_!==null){switch(_.tag){case 31:case 13:return Os===null?Gy():_.alternate===null&&Cr===0&&(Cr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,w===vy?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([w]):p.add(w),q2(h,w,P)),!1;case 22:return _.flags|=65536,w===vy?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([w])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([w]):_.add(w)),q2(h,w,P)),!1}throw Error(r(435,_.tag))}return q2(h,w,P),Gy(),!1}if(wn)return p=rs.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,w!==BE&&(h=Error(r(422),{cause:w}),Eg(Ps(h,_)))):(w!==BE&&(p=Error(r(423),{cause:w}),Eg(Ps(p,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,w=Ps(w,_),P=w2(h.stateNode,w,P),QE(h,P),Cr!==4&&(Cr=2)),!1;var j=Error(r(520),{cause:w});if(j=Ps(j,_),Vg===null?Vg=[j]:Vg.push(j),Cr!==4&&(Cr=2),p===null)return!0;w=Ps(w,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=w2(_.stateNode,w,h),QE(_,h),!1;case 1:if(p=_.type,j=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(ru===null||!ru.has(j))))return _.flags|=65536,P&=-P,_.lanes|=P,P=uI(P),dI(P,h,_,w),QE(_,P),!1}_=_.return}while(_!==null);return!1}var S2=Error(r(461)),Gr=!1;function Vi(h,p,_,w){p.child=h===null?m4(p,null,_,w):Fd(p,h.child,_,w)}function hI(h,p,_,w,P){_=_.render;var j=p.ref;if("ref"in w){var Y={};for(var le in w)le!=="ref"&&(Y[le]=w[le])}else Y=w;return jd(p),w=i2(h,p,_,Y,j,P),le=a2(),h!==null&&!Gr?(s2(h,p,P),Ol(h,p,P)):(wn&&le&&UE(p),p.flags|=1,Vi(h,p,w,P),p.child)}function fI(h,p,_,w,P){if(h===null){var j=_.type;return typeof j=="function"&&!LE(j)&&j.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=j,pI(h,p,j,w,P)):(h=py(_.type,null,w,p,p.mode,P),h.ref=p.ref,h.return=p,p.child=h)}if(j=h.child,!P2(h,P)){var Y=j.memoizedProps;if(_=_.compare,_=_!==null?_:wg,_(Y,w)&&h.ref===p.ref)return Ol(h,p,P)}return p.flags|=1,h=Nl(j,w),h.ref=p.ref,h.return=p,p.child=h}function pI(h,p,_,w,P){if(h!==null){var j=h.memoizedProps;if(wg(j,w)&&h.ref===p.ref)if(Gr=!1,p.pendingProps=w=j,P2(h,P))(h.flags&131072)!==0&&(Gr=!0);else return p.lanes=h.lanes,Ol(h,p,P)}return M2(h,p,_,w,P)}function mI(h,p,_,w){var P=w.children,j=h!==null?h.memoizedState:null;if(h===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),w.mode==="hidden"){if((p.flags&128)!==0){if(j=j!==null?j.baseLanes|_:_,h!==null){for(w=p.child=h.child,P=0;w!==null;)P=P|w.lanes|w.childLanes,w=w.sibling;w=P&~j}else w=0,p.child=null;return gI(h,p,j,_,w)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&by(p,j!==null?j.cachePool:null),j!==null?b4(p,j):e2(),y4(p);else return w=p.lanes=536870912,gI(h,p,j!==null?j.baseLanes|_:_,_,w)}else j!==null?(by(p,j.cachePool),b4(p,j),Jc(),p.memoizedState=null):(h!==null&&by(p,null),e2(),Jc());return Vi(h,p,P,_),p.child}function Ig(h,p){return h!==null&&h.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function gI(h,p,_,w,P){var j=KE();return j=j===null?null:{parent:$r._currentValue,pool:j},p.memoizedState={baseLanes:_,cachePool:j},h!==null&&by(p,null),e2(),y4(p),h!==null&&Tf(h,p,w,!0),p.childLanes=P,null}function jy(h,p){return p=Ly({mode:p.mode,children:p.children},h.mode),p.ref=h.ref,h.child=p,p.return=h,p}function xI(h,p,_){return Fd(p,h.child,null,_),h=jy(p,p.pendingProps),h.flags|=2,is(p),p.memoizedState=null,h}function Sne(h,p,_){var w=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(wn){if(w.mode==="hidden")return h=jy(p,w),p.lanes=536870912,Ig(null,h);if(n2(p),(h=sr)?(h=N5(h,js),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Gc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=e4(h),_.return=p,p.child=_,Hi=p,sr=null)):h=null,h===null)throw qc(p);return p.lanes=536870912,null}return jy(p,w)}var j=h.memoizedState;if(j!==null){var Y=j.dehydrated;if(n2(p),P)if(p.flags&256)p.flags&=-257,p=xI(h,p,_);else if(p.memoizedState!==null)p.child=h.child,p.flags|=128,p=null;else throw Error(r(558));else if(Gr||Tf(h,p,_,!1),P=(_&h.childLanes)!==0,Gr||P){if(w=Jn,w!==null&&(Y=Mi(w,_),Y!==0&&Y!==j.retryLane))throw j.retryLane=Y,kd(h,Y),Ua(w,h,Y),S2;Gy(),p=xI(h,p,_)}else h=j.treeContext,sr=Ls(Y.nextSibling),Hi=p,wn=!0,Wc=null,js=!1,h!==null&&r4(p,h),p=jy(p,w),p.flags|=4096;return p}return h=Nl(h.child,{mode:w.mode,children:w.children}),h.ref=p.ref,p.child=h,h.return=p,h}function Oy(h,p){var _=p.ref;if(_===null)h!==null&&h.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(p.flags|=4194816)}}function M2(h,p,_,w,P){return jd(p),_=i2(h,p,_,w,void 0,P),w=a2(),h!==null&&!Gr?(s2(h,p,P),Ol(h,p,P)):(wn&&w&&UE(p),p.flags|=1,Vi(h,p,_,P),p.child)}function bI(h,p,_,w,P,j){return jd(p),p.updateQueue=null,_=_4(p,w,_,P),v4(h),w=a2(),h!==null&&!Gr?(s2(h,p,j),Ol(h,p,j)):(wn&&w&&UE(p),p.flags|=1,Vi(h,p,_,j),p.child)}function yI(h,p,_,w,P){if(jd(p),p.stateNode===null){var j=Sf,Y=_.contextType;typeof Y=="object"&&Y!==null&&(j=$i(Y)),j=new _(w,j),p.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=_2,p.stateNode=j,j._reactInternals=p,j=p.stateNode,j.props=w,j.state=p.memoizedState,j.refs={},YE(p),Y=_.contextType,j.context=typeof Y=="object"&&Y!==null?$i(Y):Sf,j.state=p.memoizedState,Y=_.getDerivedStateFromProps,typeof Y=="function"&&(v2(p,_,Y,w),j.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(Y=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),Y!==j.state&&_2.enqueueReplaceState(j,j.state,null),Rg(p,w,j,P),Pg(),j.state=p.memoizedState),typeof j.componentDidMount=="function"&&(p.flags|=4194308),w=!0}else if(h===null){j=p.stateNode;var le=p.memoizedProps,Ee=zd(_,le);j.props=Ee;var Xe=j.context,lt=_.contextType;Y=Sf,typeof lt=="object"&&lt!==null&&(Y=$i(lt));var dt=_.getDerivedStateFromProps;lt=typeof dt=="function"||typeof j.getSnapshotBeforeUpdate=="function",le=p.pendingProps!==le,lt||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(le||Xe!==Y)&&aI(p,j,w,Y),Xc=!1;var Ze=p.memoizedState;j.state=Ze,Rg(p,w,j,P),Pg(),Xe=p.memoizedState,le||Ze!==Xe||Xc?(typeof dt=="function"&&(v2(p,_,dt,w),Xe=p.memoizedState),(Ee=Xc||iI(p,_,Ee,w,Ze,Xe,Y))?(lt||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(p.flags|=4194308)):(typeof j.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=w,p.memoizedState=Xe),j.props=w,j.state=Xe,j.context=Y,w=Ee):(typeof j.componentDidMount=="function"&&(p.flags|=4194308),w=!1)}else{j=p.stateNode,ZE(h,p),Y=p.memoizedProps,lt=zd(_,Y),j.props=lt,dt=p.pendingProps,Ze=j.context,Xe=_.contextType,Ee=Sf,typeof Xe=="object"&&Xe!==null&&(Ee=$i(Xe)),le=_.getDerivedStateFromProps,(Xe=typeof le=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(Y!==dt||Ze!==Ee)&&aI(p,j,w,Ee),Xc=!1,Ze=p.memoizedState,j.state=Ze,Rg(p,w,j,P),Pg();var at=p.memoizedState;Y!==dt||Ze!==at||Xc||h!==null&&h.dependencies!==null&&gy(h.dependencies)?(typeof le=="function"&&(v2(p,_,le,w),at=p.memoizedState),(lt=Xc||iI(p,_,lt,w,Ze,at,Ee)||h!==null&&h.dependencies!==null&&gy(h.dependencies))?(Xe||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(w,at,Ee),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(w,at,Ee)),typeof j.componentDidUpdate=="function"&&(p.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof j.componentDidUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=1024),p.memoizedProps=w,p.memoizedState=at),j.props=w,j.state=at,j.context=Ee,w=lt):(typeof j.componentDidUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||Y===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=1024),w=!1)}return j=w,Oy(h,p),w=(p.flags&128)!==0,j||w?(j=p.stateNode,_=w&&typeof _.getDerivedStateFromError!="function"?null:j.render(),p.flags|=1,h!==null&&w?(p.child=Fd(p,h.child,null,P),p.child=Fd(p,null,_,P)):Vi(h,p,_,P),p.memoizedState=j.state,h=p.child):h=Ol(h,p,P),h}function vI(h,p,_,w){return Rd(),p.flags|=256,Vi(h,p,_,w),p.child}var E2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function A2(h){return{baseLanes:h,cachePool:c4()}}function T2(h,p,_){return h=h!==null?h.childLanes&~_:0,p&&(h|=ss),h}function _I(h,p,_){var w=p.pendingProps,P=!1,j=(p.flags&128)!==0,Y;if((Y=j)||(Y=h!==null&&h.memoizedState===null?!1:(Lr.current&2)!==0),Y&&(P=!0,p.flags&=-129),Y=(p.flags&32)!==0,p.flags&=-33,h===null){if(wn){if(P?Qc(p):Jc(),(h=sr)?(h=N5(h,js),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Gc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=e4(h),_.return=p,p.child=_,Hi=p,sr=null)):h=null,h===null)throw qc(p);return cA(h)?p.lanes=32:p.lanes=536870912,null}var le=w.children;return w=w.fallback,P?(Jc(),P=p.mode,le=Ly({mode:"hidden",children:le},P),w=Pd(w,P,_,null),le.return=p,w.return=p,le.sibling=w,p.child=le,w=p.child,w.memoizedState=A2(_),w.childLanes=T2(h,Y,_),p.memoizedState=E2,Ig(null,w)):(Qc(p),C2(p,le))}var Ee=h.memoizedState;if(Ee!==null&&(le=Ee.dehydrated,le!==null)){if(j)p.flags&256?(Qc(p),p.flags&=-257,p=N2(h,p,_)):p.memoizedState!==null?(Jc(),p.child=h.child,p.flags|=128,p=null):(Jc(),le=w.fallback,P=p.mode,w=Ly({mode:"visible",children:w.children},P),le=Pd(le,P,_,null),le.flags|=2,w.return=p,le.return=p,w.sibling=le,p.child=w,Fd(p,h.child,null,_),w=p.child,w.memoizedState=A2(_),w.childLanes=T2(h,Y,_),p.memoizedState=E2,p=Ig(null,w));else if(Qc(p),cA(le)){if(Y=le.nextSibling&&le.nextSibling.dataset,Y)var Xe=Y.dgst;Y=Xe,w=Error(r(419)),w.stack="",w.digest=Y,Eg({value:w,source:null,stack:null}),p=N2(h,p,_)}else if(Gr||Tf(h,p,_,!1),Y=(_&h.childLanes)!==0,Gr||Y){if(Y=Jn,Y!==null&&(w=Mi(Y,_),w!==0&&w!==Ee.retryLane))throw Ee.retryLane=w,kd(h,w),Ua(Y,h,w),S2;lA(le)||Gy(),p=N2(h,p,_)}else lA(le)?(p.flags|=192,p.child=h.child,p=null):(h=Ee.treeContext,sr=Ls(le.nextSibling),Hi=p,wn=!0,Wc=null,js=!1,h!==null&&r4(p,h),p=C2(p,w.children),p.flags|=4096);return p}return P?(Jc(),le=w.fallback,P=p.mode,Ee=h.child,Xe=Ee.sibling,w=Nl(Ee,{mode:"hidden",children:w.children}),w.subtreeFlags=Ee.subtreeFlags&65011712,Xe!==null?le=Nl(Xe,le):(le=Pd(le,P,_,null),le.flags|=2),le.return=p,w.return=p,w.sibling=le,p.child=w,Ig(null,w),w=p.child,le=h.child.memoizedState,le===null?le=A2(_):(P=le.cachePool,P!==null?(Ee=$r._currentValue,P=P.parent!==Ee?{parent:Ee,pool:Ee}:P):P=c4(),le={baseLanes:le.baseLanes|_,cachePool:P}),w.memoizedState=le,w.childLanes=T2(h,Y,_),p.memoizedState=E2,Ig(h.child,w)):(Qc(p),_=h.child,h=_.sibling,_=Nl(_,{mode:"visible",children:w.children}),_.return=p,_.sibling=null,h!==null&&(Y=p.deletions,Y===null?(p.deletions=[h],p.flags|=16):Y.push(h)),p.child=_,p.memoizedState=null,_)}function C2(h,p){return p=Ly({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function Ly(h,p){return h=ns(22,h,null,p),h.lanes=0,h}function N2(h,p,_){return Fd(p,h.child,null,_),h=C2(p,p.pendingProps.children),h.flags|=2,p.memoizedState=null,h}function wI(h,p,_){h.lanes|=p;var w=h.alternate;w!==null&&(w.lanes|=p),VE(h.return,p,_)}function k2(h,p,_,w,P,j){var Y=h.memoizedState;Y===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:w,tail:_,tailMode:P,treeForkCount:j}:(Y.isBackwards=p,Y.rendering=null,Y.renderingStartTime=0,Y.last=w,Y.tail=_,Y.tailMode=P,Y.treeForkCount=j)}function SI(h,p,_){var w=p.pendingProps,P=w.revealOrder,j=w.tail;w=w.children;var Y=Lr.current,le=(Y&2)!==0;if(le?(Y=Y&1|2,p.flags|=128):Y&=1,X(Lr,Y),Vi(h,p,w,_),w=wn?Mg:0,!le&&h!==null&&(h.flags&128)!==0)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&wI(h,_,p);else if(h.tag===19)wI(h,_,p);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===p)break e;for(;h.sibling===null;){if(h.return===null||h.return===p)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=p.child,P=null;_!==null;)h=_.alternate,h!==null&&My(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),k2(p,!1,P,_,j,w);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(h=P.alternate,h!==null&&My(h)===null){p.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}k2(p,!0,_,null,j,w);break;case"together":k2(p,!1,null,null,void 0,w);break;default:p.memoizedState=null}return p.child}function Ol(h,p,_){if(h!==null&&(p.dependencies=h.dependencies),nu|=p.lanes,(_&p.childLanes)===0)if(h!==null){if(Tf(h,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(h!==null&&p.child!==h.child)throw Error(r(153));if(p.child!==null){for(h=p.child,_=Nl(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=Nl(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function P2(h,p){return(h.lanes&p)!==0?!0:(h=h.dependencies,!!(h!==null&&gy(h)))}function Mne(h,p,_){switch(p.tag){case 3:Ne(p,p.stateNode.containerInfo),Kc(p,$r,h.memoizedState.cache),Rd();break;case 27:case 5:xe(p);break;case 4:Ne(p,p.stateNode.containerInfo);break;case 10:Kc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,n2(p),null;break;case 13:var w=p.memoizedState;if(w!==null)return w.dehydrated!==null?(Qc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?_I(h,p,_):(Qc(p),h=Ol(h,p,_),h!==null?h.sibling:null);Qc(p);break;case 19:var P=(h.flags&128)!==0;if(w=(_&p.childLanes)!==0,w||(Tf(h,p,_,!1),w=(_&p.childLanes)!==0),P){if(w)return SI(h,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),X(Lr,Lr.current),w)break;return null;case 22:return p.lanes=0,mI(h,p,_,p.pendingProps);case 24:Kc(p,$r,h.memoizedState.cache)}return Ol(h,p,_)}function MI(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps)Gr=!0;else{if(!P2(h,_)&&(p.flags&128)===0)return Gr=!1,Mne(h,p,_);Gr=(h.flags&131072)!==0}else Gr=!1,wn&&(p.flags&1048576)!==0&&n4(p,Mg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var w=p.pendingProps;if(h=Ld(p.elementType),p.type=h,typeof h=="function")LE(h)?(w=zd(h,w),p.tag=1,p=yI(null,p,h,w,_)):(p.tag=0,p=M2(null,p,h,w,_));else{if(h!=null){var P=h.$$typeof;if(P===A){p.tag=11,p=hI(null,p,h,w,_);break e}else if(P===N){p.tag=14,p=fI(null,p,h,w,_);break e}}throw p=R(h)||h,Error(r(306,p,""))}}return p;case 0:return M2(h,p,p.type,p.pendingProps,_);case 1:return w=p.type,P=zd(w,p.pendingProps),yI(h,p,w,P,_);case 3:e:{if(Ne(p,p.stateNode.containerInfo),h===null)throw Error(r(387));w=p.pendingProps;var j=p.memoizedState;P=j.element,ZE(h,p),Rg(p,w,null,_);var Y=p.memoizedState;if(w=Y.cache,Kc(p,$r,w),w!==j.cache&&GE(p,[$r],_,!0),Pg(),w=Y.element,j.isDehydrated)if(j={element:w,isDehydrated:!1,cache:Y.cache},p.updateQueue.baseState=j,p.memoizedState=j,p.flags&256){p=vI(h,p,w,_);break e}else if(w!==P){P=Ps(Error(r(424)),p),Eg(P),p=vI(h,p,w,_);break e}else{switch(h=p.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(sr=Ls(h.firstChild),Hi=p,wn=!0,Wc=null,js=!0,_=m4(p,null,w,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Rd(),w===P){p=Ol(h,p,_);break e}Vi(h,p,w,_)}p=p.child}return p;case 26:return Oy(h,p),h===null?(_=O5(p.type,null,p.pendingProps,null))?p.memoizedState=_:wn||(_=p.type,h=p.pendingProps,w=Qy(pe.current).createElement(_),w[br]=p,w[jr]=h,Gi(w,_,h),Oe(w),p.stateNode=w):p.memoizedState=O5(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return xe(p),h===null&&wn&&(w=p.stateNode=R5(p.type,p.pendingProps,pe.current),Hi=p,js=!0,P=sr,ou(p.type)?(uA=P,sr=Ls(w.firstChild)):sr=P),Vi(h,p,p.pendingProps.children,_),Oy(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&wn&&((P=w=sr)&&(w=ere(w,p.type,p.pendingProps,js),w!==null?(p.stateNode=w,Hi=p,sr=Ls(w.firstChild),js=!1,P=!0):P=!1),P||qc(p)),xe(p),P=p.type,j=p.pendingProps,Y=h!==null?h.memoizedProps:null,w=j.children,aA(P,j)?w=null:Y!==null&&aA(P,Y)&&(p.flags|=32),p.memoizedState!==null&&(P=i2(h,p,mne,null,null,_),Qg._currentValue=P),Oy(h,p),Vi(h,p,w,_),p.child;case 6:return h===null&&wn&&((h=_=sr)&&(_=tre(_,p.pendingProps,js),_!==null?(p.stateNode=_,Hi=p,sr=null,h=!0):h=!1),h||qc(p)),null;case 13:return _I(h,p,_);case 4:return Ne(p,p.stateNode.containerInfo),w=p.pendingProps,h===null?p.child=Fd(p,null,w,_):Vi(h,p,w,_),p.child;case 11:return hI(h,p,p.type,p.pendingProps,_);case 7:return Vi(h,p,p.pendingProps,_),p.child;case 8:return Vi(h,p,p.pendingProps.children,_),p.child;case 12:return Vi(h,p,p.pendingProps.children,_),p.child;case 10:return w=p.pendingProps,Kc(p,p.type,w.value),Vi(h,p,w.children,_),p.child;case 9:return P=p.type._context,w=p.pendingProps.children,jd(p),P=$i(P),w=w(P),p.flags|=1,Vi(h,p,w,_),p.child;case 14:return fI(h,p,p.type,p.pendingProps,_);case 15:return pI(h,p,p.type,p.pendingProps,_);case 19:return SI(h,p,_);case 31:return Sne(h,p,_);case 22:return mI(h,p,_,p.pendingProps);case 24:return jd(p),w=$i($r),h===null?(P=KE(),P===null&&(P=Jn,j=WE(),P.pooledCache=j,j.refCount++,j!==null&&(P.pooledCacheLanes|=_),P=j),p.memoizedState={parent:w,cache:P},YE(p),Kc(p,$r,P)):((h.lanes&_)!==0&&(ZE(h,p),Rg(p,null,null,_),Pg()),P=h.memoizedState,j=p.memoizedState,P.parent!==w?(P={parent:w,cache:w},p.memoizedState=P,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=P),Kc(p,$r,w)):(w=j.cache,Kc(p,$r,w),w!==P.cache&&GE(p,[$r],_,!0))),Vi(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function Ll(h){h.flags|=4}function R2(h,p,_,w,P){if((p=(h.mode&32)!==0)&&(p=!1),p){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(ZI())h.flags|=8192;else throw Id=vy,XE}else h.flags&=-16777217}function EI(h,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!z5(p))if(ZI())h.flags|=8192;else throw Id=vy,XE}function Iy(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?xt():536870912,h.lanes|=p,Uf|=p)}function Fg(h,p){if(!wn)switch(h.tailMode){case"hidden":p=h.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var w=null;_!==null;)_.alternate!==null&&(w=_),_=_.sibling;w===null?p||h.tail===null?h.tail=null:h.tail.sibling=null:w.sibling=null}}function or(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,w=0;if(p)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,w|=P.subtreeFlags&65011712,w|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,w|=P.subtreeFlags,w|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=w,h.childLanes=_,p}function Ene(h,p,_){var w=p.pendingProps;switch(zE(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return or(p),null;case 1:return or(p),null;case 3:return _=p.stateNode,w=null,h!==null&&(w=h.memoizedState.cache),p.memoizedState.cache!==w&&(p.flags|=2048),Rl($r),ie(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Af(p)?Ll(p):h===null||h.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,HE())),or(p),null;case 26:var P=p.type,j=p.memoizedState;return h===null?(Ll(p),j!==null?(or(p),EI(p,j)):(or(p),R2(p,P,null,w,_))):j?j!==h.memoizedState?(Ll(p),or(p),EI(p,j)):(or(p),p.flags&=-16777217):(h=h.memoizedProps,h!==w&&Ll(p),or(p),R2(p,P,h,w,_)),null;case 27:if(Re(p),_=pe.current,P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}h=te.current,Af(p)?i4(p):(h=R5(P,w,_),p.stateNode=h,Ll(p))}return or(p),null;case 5:if(Re(p),P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}if(j=te.current,Af(p))i4(p);else{var Y=Qy(pe.current);switch(j){case 1:j=Y.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:j=Y.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":j=Y.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":j=Y.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":j=Y.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof w.is=="string"?Y.createElement("select",{is:w.is}):Y.createElement("select"),w.multiple?j.multiple=!0:w.size&&(j.size=w.size);break;default:j=typeof w.is=="string"?Y.createElement(P,{is:w.is}):Y.createElement(P)}}j[br]=p,j[jr]=w;e:for(Y=p.child;Y!==null;){if(Y.tag===5||Y.tag===6)j.appendChild(Y.stateNode);else if(Y.tag!==4&&Y.tag!==27&&Y.child!==null){Y.child.return=Y,Y=Y.child;continue}if(Y===p)break e;for(;Y.sibling===null;){if(Y.return===null||Y.return===p)break e;Y=Y.return}Y.sibling.return=Y.return,Y=Y.sibling}p.stateNode=j;e:switch(Gi(j,P,w),P){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}w&&Ll(p)}}return or(p),R2(p,p.type,h===null?null:h.memoizedProps,p.pendingProps,_),null;case 6:if(h&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(typeof w!="string"&&p.stateNode===null)throw Error(r(166));if(h=pe.current,Af(p)){if(h=p.stateNode,_=p.memoizedProps,w=null,P=Hi,P!==null)switch(P.tag){case 27:case 5:w=P.memoizedProps}h[br]=p,h=!!(h.nodeValue===_||w!==null&&w.suppressHydrationWarning===!0||_5(h.nodeValue,_)),h||qc(p,!0)}else h=Qy(h).createTextNode(w),h[br]=p,p.stateNode=h}return or(p),null;case 31:if(_=p.memoizedState,h===null||h.memoizedState!==null){if(w=Af(p),_!==null){if(h===null){if(!w)throw Error(r(318));if(h=p.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[br]=p}else Rd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),h=!1}else _=HE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return p.flags&256?(is(p),p):(is(p),null);if((p.flags&128)!==0)throw Error(r(558))}return or(p),null;case 13:if(w=p.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Af(p),w!==null&&w.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=p.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[br]=p}else Rd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),P=!1}else P=HE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return p.flags&256?(is(p),p):(is(p),null)}return is(p),(p.flags&128)!==0?(p.lanes=_,p):(_=w!==null,h=h!==null&&h.memoizedState!==null,_&&(w=p.child,P=null,w.alternate!==null&&w.alternate.memoizedState!==null&&w.alternate.memoizedState.cachePool!==null&&(P=w.alternate.memoizedState.cachePool.pool),j=null,w.memoizedState!==null&&w.memoizedState.cachePool!==null&&(j=w.memoizedState.cachePool.pool),j!==P&&(w.flags|=2048)),_!==h&&_&&(p.child.flags|=8192),Iy(p,p.updateQueue),or(p),null);case 4:return ie(),h===null&&eA(p.stateNode.containerInfo),or(p),null;case 10:return Rl(p.type),or(p),null;case 19:if($(Lr),w=p.memoizedState,w===null)return or(p),null;if(P=(p.flags&128)!==0,j=w.rendering,j===null)if(P)Fg(w,!1);else{if(Cr!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(j=My(h),j!==null){for(p.flags|=128,Fg(w,!1),h=j.updateQueue,p.updateQueue=h,Iy(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)JL(_,h),_=_.sibling;return X(Lr,Lr.current&1|2),wn&&kl(p,w.treeForkCount),p.child}h=h.sibling}w.tail!==null&&L()>Hy&&(p.flags|=128,P=!0,Fg(w,!1),p.lanes=4194304)}else{if(!P)if(h=My(j),h!==null){if(p.flags|=128,P=!0,h=h.updateQueue,p.updateQueue=h,Iy(p,h),Fg(w,!0),w.tail===null&&w.tailMode==="hidden"&&!j.alternate&&!wn)return or(p),null}else 2*L()-w.renderingStartTime>Hy&&_!==536870912&&(p.flags|=128,P=!0,Fg(w,!1),p.lanes=4194304);w.isBackwards?(j.sibling=p.child,p.child=j):(h=w.last,h!==null?h.sibling=j:p.child=j,w.last=j)}return w.tail!==null?(h=w.tail,w.rendering=h,w.tail=h.sibling,w.renderingStartTime=L(),h.sibling=null,_=Lr.current,X(Lr,P?_&1|2:_&1),wn&&kl(p,w.treeForkCount),h):(or(p),null);case 22:case 23:return is(p),t2(),w=p.memoizedState!==null,h!==null?h.memoizedState!==null!==w&&(p.flags|=8192):w&&(p.flags|=8192),w?(_&536870912)!==0&&(p.flags&128)===0&&(or(p),p.subtreeFlags&6&&(p.flags|=8192)):or(p),_=p.updateQueue,_!==null&&Iy(p,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),w=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(w=p.memoizedState.cachePool.pool),w!==_&&(p.flags|=2048),h!==null&&$(Od),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),Rl($r),or(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function Ane(h,p){switch(zE(p),p.tag){case 1:return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return Rl($r),ie(),h=p.flags,(h&65536)!==0&&(h&128)===0?(p.flags=h&-65537|128,p):null;case 26:case 27:case 5:return Re(p),null;case 31:if(p.memoizedState!==null){if(is(p),p.alternate===null)throw Error(r(340));Rd()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 13:if(is(p),h=p.memoizedState,h!==null&&h.dehydrated!==null){if(p.alternate===null)throw Error(r(340));Rd()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 19:return $(Lr),null;case 4:return ie(),null;case 10:return Rl(p.type),null;case 22:case 23:return is(p),t2(),h!==null&&$(Od),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return Rl($r),null;case 25:return null;default:return null}}function AI(h,p){switch(zE(p),p.tag){case 3:Rl($r),ie();break;case 26:case 27:case 5:Re(p);break;case 4:ie();break;case 31:p.memoizedState!==null&&is(p);break;case 13:is(p);break;case 19:$(Lr);break;case 10:Rl(p.type);break;case 22:case 23:is(p),t2(),h!==null&&$(Od);break;case 24:Rl($r)}}function Ug(h,p){try{var _=p.updateQueue,w=_!==null?_.lastEffect:null;if(w!==null){var P=w.next;_=P;do{if((_.tag&h)===h){w=void 0;var j=_.create,Y=_.inst;w=j(),Y.destroy=w}_=_.next}while(_!==P)}}catch(le){Fn(p,p.return,le)}}function eu(h,p,_){try{var w=p.updateQueue,P=w!==null?w.lastEffect:null;if(P!==null){var j=P.next;w=j;do{if((w.tag&h)===h){var Y=w.inst,le=Y.destroy;if(le!==void 0){Y.destroy=void 0,P=p;var Ee=_,Xe=le;try{Xe()}catch(lt){Fn(P,Ee,lt)}}}w=w.next}while(w!==j)}}catch(lt){Fn(p,p.return,lt)}}function TI(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{x4(p,_)}catch(w){Fn(h,h.return,w)}}}function CI(h,p,_){_.props=zd(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(w){Fn(h,p,w)}}function zg(h,p){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var w=h.stateNode;break;case 30:w=h.stateNode;break;default:w=h.stateNode}typeof _=="function"?h.refCleanup=_(w):_.current=w}}catch(P){Fn(h,p,P)}}function qo(h,p){var _=h.ref,w=h.refCleanup;if(_!==null)if(typeof w=="function")try{w()}catch(P){Fn(h,p,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Fn(h,p,P)}else _.current=null}function NI(h){var p=h.type,_=h.memoizedProps,w=h.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&w.focus();break e;case"img":_.src?w.src=_.src:_.srcSet&&(w.srcset=_.srcSet)}}catch(P){Fn(h,h.return,P)}}function D2(h,p,_){try{var w=h.stateNode;Kne(w,h.type,_,p),w[jr]=p}catch(P){Fn(h,h.return,P)}}function kI(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&ou(h.type)||h.tag===4}function j2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||kI(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&&ou(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 O2(h,p,_){var w=h.tag;if(w===5||w===6)h=h.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(h),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=Tl));else if(w!==4&&(w===27&&ou(h.type)&&(_=h.stateNode,p=null),h=h.child,h!==null))for(O2(h,p,_),h=h.sibling;h!==null;)O2(h,p,_),h=h.sibling}function Fy(h,p,_){var w=h.tag;if(w===5||w===6)h=h.stateNode,p?_.insertBefore(h,p):_.appendChild(h);else if(w!==4&&(w===27&&ou(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Fy(h,p,_),h=h.sibling;h!==null;)Fy(h,p,_),h=h.sibling}function PI(h){var p=h.stateNode,_=h.memoizedProps;try{for(var w=h.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);Gi(p,w,_),p[br]=h,p[jr]=_}catch(j){Fn(h,h.return,j)}}var Il=!1,Wr=!1,L2=!1,RI=typeof WeakSet=="function"?WeakSet:Set,Ci=null;function Tne(h,p){if(h=h.containerInfo,rA=av,h=VL(h),NE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var w=_.getSelection&&_.getSelection();if(w&&w.rangeCount!==0){_=w.anchorNode;var P=w.anchorOffset,j=w.focusNode;w=w.focusOffset;try{_.nodeType,j.nodeType}catch{_=null;break e}var Y=0,le=-1,Ee=-1,Xe=0,lt=0,dt=h,Ze=null;t:for(;;){for(var at;dt!==_||P!==0&&dt.nodeType!==3||(le=Y+P),dt!==j||w!==0&&dt.nodeType!==3||(Ee=Y+w),dt.nodeType===3&&(Y+=dt.nodeValue.length),(at=dt.firstChild)!==null;)Ze=dt,dt=at;for(;;){if(dt===h)break t;if(Ze===_&&++Xe===P&&(le=Y),Ze===j&&++lt===w&&(Ee=Y),(at=dt.nextSibling)!==null)break;dt=Ze,Ze=dt.parentNode}dt=at}_=le===-1||Ee===-1?null:{start:le,end:Ee}}else _=null}_=_||{start:0,end:0}}else _=null;for(iA={focusedElem:h,selectionRange:_},av=!1,Ci=p;Ci!==null;)if(p=Ci,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Ci=h;else for(;Ci!==null;){switch(p=Ci,j=p.alternate,h=p.flags,p.tag){case 0:if((h&4)!==0&&(h=p.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&j!==null){h=void 0,_=p,P=j.memoizedProps,j=j.memoizedState,w=_.stateNode;try{var jt=zd(_.type,P);h=w.getSnapshotBeforeUpdate(jt,j),w.__reactInternalSnapshotBeforeUpdate=h}catch(Gt){Fn(_,_.return,Gt)}}break;case 3:if((h&1024)!==0){if(h=p.stateNode.containerInfo,_=h.nodeType,_===9)oA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":oA(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=p.sibling,h!==null){h.return=p.return,Ci=h;break}Ci=p.return}}function DI(h,p,_){var w=_.flags;switch(_.tag){case 0:case 11:case 15:Ul(h,_),w&4&&Ug(5,_);break;case 1:if(Ul(h,_),w&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(Y){Fn(_,_.return,Y)}else{var P=zd(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(P,p,h.__reactInternalSnapshotBeforeUpdate)}catch(Y){Fn(_,_.return,Y)}}w&64&&TI(_),w&512&&zg(_,_.return);break;case 3:if(Ul(h,_),w&64&&(h=_.updateQueue,h!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{x4(h,p)}catch(Y){Fn(_,_.return,Y)}}break;case 27:p===null&&w&4&&PI(_);case 26:case 5:Ul(h,_),p===null&&w&4&&NI(_),w&512&&zg(_,_.return);break;case 12:Ul(h,_);break;case 31:Ul(h,_),w&4&&LI(h,_);break;case 13:Ul(h,_),w&4&&II(h,_),w&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Lne.bind(null,_),nre(h,_))));break;case 22:if(w=_.memoizedState!==null||Il,!w){p=p!==null&&p.memoizedState!==null||Wr,P=Il;var j=Wr;Il=w,(Wr=p)&&!j?zl(h,_,(_.subtreeFlags&8772)!==0):Ul(h,_),Il=P,Wr=j}break;case 30:break;default:Ul(h,_)}}function jI(h){var p=h.alternate;p!==null&&(h.alternate=null,jI(p)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(p=h.stateNode,p!==null&&tt(p)),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 hr=null,Oa=!1;function Fl(h,p,_){for(_=_.child;_!==null;)OI(h,p,_),_=_.sibling}function OI(h,p,_){if(oe&&typeof oe.onCommitFiberUnmount=="function")try{oe.onCommitFiberUnmount(Fe,_)}catch{}switch(_.tag){case 26:Wr||qo(_,p),Fl(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Wr||qo(_,p);var w=hr,P=Oa;ou(_.type)&&(hr=_.stateNode,Oa=!1),Fl(h,p,_),Xg(_.stateNode),hr=w,Oa=P;break;case 5:Wr||qo(_,p);case 6:if(w=hr,P=Oa,hr=null,Fl(h,p,_),hr=w,Oa=P,hr!==null)if(Oa)try{(hr.nodeType===9?hr.body:hr.nodeName==="HTML"?hr.ownerDocument.body:hr).removeChild(_.stateNode)}catch(j){Fn(_,p,j)}else try{hr.removeChild(_.stateNode)}catch(j){Fn(_,p,j)}break;case 18:hr!==null&&(Oa?(h=hr,T5(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),qf(h)):T5(hr,_.stateNode));break;case 4:w=hr,P=Oa,hr=_.stateNode.containerInfo,Oa=!0,Fl(h,p,_),hr=w,Oa=P;break;case 0:case 11:case 14:case 15:eu(2,_,p),Wr||eu(4,_,p),Fl(h,p,_);break;case 1:Wr||(qo(_,p),w=_.stateNode,typeof w.componentWillUnmount=="function"&&CI(_,p,w)),Fl(h,p,_);break;case 21:Fl(h,p,_);break;case 22:Wr=(w=Wr)||_.memoizedState!==null,Fl(h,p,_),Wr=w;break;default:Fl(h,p,_)}}function LI(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{qf(h)}catch(_){Fn(p,p.return,_)}}}function II(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{qf(h)}catch(_){Fn(p,p.return,_)}}function Cne(h){switch(h.tag){case 31:case 13:case 19:var p=h.stateNode;return p===null&&(p=h.stateNode=new RI),p;case 22:return h=h.stateNode,p=h._retryCache,p===null&&(p=h._retryCache=new RI),p;default:throw Error(r(435,h.tag))}}function Uy(h,p){var _=Cne(h);p.forEach(function(w){if(!_.has(w)){_.add(w);var P=Ine.bind(null,h,w);w.then(P,P)}})}function La(h,p){var _=p.deletions;if(_!==null)for(var w=0;w<_.length;w++){var P=_[w],j=h,Y=p,le=Y;e:for(;le!==null;){switch(le.tag){case 27:if(ou(le.type)){hr=le.stateNode,Oa=!1;break e}break;case 5:hr=le.stateNode,Oa=!1;break e;case 3:case 4:hr=le.stateNode.containerInfo,Oa=!0;break e}le=le.return}if(hr===null)throw Error(r(160));OI(j,Y,P),hr=null,Oa=!1,j=P.alternate,j!==null&&(j.return=null),P.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)FI(p,h),p=p.sibling}var bo=null;function FI(h,p){var _=h.alternate,w=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:La(p,h),Ia(h),w&4&&(eu(3,h,h.return),Ug(3,h),eu(5,h,h.return));break;case 1:La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),w&64&&Il&&(h=h.updateQueue,h!==null&&(w=h.callbacks,w!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?w:_.concat(w))));break;case 26:var P=bo;if(La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),w&4){var j=_!==null?_.memoizedState:null;if(w=h.memoizedState,_===null)if(w===null)if(h.stateNode===null){e:{w=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(w){case"title":j=P.getElementsByTagName("title")[0],(!j||j[it]||j[br]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=P.createElement(w),P.head.insertBefore(j,P.querySelector("head > title"))),Gi(j,w,_),j[br]=h,Oe(j),w=j;break e;case"link":var Y=F5("link","href",P).get(w+(_.href||""));if(Y){for(var le=0;le<Y.length;le++)if(j=Y[le],j.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&j.getAttribute("rel")===(_.rel==null?null:_.rel)&&j.getAttribute("title")===(_.title==null?null:_.title)&&j.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Y.splice(le,1);break t}}j=P.createElement(w),Gi(j,w,_),P.head.appendChild(j);break;case"meta":if(Y=F5("meta","content",P).get(w+(_.content||""))){for(le=0;le<Y.length;le++)if(j=Y[le],j.getAttribute("content")===(_.content==null?null:""+_.content)&&j.getAttribute("name")===(_.name==null?null:_.name)&&j.getAttribute("property")===(_.property==null?null:_.property)&&j.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&j.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Y.splice(le,1);break t}}j=P.createElement(w),Gi(j,w,_),P.head.appendChild(j);break;default:throw Error(r(468,w))}j[br]=h,Oe(j),w=j}h.stateNode=w}else U5(P,h.type,h.stateNode);else h.stateNode=I5(P,w,h.memoizedProps);else j!==w?(j===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):j.count--,w===null?U5(P,h.type,h.stateNode):I5(P,w,h.memoizedProps)):w===null&&h.stateNode!==null&&D2(h,h.memoizedProps,_.memoizedProps)}break;case 27:La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),_!==null&&w&4&&D2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(La(p,h),Ia(h),w&512&&(Wr||_===null||qo(_,_.return)),h.flags&32){P=h.stateNode;try{Vo(P,"")}catch(jt){Fn(h,h.return,jt)}}w&4&&h.stateNode!=null&&(P=h.memoizedProps,D2(h,P,_!==null?_.memoizedProps:P)),w&1024&&(L2=!0);break;case 6:if(La(p,h),Ia(h),w&4){if(h.stateNode===null)throw Error(r(162));w=h.memoizedProps,_=h.stateNode;try{_.nodeValue=w}catch(jt){Fn(h,h.return,jt)}}break;case 3:if(tv=null,P=bo,bo=Jy(p.containerInfo),La(p,h),bo=P,Ia(h),w&4&&_!==null&&_.memoizedState.isDehydrated)try{qf(p.containerInfo)}catch(jt){Fn(h,h.return,jt)}L2&&(L2=!1,UI(h));break;case 4:w=bo,bo=Jy(h.stateNode.containerInfo),La(p,h),Ia(h),bo=w;break;case 12:La(p,h),Ia(h);break;case 31:La(p,h),Ia(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Uy(h,w)));break;case 13:La(p,h),Ia(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(By=L()),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Uy(h,w)));break;case 22:P=h.memoizedState!==null;var Ee=_!==null&&_.memoizedState!==null,Xe=Il,lt=Wr;if(Il=Xe||P,Wr=lt||Ee,La(p,h),Wr=lt,Il=Xe,Ia(h),w&8192)e:for(p=h.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||Ee||Il||Wr||Bd(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){Ee=_=p;try{if(j=Ee.stateNode,P)Y=j.style,typeof Y.setProperty=="function"?Y.setProperty("display","none","important"):Y.display="none";else{le=Ee.stateNode;var dt=Ee.memoizedProps.style,Ze=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;le.style.display=Ze==null||typeof Ze=="boolean"?"":(""+Ze).trim()}}catch(jt){Fn(Ee,Ee.return,jt)}}}else if(p.tag===6){if(_===null){Ee=p;try{Ee.stateNode.nodeValue=P?"":Ee.memoizedProps}catch(jt){Fn(Ee,Ee.return,jt)}}}else if(p.tag===18){if(_===null){Ee=p;try{var at=Ee.stateNode;P?C5(at,!0):C5(Ee.stateNode,!1)}catch(jt){Fn(Ee,Ee.return,jt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===h)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break e;for(;p.sibling===null;){if(p.return===null||p.return===h)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}w&4&&(w=h.updateQueue,w!==null&&(_=w.retryQueue,_!==null&&(w.retryQueue=null,Uy(h,_))));break;case 19:La(p,h),Ia(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Uy(h,w)));break;case 30:break;case 21:break;default:La(p,h),Ia(h)}}function Ia(h){var p=h.flags;if(p&2){try{for(var _,w=h.return;w!==null;){if(kI(w)){_=w;break}w=w.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,j=j2(h);Fy(h,j,P);break;case 5:var Y=_.stateNode;_.flags&32&&(Vo(Y,""),_.flags&=-33);var le=j2(h);Fy(h,le,Y);break;case 3:case 4:var Ee=_.stateNode.containerInfo,Xe=j2(h);O2(h,Xe,Ee);break;default:throw Error(r(161))}}catch(lt){Fn(h,h.return,lt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function UI(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var p=h;UI(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),h=h.sibling}}function Ul(h,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)DI(h,p.alternate,p),p=p.sibling}function Bd(h){for(h=h.child;h!==null;){var p=h;switch(p.tag){case 0:case 11:case 14:case 15:eu(4,p,p.return),Bd(p);break;case 1:qo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&CI(p,p.return,_),Bd(p);break;case 27:Xg(p.stateNode);case 26:case 5:qo(p,p.return),Bd(p);break;case 22:p.memoizedState===null&&Bd(p);break;case 30:Bd(p);break;default:Bd(p)}h=h.sibling}}function zl(h,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var w=p.alternate,P=h,j=p,Y=j.flags;switch(j.tag){case 0:case 11:case 15:zl(P,j,_),Ug(4,j);break;case 1:if(zl(P,j,_),w=j,P=w.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Xe){Fn(w,w.return,Xe)}if(w=j,P=w.updateQueue,P!==null){var le=w.stateNode;try{var Ee=P.shared.hiddenCallbacks;if(Ee!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ee.length;P++)g4(Ee[P],le)}catch(Xe){Fn(w,w.return,Xe)}}_&&Y&64&&TI(j),zg(j,j.return);break;case 27:PI(j);case 26:case 5:zl(P,j,_),_&&w===null&&Y&4&&NI(j),zg(j,j.return);break;case 12:zl(P,j,_);break;case 31:zl(P,j,_),_&&Y&4&&LI(P,j);break;case 13:zl(P,j,_),_&&Y&4&&II(P,j);break;case 22:j.memoizedState===null&&zl(P,j,_),zg(j,j.return);break;case 30:break;default:zl(P,j,_)}p=p.sibling}}function I2(h,p){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(h=p.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Ag(_))}function F2(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&Ag(h))}function yo(h,p,_,w){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)zI(h,p,_,w),p=p.sibling}function zI(h,p,_,w){var P=p.flags;switch(p.tag){case 0:case 11:case 15:yo(h,p,_,w),P&2048&&Ug(9,p);break;case 1:yo(h,p,_,w);break;case 3:yo(h,p,_,w),P&2048&&(h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&Ag(h)));break;case 12:if(P&2048){yo(h,p,_,w),h=p.stateNode;try{var j=p.memoizedProps,Y=j.id,le=j.onPostCommit;typeof le=="function"&&le(Y,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ee){Fn(p,p.return,Ee)}}else yo(h,p,_,w);break;case 31:yo(h,p,_,w);break;case 13:yo(h,p,_,w);break;case 23:break;case 22:j=p.stateNode,Y=p.alternate,p.memoizedState!==null?j._visibility&2?yo(h,p,_,w):Bg(h,p):j._visibility&2?yo(h,p,_,w):(j._visibility|=2,Lf(h,p,_,w,(p.subtreeFlags&10256)!==0||!1)),P&2048&&I2(Y,p);break;case 24:yo(h,p,_,w),P&2048&&F2(p.alternate,p);break;default:yo(h,p,_,w)}}function Lf(h,p,_,w,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var j=h,Y=p,le=_,Ee=w,Xe=Y.flags;switch(Y.tag){case 0:case 11:case 15:Lf(j,Y,le,Ee,P),Ug(8,Y);break;case 23:break;case 22:var lt=Y.stateNode;Y.memoizedState!==null?lt._visibility&2?Lf(j,Y,le,Ee,P):Bg(j,Y):(lt._visibility|=2,Lf(j,Y,le,Ee,P)),P&&Xe&2048&&I2(Y.alternate,Y);break;case 24:Lf(j,Y,le,Ee,P),P&&Xe&2048&&F2(Y.alternate,Y);break;default:Lf(j,Y,le,Ee,P)}p=p.sibling}}function Bg(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,w=p,P=w.flags;switch(w.tag){case 22:Bg(_,w),P&2048&&I2(w.alternate,w);break;case 24:Bg(_,w),P&2048&&F2(w.alternate,w);break;default:Bg(_,w)}p=p.sibling}}var Hg=8192;function If(h,p,_){if(h.subtreeFlags&Hg)for(h=h.child;h!==null;)BI(h,p,_),h=h.sibling}function BI(h,p,_){switch(h.tag){case 26:If(h,p,_),h.flags&Hg&&h.memoizedState!==null&&pre(_,bo,h.memoizedState,h.memoizedProps);break;case 5:If(h,p,_);break;case 3:case 4:var w=bo;bo=Jy(h.stateNode.containerInfo),If(h,p,_),bo=w;break;case 22:h.memoizedState===null&&(w=h.alternate,w!==null&&w.memoizedState!==null?(w=Hg,Hg=16777216,If(h,p,_),Hg=w):If(h,p,_));break;default:If(h,p,_)}}function HI(h){var p=h.alternate;if(p!==null&&(h=p.child,h!==null)){p.child=null;do p=h.sibling,h.sibling=null,h=p;while(h!==null)}}function $g(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ci=w,VI(w,h)}HI(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)$I(h),h=h.sibling}function $I(h){switch(h.tag){case 0:case 11:case 15:$g(h),h.flags&2048&&eu(9,h,h.return);break;case 3:$g(h);break;case 12:$g(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,zy(h)):$g(h);break;default:$g(h)}}function zy(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ci=w,VI(w,h)}HI(h)}for(h=h.child;h!==null;){switch(p=h,p.tag){case 0:case 11:case 15:eu(8,p,p.return),zy(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,zy(p));break;default:zy(p)}h=h.sibling}}function VI(h,p){for(;Ci!==null;){var _=Ci;switch(_.tag){case 0:case 11:case 15:eu(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var w=_.memoizedState.cachePool.pool;w!=null&&w.refCount++}break;case 24:Ag(_.memoizedState.cache)}if(w=_.child,w!==null)w.return=_,Ci=w;else e:for(_=h;Ci!==null;){w=Ci;var P=w.sibling,j=w.return;if(jI(w),w===_){Ci=null;break e}if(P!==null){P.return=j,Ci=P;break e}Ci=j}}}var Nne={getCacheForType:function(h){var p=$i($r),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return $i($r).controller.signal}},kne=typeof WeakMap=="function"?WeakMap:Map,kn=0,Jn=null,pn=null,yn=0,In=0,as=null,tu=!1,Ff=!1,U2=!1,Bl=0,Cr=0,nu=0,Hd=0,z2=0,ss=0,Uf=0,Vg=null,Fa=null,B2=!1,By=0,GI=0,Hy=1/0,$y=null,ru=null,li=0,iu=null,zf=null,Hl=0,H2=0,$2=null,WI=null,Gg=0,V2=null;function ls(){return(kn&2)!==0&&yn!==0?yn&-yn:K.T!==null?Y2():zi()}function qI(){if(ss===0)if((yn&536870912)===0||wn){var h=ge;ge<<=1,(ge&3932160)===0&&(ge=262144),ss=h}else ss=536870912;return h=rs.current,h!==null&&(h.flags|=32),ss}function Ua(h,p,_){(h===Jn&&(In===2||In===9)||h.cancelPendingCommit!==null)&&(Bf(h,0),au(h,yn,ss,!1)),Qt(h,_),((kn&2)===0||h!==Jn)&&(h===Jn&&((kn&2)===0&&(Hd|=_),Cr===4&&au(h,yn,ss,!1)),Ko(h))}function KI(h,p,_){if((kn&6)!==0)throw Error(r(327));var w=!_&&(p&127)===0&&(p&h.expiredLanes)===0||ce(h,p),P=w?Dne(h,p):W2(h,p,!0),j=w;do{if(P===0){Ff&&!w&&au(h,p,0,!1);break}else{if(_=h.current.alternate,j&&!Pne(_)){P=W2(h,p,!1),j=!1;continue}if(P===2){if(j=p,h.errorRecoveryDisabledLanes&j)var Y=0;else Y=h.pendingLanes&-536870913,Y=Y!==0?Y:Y&536870912?536870912:0;if(Y!==0){p=Y;e:{var le=h;P=Vg;var Ee=le.current.memoizedState.isDehydrated;if(Ee&&(Bf(le,Y).flags|=256),Y=W2(le,Y,!1),Y!==2){if(U2&&!Ee){le.errorRecoveryDisabledLanes|=j,Hd|=j,P=4;break e}j=Fa,Fa=P,j!==null&&(Fa===null?Fa=j:Fa.push.apply(Fa,j))}P=Y}if(j=!1,P!==2)continue}}if(P===1){Bf(h,0),au(h,p,0,!0);break}e:{switch(w=h,j=P,j){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:au(w,p,ss,!tu);break e;case 2:Fa=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=By+300-L(),10<P)){if(au(w,p,ss,!tu),_e(w,0,!0)!==0)break e;Hl=p,w.timeoutHandle=E5(XI.bind(null,w,_,Fa,$y,B2,p,ss,Hd,Uf,tu,j,"Throttled",-0,0),P);break e}XI(w,_,Fa,$y,B2,p,ss,Hd,Uf,tu,j,null,-0,0)}}break}while(!0);Ko(h)}function XI(h,p,_,w,P,j,Y,le,Ee,Xe,lt,dt,Ze,at){if(h.timeoutHandle=-1,dt=p.subtreeFlags,dt&8192||(dt&16785408)===16785408){dt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Tl},BI(p,j,dt);var jt=(j&62914560)===j?By-L():(j&4194048)===j?GI-L():0;if(jt=mre(dt,jt),jt!==null){Hl=j,h.cancelPendingCommit=jt(r5.bind(null,h,p,j,_,w,P,Y,le,Ee,lt,dt,null,Ze,at)),au(h,j,Y,!Xe);return}}r5(h,p,j,_,w,P,Y,le,Ee)}function Pne(h){for(var p=h;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var w=0;w<_.length;w++){var P=_[w],j=P.getSnapshot;P=P.value;try{if(!ts(j(),P))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function au(h,p,_,w){p&=~z2,p&=~Hd,h.suspendedLanes|=p,h.pingedLanes&=~p,w&&(h.warmLanes|=p),w=h.expirationTimes;for(var P=p;0<P;){var j=31-He(P),Y=1<<j;w[j]=-1,P&=~Y}_!==0&&Vt(h,_,p)}function Vy(){return(kn&6)===0?(Wg(0),!1):!0}function G2(){if(pn!==null){if(In===0)var h=pn.return;else h=pn,Pl=Dd=null,o2(h),Pf=null,Cg=0,h=pn;for(;h!==null;)AI(h.alternate,h),h=h.return;pn=null}}function Bf(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Zne(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Hl=0,G2(),Jn=h,pn=_=Nl(h.current,null),yn=p,In=0,as=null,tu=!1,Ff=ce(h,p),U2=!1,Uf=ss=z2=Hd=nu=Cr=0,Fa=Vg=null,B2=!1,(p&8)!==0&&(p|=p&32);var w=h.entangledLanes;if(w!==0)for(h=h.entanglements,w&=p;0<w;){var P=31-He(w),j=1<<P;p|=h[P],w&=~j}return Bl=p,dy(),_}function YI(h,p){nn=null,K.H=Lg,p===kf||p===yy?(p=h4(),In=3):p===XE?(p=h4(),In=4):In=p===S2?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,as=p,pn===null&&(Cr=1,Dy(h,Ps(p,h.current)))}function ZI(){var h=rs.current;return h===null?!0:(yn&4194048)===yn?Os===null:(yn&62914560)===yn||(yn&536870912)!==0?h===Os:!1}function QI(){var h=K.H;return K.H=Lg,h===null?Lg:h}function JI(){var h=K.A;return K.A=Nne,h}function Gy(){Cr=4,tu||(yn&4194048)!==yn&&rs.current!==null||(Ff=!0),(nu&134217727)===0&&(Hd&134217727)===0||Jn===null||au(Jn,yn,ss,!1)}function W2(h,p,_){var w=kn;kn|=2;var P=QI(),j=JI();(Jn!==h||yn!==p)&&($y=null,Bf(h,p)),p=!1;var Y=Cr;e:do try{if(In!==0&&pn!==null){var le=pn,Ee=as;switch(In){case 8:G2(),Y=6;break e;case 3:case 2:case 9:case 6:rs.current===null&&(p=!0);var Xe=In;if(In=0,as=null,Hf(h,le,Ee,Xe),_&&Ff){Y=0;break e}break;default:Xe=In,In=0,as=null,Hf(h,le,Ee,Xe)}}Rne(),Y=Cr;break}catch(lt){YI(h,lt)}while(!0);return p&&h.shellSuspendCounter++,Pl=Dd=null,kn=w,K.H=P,K.A=j,pn===null&&(Jn=null,yn=0,dy()),Y}function Rne(){for(;pn!==null;)e5(pn)}function Dne(h,p){var _=kn;kn|=2;var w=QI(),P=JI();Jn!==h||yn!==p?($y=null,Hy=L()+500,Bf(h,p)):Ff=ce(h,p);e:do try{if(In!==0&&pn!==null){p=pn;var j=as;t:switch(In){case 1:In=0,as=null,Hf(h,p,j,1);break;case 2:case 9:if(u4(j)){In=0,as=null,t5(p);break}p=function(){In!==2&&In!==9||Jn!==h||(In=7),Ko(h)},j.then(p,p);break e;case 3:In=7;break e;case 4:In=5;break e;case 7:u4(j)?(In=0,as=null,t5(p)):(In=0,as=null,Hf(h,p,j,7));break;case 5:var Y=null;switch(pn.tag){case 26:Y=pn.memoizedState;case 5:case 27:var le=pn;if(Y?z5(Y):le.stateNode.complete){In=0,as=null;var Ee=le.sibling;if(Ee!==null)pn=Ee;else{var Xe=le.return;Xe!==null?(pn=Xe,Wy(Xe)):pn=null}break t}}In=0,as=null,Hf(h,p,j,5);break;case 6:In=0,as=null,Hf(h,p,j,6);break;case 8:G2(),Cr=6;break e;default:throw Error(r(462))}}jne();break}catch(lt){YI(h,lt)}while(!0);return Pl=Dd=null,K.H=w,K.A=P,kn=_,pn!==null?0:(Jn=null,yn=0,dy(),Cr)}function jne(){for(;pn!==null&&!Se();)e5(pn)}function e5(h){var p=MI(h.alternate,h,Bl);h.memoizedProps=h.pendingProps,p===null?Wy(h):pn=p}function t5(h){var p=h,_=p.alternate;switch(p.tag){case 15:case 0:p=bI(_,p,p.pendingProps,p.type,void 0,yn);break;case 11:p=bI(_,p,p.pendingProps,p.type.render,p.ref,yn);break;case 5:o2(p);default:AI(_,p),p=pn=JL(p,Bl),p=MI(_,p,Bl)}h.memoizedProps=h.pendingProps,p===null?Wy(h):pn=p}function Hf(h,p,_,w){Pl=Dd=null,o2(p),Pf=null,Cg=0;var P=p.return;try{if(wne(h,P,p,_,yn)){Cr=1,Dy(h,Ps(_,h.current)),pn=null;return}}catch(j){if(P!==null)throw pn=P,j;Cr=1,Dy(h,Ps(_,h.current)),pn=null;return}p.flags&32768?(wn||w===1?h=!0:Ff||(yn&536870912)!==0?h=!1:(tu=h=!0,(w===2||w===9||w===3||w===6)&&(w=rs.current,w!==null&&w.tag===13&&(w.flags|=16384))),n5(p,h)):Wy(p)}function Wy(h){var p=h;do{if((p.flags&32768)!==0){n5(p,tu);return}h=p.return;var _=Ene(p.alternate,p,Bl);if(_!==null){pn=_;return}if(p=p.sibling,p!==null){pn=p;return}pn=p=h}while(p!==null);Cr===0&&(Cr=5)}function n5(h,p){do{var _=Ane(h.alternate,h);if(_!==null){_.flags&=32767,pn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){pn=h;return}pn=h=_}while(h!==null);Cr=6,pn=null}function r5(h,p,_,w,P,j,Y,le,Ee){h.cancelPendingCommit=null;do qy();while(li!==0);if((kn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(j=p.lanes|p.childLanes,j|=jE,Ot(h,_,j,Y,le,Ee),h===Jn&&(pn=Jn=null,yn=0),zf=p,iu=h,Hl=_,H2=j,$2=P,WI=w,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Fne(ye,function(){return l5(),null})):(h.callbackNode=null,h.callbackPriority=0),w=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||w){w=K.T,K.T=null,P=G.p,G.p=2,Y=kn,kn|=4;try{Tne(h,p,_)}finally{kn=Y,G.p=P,K.T=w}}li=1,i5(),a5(),s5()}}function i5(){if(li===1){li=0;var h=iu,p=zf,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var w=G.p;G.p=2;var P=kn;kn|=4;try{FI(p,h);var j=iA,Y=VL(h.containerInfo),le=j.focusedElem,Ee=j.selectionRange;if(Y!==le&&le&&le.ownerDocument&&$L(le.ownerDocument.documentElement,le)){if(Ee!==null&&NE(le)){var Xe=Ee.start,lt=Ee.end;if(lt===void 0&&(lt=Xe),"selectionStart"in le)le.selectionStart=Xe,le.selectionEnd=Math.min(lt,le.value.length);else{var dt=le.ownerDocument||document,Ze=dt&&dt.defaultView||window;if(Ze.getSelection){var at=Ze.getSelection(),jt=le.textContent.length,Gt=Math.min(Ee.start,jt),Gn=Ee.end===void 0?Gt:Math.min(Ee.end,jt);!at.extend&&Gt>Gn&&(Y=Gn,Gn=Gt,Gt=Y);var ze=HL(le,Gt),De=HL(le,Gn);if(ze&&De&&(at.rangeCount!==1||at.anchorNode!==ze.node||at.anchorOffset!==ze.offset||at.focusNode!==De.node||at.focusOffset!==De.offset)){var We=dt.createRange();We.setStart(ze.node,ze.offset),at.removeAllRanges(),Gt>Gn?(at.addRange(We),at.extend(De.node,De.offset)):(We.setEnd(De.node,De.offset),at.addRange(We))}}}}for(dt=[],at=le;at=at.parentNode;)at.nodeType===1&&dt.push({element:at,left:at.scrollLeft,top:at.scrollTop});for(typeof le.focus=="function"&&le.focus(),le=0;le<dt.length;le++){var ut=dt[le];ut.element.scrollLeft=ut.left,ut.element.scrollTop=ut.top}}av=!!rA,iA=rA=null}finally{kn=P,G.p=w,K.T=_}}h.current=p,li=2}}function a5(){if(li===2){li=0;var h=iu,p=zf,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var w=G.p;G.p=2;var P=kn;kn|=4;try{DI(h,p.alternate,p)}finally{kn=P,G.p=w,K.T=_}}li=3}}function s5(){if(li===4||li===3){li=0,z();var h=iu,p=zf,_=Hl,w=WI;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?li=5:(li=0,zf=iu=null,o5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(ru=null),Ei(_),p=p.stateNode,oe&&typeof oe.onCommitFiberRoot=="function")try{oe.onCommitFiberRoot(Fe,p,void 0,(p.current.flags&128)===128)}catch{}if(w!==null){p=K.T,P=G.p,G.p=2,K.T=null;try{for(var j=h.onRecoverableError,Y=0;Y<w.length;Y++){var le=w[Y];j(le.value,{componentStack:le.stack})}}finally{K.T=p,G.p=P}}(Hl&3)!==0&&qy(),Ko(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===V2?Gg++:(Gg=0,V2=h):Gg=0,Wg(0)}}function o5(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,Ag(p)))}function qy(){return i5(),a5(),s5(),l5()}function l5(){if(li!==5)return!1;var h=iu,p=H2;H2=0;var _=Ei(Hl),w=K.T,P=G.p;try{G.p=32>_?32:_,K.T=null,_=$2,$2=null;var j=iu,Y=Hl;if(li=0,zf=iu=null,Hl=0,(kn&6)!==0)throw Error(r(331));var le=kn;if(kn|=4,$I(j.current),zI(j,j.current,Y,_),kn=le,Wg(0,!1),oe&&typeof oe.onPostCommitFiberRoot=="function")try{oe.onPostCommitFiberRoot(Fe,j)}catch{}return!0}finally{G.p=P,K.T=w,o5(h,p)}}function c5(h,p,_){p=Ps(_,p),p=w2(h.stateNode,p,2),h=Zc(h,p,2),h!==null&&(Qt(h,2),Ko(h))}function Fn(h,p,_){if(h.tag===3)c5(h,h,_);else for(;p!==null;){if(p.tag===3){c5(p,h,_);break}else if(p.tag===1){var w=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(ru===null||!ru.has(w))){h=Ps(_,h),_=uI(2),w=Zc(p,_,2),w!==null&&(dI(_,w,p,h),Qt(w,2),Ko(w));break}}p=p.return}}function q2(h,p,_){var w=h.pingCache;if(w===null){w=h.pingCache=new kne;var P=new Set;w.set(p,P)}else P=w.get(p),P===void 0&&(P=new Set,w.set(p,P));P.has(_)||(U2=!0,P.add(_),h=One.bind(null,h,p,_),p.then(h,h))}function One(h,p,_){var w=h.pingCache;w!==null&&w.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,Jn===h&&(yn&_)===_&&(Cr===4||Cr===3&&(yn&62914560)===yn&&300>L()-By?(kn&2)===0&&Bf(h,0):z2|=_,Uf===yn&&(Uf=0)),Ko(h)}function u5(h,p){p===0&&(p=xt()),h=kd(h,p),h!==null&&(Qt(h,p),Ko(h))}function Lne(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),u5(h,_)}function Ine(h,p){var _=0;switch(h.tag){case 31:case 13:var w=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:w=h.stateNode;break;case 22:w=h.stateNode._retryCache;break;default:throw Error(r(314))}w!==null&&w.delete(p),u5(h,_)}function Fne(h,p){return Ae(h,p)}var Ky=null,$f=null,K2=!1,Xy=!1,X2=!1,su=0;function Ko(h){h!==$f&&h.next===null&&($f===null?Ky=$f=h:$f=$f.next=h),Xy=!0,K2||(K2=!0,zne())}function Wg(h,p){if(!X2&&Xy){X2=!0;do for(var _=!1,w=Ky;w!==null;){if(h!==0){var P=w.pendingLanes;if(P===0)var j=0;else{var Y=w.suspendedLanes,le=w.pingedLanes;j=(1<<31-He(42|h)+1)-1,j&=P&~(Y&~le),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(_=!0,p5(w,j))}else j=yn,j=_e(w,w===Jn?j:0,w.cancelPendingCommit!==null||w.timeoutHandle!==-1),(j&3)===0||ce(w,j)||(_=!0,p5(w,j));w=w.next}while(_);X2=!1}}function Une(){d5()}function d5(){Xy=K2=!1;var h=0;su!==0&&Yne()&&(h=su);for(var p=L(),_=null,w=Ky;w!==null;){var P=w.next,j=h5(w,p);j===0?(w.next=null,_===null?Ky=P:_.next=P,P===null&&($f=_)):(_=w,(h!==0||(j&3)!==0)&&(Xy=!0)),w=P}li!==0&&li!==5||Wg(h),su!==0&&(su=0)}function h5(h,p){for(var _=h.suspendedLanes,w=h.pingedLanes,P=h.expirationTimes,j=h.pendingLanes&-62914561;0<j;){var Y=31-He(j),le=1<<Y,Ee=P[Y];Ee===-1?((le&_)===0||(le&w)!==0)&&(P[Y]=st(le,p)):Ee<=p&&(h.expiredLanes|=le),j&=~le}if(p=Jn,_=yn,_=_e(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w=h.callbackNode,_===0||h===p&&(In===2||In===9)||h.cancelPendingCommit!==null)return w!==null&&w!==null&&Pe(w),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||ce(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(w!==null&&Pe(w),Ei(_)){case 2:case 8:_=we;break;case 32:_=ye;break;case 268435456:_=Be;break;default:_=ye}return w=f5.bind(null,h),_=Ae(_,w),h.callbackPriority=p,h.callbackNode=_,p}return w!==null&&w!==null&&Pe(w),h.callbackPriority=2,h.callbackNode=null,2}function f5(h,p){if(li!==0&&li!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(qy()&&h.callbackNode!==_)return null;var w=yn;return w=_e(h,h===Jn?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w===0?null:(KI(h,w,p),h5(h,L()),h.callbackNode!=null&&h.callbackNode===_?f5.bind(null,h):null)}function p5(h,p){if(qy())return null;KI(h,p,!0)}function zne(){Qne(function(){(kn&6)!==0?Ae(ve,Une):d5()})}function Y2(){if(su===0){var h=Cf;h===0&&(h=Ye,Ye<<=1,(Ye&261888)===0&&(Ye=256)),su=h}return su}function m5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:ry(""+h)}function g5(h,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,h.id&&_.setAttribute("form",h.id),p.parentNode.insertBefore(_,p),h=new FormData(h),_.parentNode.removeChild(_),h}function Bne(h,p,_,w,P){if(p==="submit"&&_&&_.stateNode===P){var j=m5((P[jr]||null).action),Y=w.submitter;Y&&(p=(p=Y[jr]||null)?m5(p.formAction):Y.getAttribute("formAction"),p!==null&&(j=p,Y=null));var le=new oy("action","action",null,w,P);h.push({event:le,listeners:[{instance:null,listener:function(){if(w.defaultPrevented){if(su!==0){var Ee=Y?g5(P,Y):new FormData(P);g2(_,{pending:!0,data:Ee,method:P.method,action:j},null,Ee)}}else typeof j=="function"&&(le.preventDefault(),Ee=Y?g5(P,Y):new FormData(P),g2(_,{pending:!0,data:Ee,method:P.method,action:j},j,Ee))},currentTarget:P}]})}}for(var Z2=0;Z2<DE.length;Z2++){var Q2=DE[Z2],Hne=Q2.toLowerCase(),$ne=Q2[0].toUpperCase()+Q2.slice(1);xo(Hne,"on"+$ne)}xo(qL,"onAnimationEnd"),xo(KL,"onAnimationIteration"),xo(XL,"onAnimationStart"),xo("dblclick","onDoubleClick"),xo("focusin","onFocus"),xo("focusout","onBlur"),xo(ane,"onTransitionRun"),xo(sne,"onTransitionStart"),xo(one,"onTransitionCancel"),xo(YL,"onTransitionEnd"),yt("onMouseEnter",["mouseout","mouseover"]),yt("onMouseLeave",["mouseout","mouseover"]),yt("onPointerEnter",["pointerout","pointerover"]),yt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var qg="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(" "),Vne=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(qg));function x5(h,p){p=(p&4)!==0;for(var _=0;_<h.length;_++){var w=h[_],P=w.event;w=w.listeners;e:{var j=void 0;if(p)for(var Y=w.length-1;0<=Y;Y--){var le=w[Y],Ee=le.instance,Xe=le.currentTarget;if(le=le.listener,Ee!==j&&P.isPropagationStopped())break e;j=le,P.currentTarget=Xe;try{j(P)}catch(lt){uy(lt)}P.currentTarget=null,j=Ee}else for(Y=0;Y<w.length;Y++){if(le=w[Y],Ee=le.instance,Xe=le.currentTarget,le=le.listener,Ee!==j&&P.isPropagationStopped())break e;j=le,P.currentTarget=Xe;try{j(P)}catch(lt){uy(lt)}P.currentTarget=null,j=Ee}}}}function mn(h,p){var _=p[$c];_===void 0&&(_=p[$c]=new Set);var w=h+"__bubble";_.has(w)||(b5(p,h,2,!1),_.add(w))}function J2(h,p,_){var w=0;p&&(w|=4),b5(_,h,w,p)}var Yy="_reactListening"+Math.random().toString(36).slice(2);function eA(h){if(!h[Yy]){h[Yy]=!0,Te.forEach(function(_){_!=="selectionchange"&&(Vne.has(_)||J2(_,!1,h),J2(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[Yy]||(p[Yy]=!0,J2("selectionchange",!1,p))}}function b5(h,p,_,w){switch(q5(p)){case 2:var P=bre;break;case 8:P=yre;break;default:P=mA}_=P.bind(null,p,_,h),P=void 0,!vE||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(P=!0),w?P!==void 0?h.addEventListener(p,_,{capture:!0,passive:P}):h.addEventListener(p,_,!0):P!==void 0?h.addEventListener(p,_,{passive:P}):h.addEventListener(p,_,!1)}function tA(h,p,_,w,P){var j=w;if((p&1)===0&&(p&2)===0&&w!==null)e:for(;;){if(w===null)return;var Y=w.tag;if(Y===3||Y===4){var le=w.stateNode.containerInfo;if(le===P)break;if(Y===4)for(Y=w.return;Y!==null;){var Ee=Y.tag;if((Ee===3||Ee===4)&&Y.stateNode.containerInfo===P)return;Y=Y.return}for(;le!==null;){if(Y=Mt(le),Y===null)return;if(Ee=Y.tag,Ee===5||Ee===6||Ee===26||Ee===27){w=j=Y;continue e}le=le.parentNode}}w=w.return}SL(function(){var Xe=j,lt=bE(_),dt=[];e:{var Ze=ZL.get(h);if(Ze!==void 0){var at=oy,jt=h;switch(h){case"keypress":if(ay(_)===0)break e;case"keydown":case"keyup":at=Ite;break;case"focusin":jt="focus",at=ME;break;case"focusout":jt="blur",at=ME;break;case"beforeblur":case"afterblur":at=ME;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":at=AL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":at=Ete;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":at=zte;break;case qL:case KL:case XL:at=Cte;break;case YL:at=Hte;break;case"scroll":case"scrollend":at=Ste;break;case"wheel":at=Vte;break;case"copy":case"cut":case"paste":at=kte;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":at=CL;break;case"toggle":case"beforetoggle":at=Wte}var Gt=(p&4)!==0,Gn=!Gt&&(h==="scroll"||h==="scrollend"),ze=Gt?Ze!==null?Ze+"Capture":null:Ze;Gt=[];for(var De=Xe,We;De!==null;){var ut=De;if(We=ut.stateNode,ut=ut.tag,ut!==5&&ut!==26&&ut!==27||We===null||ze===null||(ut=mg(De,ze),ut!=null&&Gt.push(Kg(De,ut,We))),Gn)break;De=De.return}0<Gt.length&&(Ze=new at(Ze,jt,null,_,lt),dt.push({event:Ze,listeners:Gt}))}}if((p&7)===0){e:{if(Ze=h==="mouseover"||h==="pointerover",at=h==="mouseout"||h==="pointerout",Ze&&_!==xE&&(jt=_.relatedTarget||_.fromElement)&&(Mt(jt)||jt[mo]))break e;if((at||Ze)&&(Ze=lt.window===lt?lt:(Ze=lt.ownerDocument)?Ze.defaultView||Ze.parentWindow:window,at?(jt=_.relatedTarget||_.toElement,at=Xe,jt=jt?Mt(jt):null,jt!==null&&(Gn=a(jt),Gt=jt.tag,jt!==Gn||Gt!==5&&Gt!==27&&Gt!==6)&&(jt=null)):(at=null,jt=Xe),at!==jt)){if(Gt=AL,ut="onMouseLeave",ze="onMouseEnter",De="mouse",(h==="pointerout"||h==="pointerover")&&(Gt=CL,ut="onPointerLeave",ze="onPointerEnter",De="pointer"),Gn=at==null?Ze:Me(at),We=jt==null?Ze:Me(jt),Ze=new Gt(ut,De+"leave",at,_,lt),Ze.target=Gn,Ze.relatedTarget=We,ut=null,Mt(lt)===Xe&&(Gt=new Gt(ze,De+"enter",jt,_,lt),Gt.target=We,Gt.relatedTarget=Gn,ut=Gt),Gn=ut,at&&jt)t:{for(Gt=Gne,ze=at,De=jt,We=0,ut=ze;ut;ut=Gt(ut))We++;ut=0;for(var zt=De;zt;zt=Gt(zt))ut++;for(;0<We-ut;)ze=Gt(ze),We--;for(;0<ut-We;)De=Gt(De),ut--;for(;We--;){if(ze===De||De!==null&&ze===De.alternate){Gt=ze;break t}ze=Gt(ze),De=Gt(De)}Gt=null}else Gt=null;at!==null&&y5(dt,Ze,at,Gt,!1),jt!==null&&Gn!==null&&y5(dt,Gn,jt,Gt,!0)}}e:{if(Ze=Xe?Me(Xe):window,at=Ze.nodeName&&Ze.nodeName.toLowerCase(),at==="select"||at==="input"&&Ze.type==="file")var An=LL;else if(jL(Ze))if(IL)An=nne;else{An=ene;var It=Jte}else at=Ze.nodeName,!at||at.toLowerCase()!=="input"||Ze.type!=="checkbox"&&Ze.type!=="radio"?Xe&&gE(Xe.elementType)&&(An=LL):An=tne;if(An&&(An=An(h,Xe))){OL(dt,An,_,lt);break e}It&&It(h,Ze,Xe),h==="focusout"&&Xe&&Ze.type==="number"&&Xe.memoizedProps.value!=null&&Ai(Ze,"number",Ze.value)}switch(It=Xe?Me(Xe):window,h){case"focusin":(jL(It)||It.contentEditable==="true")&&(vf=It,kE=Xe,Sg=null);break;case"focusout":Sg=kE=vf=null;break;case"mousedown":PE=!0;break;case"contextmenu":case"mouseup":case"dragend":PE=!1,GL(dt,_,lt);break;case"selectionchange":if(ine)break;case"keydown":case"keyup":GL(dt,_,lt)}var rn;if(AE)e:{switch(h){case"compositionstart":var vn="onCompositionStart";break e;case"compositionend":vn="onCompositionEnd";break e;case"compositionupdate":vn="onCompositionUpdate";break e}vn=void 0}else yf?RL(h,_)&&(vn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(NL&&_.locale!=="ko"&&(yf||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&yf&&(rn=ML()):(Vc=lt,_E="value"in Vc?Vc.value:Vc.textContent,yf=!0)),It=Zy(Xe,vn),0<It.length&&(vn=new TL(vn,h,null,_,lt),dt.push({event:vn,listeners:It}),rn?vn.data=rn:(rn=DL(_),rn!==null&&(vn.data=rn)))),(rn=Kte?Xte(h,_):Yte(h,_))&&(vn=Zy(Xe,"onBeforeInput"),0<vn.length&&(It=new TL("onBeforeInput","beforeinput",null,_,lt),dt.push({event:It,listeners:vn}),It.data=rn)),Bne(dt,h,Xe,_,lt)}x5(dt,p)})}function Kg(h,p,_){return{instance:h,listener:p,currentTarget:_}}function Zy(h,p){for(var _=p+"Capture",w=[];h!==null;){var P=h,j=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||j===null||(P=mg(h,_),P!=null&&w.unshift(Kg(h,P,j)),P=mg(h,p),P!=null&&w.push(Kg(h,P,j))),h.tag===3)return w;h=h.return}return[]}function Gne(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function y5(h,p,_,w,P){for(var j=p._reactName,Y=[];_!==null&&_!==w;){var le=_,Ee=le.alternate,Xe=le.stateNode;if(le=le.tag,Ee!==null&&Ee===w)break;le!==5&&le!==26&&le!==27||Xe===null||(Ee=Xe,P?(Xe=mg(_,j),Xe!=null&&Y.unshift(Kg(_,Xe,Ee))):P||(Xe=mg(_,j),Xe!=null&&Y.push(Kg(_,Xe,Ee)))),_=_.return}Y.length!==0&&h.push({event:p,listeners:Y})}var Wne=/\r\n?/g,qne=/\u0000|\uFFFD/g;function v5(h){return(typeof h=="string"?h:""+h).replace(Wne,`
  9. `).replace(qne,"")}function _5(h,p){return p=v5(p),v5(h)===p}function Vn(h,p,_,w,P,j){switch(_){case"children":typeof w=="string"?p==="body"||p==="textarea"&&w===""||Vo(h,w):(typeof w=="number"||typeof w=="bigint")&&p!=="body"&&Vo(h,""+w);break;case"className":Ut(h,"class",w);break;case"tabIndex":Ut(h,"tabindex",w);break;case"dir":case"role":case"viewBox":case"width":case"height":Ut(h,_,w);break;case"style":_L(h,w,j);break;case"data":if(p!=="object"){Ut(h,"data",w);break}case"src":case"href":if(w===""&&(p!=="a"||_!=="href")){h.removeAttribute(_);break}if(w==null||typeof w=="function"||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=ry(""+w),h.setAttribute(_,w);break;case"action":case"formAction":if(typeof w=="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 j=="function"&&(_==="formAction"?(p!=="input"&&Vn(h,p,"name",P.name,P,null),Vn(h,p,"formEncType",P.formEncType,P,null),Vn(h,p,"formMethod",P.formMethod,P,null),Vn(h,p,"formTarget",P.formTarget,P,null)):(Vn(h,p,"encType",P.encType,P,null),Vn(h,p,"method",P.method,P,null),Vn(h,p,"target",P.target,P,null)));if(w==null||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=ry(""+w),h.setAttribute(_,w);break;case"onClick":w!=null&&(h.onclick=Tl);break;case"onScroll":w!=null&&mn("scroll",h);break;case"onScrollEnd":w!=null&&mn("scrollend",h);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=w&&typeof w!="function"&&typeof w!="symbol";break;case"muted":h.muted=w&&typeof w!="function"&&typeof w!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(w==null||typeof w=="function"||typeof w=="boolean"||typeof w=="symbol"){h.removeAttribute("xlink:href");break}_=ry(""+w),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":w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""+w):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":w&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":w===!0?h.setAttribute(_,""):w!==!1&&w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,w):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":w!=null&&typeof w!="function"&&typeof w!="symbol"&&!isNaN(w)&&1<=w?h.setAttribute(_,w):h.removeAttribute(_);break;case"rowSpan":case"start":w==null||typeof w=="function"||typeof w=="symbol"||isNaN(w)?h.removeAttribute(_):h.setAttribute(_,w);break;case"popover":mn("beforetoggle",h),mn("toggle",h),Xt(h,"popover",w);break;case"xlinkActuate":an(h,"http://www.w3.org/1999/xlink","xlink:actuate",w);break;case"xlinkArcrole":an(h,"http://www.w3.org/1999/xlink","xlink:arcrole",w);break;case"xlinkRole":an(h,"http://www.w3.org/1999/xlink","xlink:role",w);break;case"xlinkShow":an(h,"http://www.w3.org/1999/xlink","xlink:show",w);break;case"xlinkTitle":an(h,"http://www.w3.org/1999/xlink","xlink:title",w);break;case"xlinkType":an(h,"http://www.w3.org/1999/xlink","xlink:type",w);break;case"xmlBase":an(h,"http://www.w3.org/XML/1998/namespace","xml:base",w);break;case"xmlLang":an(h,"http://www.w3.org/XML/1998/namespace","xml:lang",w);break;case"xmlSpace":an(h,"http://www.w3.org/XML/1998/namespace","xml:space",w);break;case"is":Xt(h,"is",w);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=_te.get(_)||_,Xt(h,_,w))}}function nA(h,p,_,w,P,j){switch(_){case"style":_L(h,w,j);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof w=="string"?Vo(h,w):(typeof w=="number"||typeof w=="bigint")&&Vo(h,""+w);break;case"onScroll":w!=null&&mn("scroll",h);break;case"onScrollEnd":w!=null&&mn("scrollend",h);break;case"onClick":w!=null&&(h.onclick=Tl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ot.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),p=_.slice(2,P?_.length-7:void 0),j=h[jr]||null,j=j!=null?j[_]:null,typeof j=="function"&&h.removeEventListener(p,j,P),typeof w=="function")){typeof j!="function"&&j!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(p,w,P);break e}_ in h?h[_]=w:w===!0?h.setAttribute(_,""):Xt(h,_,w)}}}function Gi(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mn("error",h),mn("load",h);var w=!1,P=!1,j;for(j in _)if(_.hasOwnProperty(j)){var Y=_[j];if(Y!=null)switch(j){case"src":w=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Vn(h,p,j,Y,_,null)}}P&&Vn(h,p,"srcSet",_.srcSet,_,null),w&&Vn(h,p,"src",_.src,_,null);return;case"input":mn("invalid",h);var le=j=Y=P=null,Ee=null,Xe=null;for(w in _)if(_.hasOwnProperty(w)){var lt=_[w];if(lt!=null)switch(w){case"name":P=lt;break;case"type":Y=lt;break;case"checked":Ee=lt;break;case"defaultChecked":Xe=lt;break;case"value":j=lt;break;case"defaultValue":le=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,p));break;default:Vn(h,p,w,lt,_,null)}}Ln(h,j,le,Ee,Xe,Y,P,!1);return;case"select":mn("invalid",h),w=Y=j=null;for(P in _)if(_.hasOwnProperty(P)&&(le=_[P],le!=null))switch(P){case"value":j=le;break;case"defaultValue":Y=le;break;case"multiple":w=le;default:Vn(h,p,P,le,_,null)}p=j,_=Y,h.multiple=!!w,p!=null?oi(h,!!w,p,!1):_!=null&&oi(h,!!w,_,!0);return;case"textarea":mn("invalid",h),j=P=w=null;for(Y in _)if(_.hasOwnProperty(Y)&&(le=_[Y],le!=null))switch(Y){case"value":w=le;break;case"defaultValue":P=le;break;case"children":j=le;break;case"dangerouslySetInnerHTML":if(le!=null)throw Error(r(91));break;default:Vn(h,p,Y,le,_,null)}Bi(h,w,P,j);return;case"option":for(Ee in _)if(_.hasOwnProperty(Ee)&&(w=_[Ee],w!=null))switch(Ee){case"selected":h.selected=w&&typeof w!="function"&&typeof w!="symbol";break;default:Vn(h,p,Ee,w,_,null)}return;case"dialog":mn("beforetoggle",h),mn("toggle",h),mn("cancel",h),mn("close",h);break;case"iframe":case"object":mn("load",h);break;case"video":case"audio":for(w=0;w<qg.length;w++)mn(qg[w],h);break;case"image":mn("error",h),mn("load",h);break;case"details":mn("toggle",h);break;case"embed":case"source":case"link":mn("error",h),mn("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(Xe in _)if(_.hasOwnProperty(Xe)&&(w=_[Xe],w!=null))switch(Xe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Vn(h,p,Xe,w,_,null)}return;default:if(gE(p)){for(lt in _)_.hasOwnProperty(lt)&&(w=_[lt],w!==void 0&&nA(h,p,lt,w,_,void 0));return}}for(le in _)_.hasOwnProperty(le)&&(w=_[le],w!=null&&Vn(h,p,le,w,_,null))}function Kne(h,p,_,w){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,j=null,Y=null,le=null,Ee=null,Xe=null,lt=null;for(at in _){var dt=_[at];if(_.hasOwnProperty(at)&&dt!=null)switch(at){case"checked":break;case"value":break;case"defaultValue":Ee=dt;default:w.hasOwnProperty(at)||Vn(h,p,at,null,w,dt)}}for(var Ze in w){var at=w[Ze];if(dt=_[Ze],w.hasOwnProperty(Ze)&&(at!=null||dt!=null))switch(Ze){case"type":j=at;break;case"name":P=at;break;case"checked":Xe=at;break;case"defaultChecked":lt=at;break;case"value":Y=at;break;case"defaultValue":le=at;break;case"children":case"dangerouslySetInnerHTML":if(at!=null)throw Error(r(137,p));break;default:at!==dt&&Vn(h,p,Ze,at,w,dt)}}go(h,Y,le,Ee,Xe,lt,j,P);return;case"select":at=Y=le=Ze=null;for(j in _)if(Ee=_[j],_.hasOwnProperty(j)&&Ee!=null)switch(j){case"value":break;case"multiple":at=Ee;default:w.hasOwnProperty(j)||Vn(h,p,j,null,w,Ee)}for(P in w)if(j=w[P],Ee=_[P],w.hasOwnProperty(P)&&(j!=null||Ee!=null))switch(P){case"value":Ze=j;break;case"defaultValue":le=j;break;case"multiple":Y=j;default:j!==Ee&&Vn(h,p,P,j,w,Ee)}p=le,_=Y,w=at,Ze!=null?oi(h,!!_,Ze,!1):!!w!=!!_&&(p!=null?oi(h,!!_,p,!0):oi(h,!!_,_?[]:"",!1));return;case"textarea":at=Ze=null;for(le in _)if(P=_[le],_.hasOwnProperty(le)&&P!=null&&!w.hasOwnProperty(le))switch(le){case"value":break;case"children":break;default:Vn(h,p,le,null,w,P)}for(Y in w)if(P=w[Y],j=_[Y],w.hasOwnProperty(Y)&&(P!=null||j!=null))switch(Y){case"value":Ze=P;break;case"defaultValue":at=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==j&&Vn(h,p,Y,P,w,j)}Ti(h,Ze,at);return;case"option":for(var jt in _)if(Ze=_[jt],_.hasOwnProperty(jt)&&Ze!=null&&!w.hasOwnProperty(jt))switch(jt){case"selected":h.selected=!1;break;default:Vn(h,p,jt,null,w,Ze)}for(Ee in w)if(Ze=w[Ee],at=_[Ee],w.hasOwnProperty(Ee)&&Ze!==at&&(Ze!=null||at!=null))switch(Ee){case"selected":h.selected=Ze&&typeof Ze!="function"&&typeof Ze!="symbol";break;default:Vn(h,p,Ee,Ze,w,at)}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 Gt in _)Ze=_[Gt],_.hasOwnProperty(Gt)&&Ze!=null&&!w.hasOwnProperty(Gt)&&Vn(h,p,Gt,null,w,Ze);for(Xe in w)if(Ze=w[Xe],at=_[Xe],w.hasOwnProperty(Xe)&&Ze!==at&&(Ze!=null||at!=null))switch(Xe){case"children":case"dangerouslySetInnerHTML":if(Ze!=null)throw Error(r(137,p));break;default:Vn(h,p,Xe,Ze,w,at)}return;default:if(gE(p)){for(var Gn in _)Ze=_[Gn],_.hasOwnProperty(Gn)&&Ze!==void 0&&!w.hasOwnProperty(Gn)&&nA(h,p,Gn,void 0,w,Ze);for(lt in w)Ze=w[lt],at=_[lt],!w.hasOwnProperty(lt)||Ze===at||Ze===void 0&&at===void 0||nA(h,p,lt,Ze,w,at);return}}for(var ze in _)Ze=_[ze],_.hasOwnProperty(ze)&&Ze!=null&&!w.hasOwnProperty(ze)&&Vn(h,p,ze,null,w,Ze);for(dt in w)Ze=w[dt],at=_[dt],!w.hasOwnProperty(dt)||Ze===at||Ze==null&&at==null||Vn(h,p,dt,Ze,w,at)}function w5(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Xne(){if(typeof performance.getEntriesByType=="function"){for(var h=0,p=0,_=performance.getEntriesByType("resource"),w=0;w<_.length;w++){var P=_[w],j=P.transferSize,Y=P.initiatorType,le=P.duration;if(j&&le&&w5(Y)){for(Y=0,le=P.responseEnd,w+=1;w<_.length;w++){var Ee=_[w],Xe=Ee.startTime;if(Xe>le)break;var lt=Ee.transferSize,dt=Ee.initiatorType;lt&&w5(dt)&&(Ee=Ee.responseEnd,Y+=lt*(Ee<le?1:(le-Xe)/(Ee-Xe)))}if(--w,p+=8*(j+Y)/(P.duration/1e3),h++,10<h)break}}if(0<h)return p/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var rA=null,iA=null;function Qy(h){return h.nodeType===9?h:h.ownerDocument}function S5(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 M5(h,p){if(h===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&p==="foreignObject"?0:h}function aA(h,p){return h==="textarea"||h==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.children=="bigint"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var sA=null;function Yne(){var h=window.event;return h&&h.type==="popstate"?h===sA?!1:(sA=h,!0):(sA=null,!1)}var E5=typeof setTimeout=="function"?setTimeout:void 0,Zne=typeof clearTimeout=="function"?clearTimeout:void 0,A5=typeof Promise=="function"?Promise:void 0,Qne=typeof queueMicrotask=="function"?queueMicrotask:typeof A5<"u"?function(h){return A5.resolve(null).then(h).catch(Jne)}:E5;function Jne(h){setTimeout(function(){throw h})}function ou(h){return h==="head"}function T5(h,p){var _=p,w=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(w===0){h.removeChild(P),qf(p);return}w--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")w++;else if(_==="html")Xg(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Xg(_);for(var j=_.firstChild;j;){var Y=j.nextSibling,le=j.nodeName;j[it]||le==="SCRIPT"||le==="STYLE"||le==="LINK"&&j.rel.toLowerCase()==="stylesheet"||_.removeChild(j),j=Y}}else _==="body"&&Xg(h.ownerDocument.body);_=P}while(_);qf(p)}function C5(h,p){var _=h;h=0;do{var w=_.nextSibling;if(_.nodeType===1?p?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(p?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),w&&w.nodeType===8)if(_=w.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=w}while(_)}function oA(h){var p=h.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":oA(_),tt(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function ere(h,p,_,w){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==p.toLowerCase()){if(!w&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(w){if(!h[it])switch(p){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(j=h.getAttribute("rel"),j==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(j!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(j=h.getAttribute("src"),(j!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&j&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(p==="input"&&h.type==="hidden"){var j=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===j)return h}else return h;if(h=Ls(h.nextSibling),h===null)break}return null}function tre(h,p,_){if(p==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Ls(h.nextSibling),h===null))return null;return h}function N5(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=Ls(h.nextSibling),h===null))return null;return h}function lA(h){return h.data==="$?"||h.data==="$~"}function cA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function nre(h,p){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=p;else if(h.data!=="$?"||_.readyState!=="loading")p();else{var w=function(){p(),_.removeEventListener("DOMContentLoaded",w)};_.addEventListener("DOMContentLoaded",w),h._reactRetry=w}}function Ls(h){for(;h!=null;h=h.nextSibling){var p=h.nodeType;if(p===1||p===3)break;if(p===8){if(p=h.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return h}var uA=null;function k5(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return Ls(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function P5(h){h=h.previousSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return h;p--}else _!=="/$"&&_!=="/&"||p++}h=h.previousSibling}return null}function R5(h,p,_){switch(p=Qy(_),h){case"html":if(h=p.documentElement,!h)throw Error(r(452));return h;case"head":if(h=p.head,!h)throw Error(r(453));return h;case"body":if(h=p.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Xg(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);tt(h)}var Is=new Map,D5=new Set;function Jy(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var $l=G.d;G.d={f:rre,r:ire,D:are,C:sre,L:ore,m:lre,X:ure,S:cre,M:dre};function rre(){var h=$l.f(),p=Vy();return h||p}function ire(h){var p=ae(h);p!==null&&p.tag===5&&p.type==="form"?Y4(p):$l.r(h)}var Vf=typeof document>"u"?null:document;function j5(h,p,_){var w=Vf;if(w&&typeof p=="string"&&p){var P=Dn(p);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),D5.has(P)||(D5.add(P),h={rel:h,crossOrigin:_,href:p},w.querySelector(P)===null&&(p=w.createElement("link"),Gi(p,"link",h),Oe(p),w.head.appendChild(p)))}}function are(h){$l.D(h),j5("dns-prefetch",h,null)}function sre(h,p){$l.C(h,p),j5("preconnect",h,p)}function ore(h,p,_){$l.L(h,p,_);var w=Vf;if(w&&h&&p){var P='link[rel="preload"][as="'+Dn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Dn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Dn(_.imageSizes)+'"]')):P+='[href="'+Dn(h)+'"]';var j=P;switch(p){case"style":j=Gf(h);break;case"script":j=Wf(h)}Is.has(j)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),Is.set(j,h),w.querySelector(P)!==null||p==="style"&&w.querySelector(Yg(j))||p==="script"&&w.querySelector(Zg(j))||(p=w.createElement("link"),Gi(p,"link",h),Oe(p),w.head.appendChild(p)))}}function lre(h,p){$l.m(h,p);var _=Vf;if(_&&h){var w=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+Dn(w)+'"][href="'+Dn(h)+'"]',j=P;switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Wf(h)}if(!Is.has(j)&&(h=f({rel:"modulepreload",href:h},p),Is.set(j,h),_.querySelector(P)===null)){switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Zg(j)))return}w=_.createElement("link"),Gi(w,"link",h),Oe(w),_.head.appendChild(w)}}}function cre(h,p,_){$l.S(h,p,_);var w=Vf;if(w&&h){var P=Ie(w).hoistableStyles,j=Gf(h);p=p||"default";var Y=P.get(j);if(!Y){var le={loading:0,preload:null};if(Y=w.querySelector(Yg(j)))le.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=Is.get(j))&&dA(h,_);var Ee=Y=w.createElement("link");Oe(Ee),Gi(Ee,"link",h),Ee._p=new Promise(function(Xe,lt){Ee.onload=Xe,Ee.onerror=lt}),Ee.addEventListener("load",function(){le.loading|=1}),Ee.addEventListener("error",function(){le.loading|=2}),le.loading|=4,ev(Y,p,w)}Y={type:"stylesheet",instance:Y,count:1,state:le},P.set(j,Y)}}}function ure(h,p){$l.X(h,p);var _=Vf;if(_&&h){var w=Ie(_).hoistableScripts,P=Wf(h),j=w.get(P);j||(j=_.querySelector(Zg(P)),j||(h=f({src:h,async:!0},p),(p=Is.get(P))&&hA(h,p),j=_.createElement("script"),Oe(j),Gi(j,"link",h),_.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},w.set(P,j))}}function dre(h,p){$l.M(h,p);var _=Vf;if(_&&h){var w=Ie(_).hoistableScripts,P=Wf(h),j=w.get(P);j||(j=_.querySelector(Zg(P)),j||(h=f({src:h,async:!0,type:"module"},p),(p=Is.get(P))&&hA(h,p),j=_.createElement("script"),Oe(j),Gi(j,"link",h),_.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},w.set(P,j))}}function O5(h,p,_,w){var P=(P=pe.current)?Jy(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Gf(_.href),_=Ie(P).hoistableStyles,w=_.get(p),w||(w={type:"style",instance:null,count:0,state:null},_.set(p,w)),w):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Gf(_.href);var j=Ie(P).hoistableStyles,Y=j.get(h);if(Y||(P=P.ownerDocument||P,Y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(h,Y),(j=P.querySelector(Yg(h)))&&!j._p&&(Y.instance=j,Y.state.loading=5),Is.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Is.set(h,_),j||hre(P,h,_,Y.state))),p&&w===null)throw Error(r(528,""));return Y}if(p&&w!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=Wf(_),_=Ie(P).hoistableScripts,w=_.get(p),w||(w={type:"script",instance:null,count:0,state:null},_.set(p,w)),w):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Gf(h){return'href="'+Dn(h)+'"'}function Yg(h){return'link[rel="stylesheet"]['+h+"]"}function L5(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function hre(h,p,_,w){h.querySelector('link[rel="preload"][as="style"]['+p+"]")?w.loading=1:(p=h.createElement("link"),w.preload=p,p.addEventListener("load",function(){return w.loading|=1}),p.addEventListener("error",function(){return w.loading|=2}),Gi(p,"link",_),Oe(p),h.head.appendChild(p))}function Wf(h){return'[src="'+Dn(h)+'"]'}function Zg(h){return"script[async]"+h}function I5(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var w=h.querySelector('style[data-href~="'+Dn(_.href)+'"]');if(w)return p.instance=w,Oe(w),w;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return w=(h.ownerDocument||h).createElement("style"),Oe(w),Gi(w,"style",P),ev(w,_.precedence,h),p.instance=w;case"stylesheet":P=Gf(_.href);var j=h.querySelector(Yg(P));if(j)return p.state.loading|=4,p.instance=j,Oe(j),j;w=L5(_),(P=Is.get(P))&&dA(w,P),j=(h.ownerDocument||h).createElement("link"),Oe(j);var Y=j;return Y._p=new Promise(function(le,Ee){Y.onload=le,Y.onerror=Ee}),Gi(j,"link",w),p.state.loading|=4,ev(j,_.precedence,h),p.instance=j;case"script":return j=Wf(_.src),(P=h.querySelector(Zg(j)))?(p.instance=P,Oe(P),P):(w=_,(P=Is.get(j))&&(w=f({},_),hA(w,P)),h=h.ownerDocument||h,P=h.createElement("script"),Oe(P),Gi(P,"link",w),h.head.appendChild(P),p.instance=P);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(w=p.instance,p.state.loading|=4,ev(w,_.precedence,h));return p.instance}function ev(h,p,_){for(var w=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=w.length?w[w.length-1]:null,j=P,Y=0;Y<w.length;Y++){var le=w[Y];if(le.dataset.precedence===p)j=le;else if(j!==P)break}j?j.parentNode.insertBefore(h,j.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(h,p.firstChild))}function dA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.title==null&&(h.title=p.title)}function hA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.integrity==null&&(h.integrity=p.integrity)}var tv=null;function F5(h,p,_){if(tv===null){var w=new Map,P=tv=new Map;P.set(_,w)}else P=tv,w=P.get(_),w||(w=new Map,P.set(_,w));if(w.has(h))return w;for(w.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var j=_[P];if(!(j[it]||j[br]||h==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var Y=j.getAttribute(p)||"";Y=h+Y;var le=w.get(Y);le?le.push(j):w.set(Y,[j])}}return w}function U5(h,p,_){h=h.ownerDocument||h,h.head.insertBefore(_,p==="title"?h.querySelector("head > title"):null)}function fre(h,p,_){if(_===1||p.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof p.precedence!="string"||typeof p.href!="string"||p.href==="")break;return!0;case"link":if(typeof p.rel!="string"||typeof p.href!="string"||p.href===""||p.onLoad||p.onError)break;switch(p.rel){case"stylesheet":return h=p.disabled,typeof p.precedence=="string"&&h==null;default:return!0}case"script":if(p.async&&typeof p.async!="function"&&typeof p.async!="symbol"&&!p.onLoad&&!p.onError&&p.src&&typeof p.src=="string")return!0}return!1}function z5(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function pre(h,p,_,w){if(_.type==="stylesheet"&&(typeof w.media!="string"||matchMedia(w.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Gf(w.href),j=p.querySelector(Yg(P));if(j){p=j._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=nv.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=j,Oe(j);return}j=p.ownerDocument||p,w=L5(w),(P=Is.get(P))&&dA(w,P),j=j.createElement("link"),Oe(j);var Y=j;Y._p=new Promise(function(le,Ee){Y.onload=le,Y.onerror=Ee}),Gi(j,"link",w),_.instance=j}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=nv.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var fA=0;function mre(h,p){return h.stylesheets&&h.count===0&&iv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var w=setTimeout(function(){if(h.stylesheets&&iv(h,h.stylesheets),h.unsuspend){var j=h.unsuspend;h.unsuspend=null,j()}},6e4+p);0<h.imgBytes&&fA===0&&(fA=62500*Xne());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&iv(h,h.stylesheets),h.unsuspend)){var j=h.unsuspend;h.unsuspend=null,j()}},(h.imgBytes>fA?50:800)+p);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(w),clearTimeout(P)}}:null}function nv(){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 rv=null;function iv(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,rv=new Map,p.forEach(gre,h),rv=null,nv.call(h))}function gre(h,p){if(!(p.state.loading&4)){var _=rv.get(h);if(_)var w=_.get(null);else{_=new Map,rv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<P.length;j++){var Y=P[j];(Y.nodeName==="LINK"||Y.getAttribute("media")!=="not all")&&(_.set(Y.dataset.precedence,Y),w=Y)}w&&_.set(null,w)}P=p.instance,Y=P.getAttribute("data-precedence"),j=_.get(Y)||w,j===w&&_.set(null,P),_.set(Y,P),this.count++,w=nv.bind(this),P.addEventListener("load",w),P.addEventListener("error",w),j?j.parentNode.insertBefore(P,j.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),p.state.loading|=4}}var Qg={$$typeof:S,Provider:null,Consumer:null,_currentValue:ee,_currentValue2:ee,_threadCount:0};function xre(h,p,_,w,P,j,Y,le,Ee){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=St(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=St(0),this.hiddenUpdates=St(null),this.identifierPrefix=w,this.onUncaughtError=P,this.onCaughtError=j,this.onRecoverableError=Y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ee,this.incompleteTransitions=new Map}function B5(h,p,_,w,P,j,Y,le,Ee,Xe,lt,dt){return h=new xre(h,p,_,Y,Ee,Xe,lt,dt,le),p=1,j===!0&&(p|=24),j=ns(3,null,null,p),h.current=j,j.stateNode=h,p=WE(),p.refCount++,h.pooledCache=p,p.refCount++,j.memoizedState={element:w,isDehydrated:_,cache:p},YE(j),h}function H5(h){return h?(h=Sf,h):Sf}function $5(h,p,_,w,P,j){P=H5(P),w.context===null?w.context=P:w.pendingContext=P,w=Yc(p),w.payload={element:_},j=j===void 0?null:j,j!==null&&(w.callback=j),_=Zc(h,w,p),_!==null&&(Ua(_,h,p),kg(_,h,p))}function V5(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function pA(h,p){V5(h,p),(h=h.alternate)&&V5(h,p)}function G5(h){if(h.tag===13||h.tag===31){var p=kd(h,67108864);p!==null&&Ua(p,h,67108864),pA(h,67108864)}}function W5(h){if(h.tag===13||h.tag===31){var p=ls();p=si(p);var _=kd(h,p);_!==null&&Ua(_,h,p),pA(h,p)}}var av=!0;function bre(h,p,_,w){var P=K.T;K.T=null;var j=G.p;try{G.p=2,mA(h,p,_,w)}finally{G.p=j,K.T=P}}function yre(h,p,_,w){var P=K.T;K.T=null;var j=G.p;try{G.p=8,mA(h,p,_,w)}finally{G.p=j,K.T=P}}function mA(h,p,_,w){if(av){var P=gA(w);if(P===null)tA(h,p,w,sv,_),K5(h,w);else if(_re(P,h,p,_,w))w.stopPropagation();else if(K5(h,w),p&4&&-1<vre.indexOf(h)){for(;P!==null;){var j=ae(P);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var Y=Ce(j.pendingLanes);if(Y!==0){var le=j;for(le.pendingLanes|=2,le.entangledLanes|=2;Y;){var Ee=1<<31-He(Y);le.entanglements[1]|=Ee,Y&=~Ee}Ko(j),(kn&6)===0&&(Hy=L()+500,Wg(0))}}break;case 31:case 13:le=kd(j,2),le!==null&&Ua(le,j,2),Vy(),pA(j,2)}if(j=gA(w),j===null&&tA(h,p,w,sv,_),j===P)break;P=j}P!==null&&w.stopPropagation()}else tA(h,p,w,null,_)}}function gA(h){return h=bE(h),xA(h)}var sv=null;function xA(h){if(sv=null,h=Mt(h),h!==null){var p=a(h);if(p===null)h=null;else{var _=p.tag;if(_===13){if(h=s(p),h!==null)return h;h=null}else if(_===31){if(h=o(p),h!==null)return h;h=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;h=null}else p!==h&&(h=null)}}return sv=h,null}function q5(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(ne()){case ve:return 2;case we:return 8;case ye:case nt:return 32;case Be:return 268435456;default:return 32}default:return 32}}var bA=!1,lu=null,cu=null,uu=null,Jg=new Map,ex=new Map,du=[],vre="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 K5(h,p){switch(h){case"focusin":case"focusout":lu=null;break;case"dragenter":case"dragleave":cu=null;break;case"mouseover":case"mouseout":uu=null;break;case"pointerover":case"pointerout":Jg.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":ex.delete(p.pointerId)}}function tx(h,p,_,w,P,j){return h===null||h.nativeEvent!==j?(h={blockedOn:p,domEventName:_,eventSystemFlags:w,nativeEvent:j,targetContainers:[P]},p!==null&&(p=ae(p),p!==null&&G5(p)),h):(h.eventSystemFlags|=w,p=h.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),h)}function _re(h,p,_,w,P){switch(p){case"focusin":return lu=tx(lu,h,p,_,w,P),!0;case"dragenter":return cu=tx(cu,h,p,_,w,P),!0;case"mouseover":return uu=tx(uu,h,p,_,w,P),!0;case"pointerover":var j=P.pointerId;return Jg.set(j,tx(Jg.get(j)||null,h,p,_,w,P)),!0;case"gotpointercapture":return j=P.pointerId,ex.set(j,tx(ex.get(j)||null,h,p,_,w,P)),!0}return!1}function X5(h){var p=Mt(h.target);if(p!==null){var _=a(p);if(_!==null){if(p=_.tag,p===13){if(p=s(_),p!==null){h.blockedOn=p,ra(h.priority,function(){W5(_)});return}}else if(p===31){if(p=o(_),p!==null){h.blockedOn=p,ra(h.priority,function(){W5(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function ov(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=gA(h.nativeEvent);if(_===null){_=h.nativeEvent;var w=new _.constructor(_.type,_);xE=w,_.target.dispatchEvent(w),xE=null}else return p=ae(_),p!==null&&G5(p),h.blockedOn=_,!1;p.shift()}return!0}function Y5(h,p,_){ov(h)&&_.delete(p)}function wre(){bA=!1,lu!==null&&ov(lu)&&(lu=null),cu!==null&&ov(cu)&&(cu=null),uu!==null&&ov(uu)&&(uu=null),Jg.forEach(Y5),ex.forEach(Y5)}function lv(h,p){h.blockedOn===p&&(h.blockedOn=null,bA||(bA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,wre)))}var cv=null;function Z5(h){cv!==h&&(cv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){cv===h&&(cv=null);for(var p=0;p<h.length;p+=3){var _=h[p],w=h[p+1],P=h[p+2];if(typeof w!="function"){if(xA(w||_)===null)continue;break}var j=ae(_);j!==null&&(h.splice(p,3),p-=3,g2(j,{pending:!0,data:P,method:_.method,action:w},w,P))}}))}function qf(h){function p(Ee){return lv(Ee,h)}lu!==null&&lv(lu,h),cu!==null&&lv(cu,h),uu!==null&&lv(uu,h),Jg.forEach(p),ex.forEach(p);for(var _=0;_<du.length;_++){var w=du[_];w.blockedOn===h&&(w.blockedOn=null)}for(;0<du.length&&(_=du[0],_.blockedOn===null);)X5(_),_.blockedOn===null&&du.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(w=0;w<_.length;w+=3){var P=_[w],j=_[w+1],Y=P[jr]||null;if(typeof j=="function")Y||Z5(_);else if(Y){var le=null;if(j&&j.hasAttribute("formAction")){if(P=j,Y=j[jr]||null)le=Y.formAction;else if(xA(P)!==null)continue}else le=Y.action;typeof le=="function"?_[w+1]=le:(_.splice(w,3),w-=3),Z5(_)}}}function Q5(){function h(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(Y){return P=Y})},focusReset:"manual",scroll:"manual"})}function p(){P!==null&&(P(),P=null),w||setTimeout(_,20)}function _(){if(!w&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var w=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){w=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),P!==null&&(P(),P=null)}}}function yA(h){this._internalRoot=h}uv.prototype.render=yA.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,w=ls();$5(_,w,h,p,null,null)},uv.prototype.unmount=yA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;$5(h.current,2,null,h,null,null),Vy(),p[mo]=null}};function uv(h){this._internalRoot=h}uv.prototype.unstable_scheduleHydration=function(h){if(h){var p=zi();h={blockedOn:null,target:h,priority:p};for(var _=0;_<du.length&&p!==0&&p<du[_].priority;_++);du.splice(_,0,h),_===0&&X5(h)}};var J5=e.version;if(J5!=="19.2.0")throw Error(r(527,J5,"19.2.0"));G.findDOMNode=function(h){var p=h._reactInternals;if(p===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(p),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Sre={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var dv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!dv.isDisabled&&dv.supportsFiber)try{Fe=dv.inject(Sre),oe=dv}catch{}}return rx.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,w="",P=sI,j=oI,Y=lI;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(w=p.identifierPrefix),p.onUncaughtError!==void 0&&(P=p.onUncaughtError),p.onCaughtError!==void 0&&(j=p.onCaughtError),p.onRecoverableError!==void 0&&(Y=p.onRecoverableError)),p=B5(h,1,!1,null,null,_,w,null,P,j,Y,Q5),h[mo]=p.current,eA(h),new yA(p)},rx.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var w=!1,P="",j=sI,Y=oI,le=lI,Ee=null;return _!=null&&(_.unstable_strictMode===!0&&(w=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(j=_.onUncaughtError),_.onCaughtError!==void 0&&(Y=_.onCaughtError),_.onRecoverableError!==void 0&&(le=_.onRecoverableError),_.formState!==void 0&&(Ee=_.formState)),p=B5(h,1,!0,p,_??null,w,P,Ee,j,Y,le,Q5),p.context=H5(null),_=p.current,w=ls(),w=si(w),P=Yc(w),P.callback=null,Zc(_,P,w),_=w,p.current.lanes=_,Qt(p,_),Ko(p),h[mo]=p.current,eA(h),new uv(p)},rx.version="19.2.0",rx}var cF;function jre(){if(cF)return wA.exports;cF=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wA.exports=Dre(),wA.exports}var Ore=jre();const qt=t=>typeof t=="string",ix=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},uF=t=>t==null?"":""+t,Lre=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Ire=/###/g,dF=t=>t&&t.indexOf("###")>-1?t.replace(Ire,"."):t,hF=t=>!t||qt(t),Gx=(t,e,n)=>{const r=qt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(hF(t))return{};const a=dF(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return hF(t)?{}:{obj:t,k:dF(r[i])}},fF=(t,e,n)=>{const{obj:r,k:i}=Gx(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],s=e.slice(0,e.length-1),o=Gx(t,s,Object);for(;o.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),o=Gx(t,s,Object),o?.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=n},Fre=(t,e,n,r)=>{const{obj:i,k:a}=Gx(t,e,Object);i[a]=i[a]||[],i[a].push(n)},_1=(t,e)=>{const{obj:n,k:r}=Gx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Ure=(t,e,n)=>{const r=_1(t,n);return r!==void 0?r:_1(e,n)},w9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?qt(t[r])||t[r]instanceof String||qt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):w9(t[r],e[r],n):t[r]=e[r]);return t},Kf=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var zre={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Bre=t=>qt(t)?t.replace(/[&<>"'\/]/g,e=>zre[e]):t;class Hre{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 $re=[" ",",","?","!",";"],Vre=new Hre(20),Gre=(t,e,n)=>{e=e||"",n=n||"";const r=$re.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=Vre.getRegExp(`(${r.map(s=>s==="?"?"\\?":s).join("|")})`);let a=!i.test(t);if(!a){const s=t.indexOf(n);s>0&&!i.test(t.substring(0,s))&&(a=!0)}return a},xk=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let s,o="";for(let c=a;c<r.length;++c)if(c!==a&&(o+=n),o+=r[c],s=i[o],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=s}return i},p0=t=>t?.replace("_","-"),Wre={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 w1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Wre,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:(qt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new w1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new w1(this.logger,e)}}var al=new w1;let jS=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 s=0;s<a;s++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i.apply(i,[e,...n])})}};class pF extends jS{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,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],r&&(Array.isArray(r)?o.push(...r):qt(r)&&a?o.push(...r.split(a)):o.push(r)));const c=_1(this.data,o);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),c||!s||!qt(r)?c:xk(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),fF(this.data,o,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(qt(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,s={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let c=_1(this.data,o)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?w9(c,r,a):c={...c,...r},fF(this.data,o,c),s.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 S9={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 M9=Symbol("i18next/PATH_KEY");function qre(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===M9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function bk(t,e){const{[M9]:n}=t(qre());return n.join(e?.keySeparator??".")}const mF={},AA=t=>!qt(t)&&typeof t!="boolean"&&typeof t!="number";class S1 extends jS{constructor(e,n={}){super(),Lre(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=al.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=AA(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 s=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Gre(e,r,i);if(s&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:qt(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:qt(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=bk(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${u}${d}${o}`,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${o}`:a?{res:o,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let b=m?.res;const y=m?.usedKey||o,v=m?.exactUsedKey||o,x=["[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&&!qt(i.count),T=S1.hasDefaultValue(i),k=A?this.pluralResolver.getSuffix(f,i.count,i):"",N=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",I=A&&!i.ordinal&&i.count===0,C=I&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${N}`]||i.defaultValue;let D=b;S&&!b&&T&&(D=C);const F=AA(D),O=Object.prototype.toString.apply(D);if(S&&D&&F&&x.indexOf(O)<0&&!(qt(M)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,D,{...i,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return a?(m.res=q,m.usedParams=this.getUsedParamsDetails(i),m):q}if(s){const q=Array.isArray(D),R=q?[]:{},W=q?v:y;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const G=`${W}${s}${K}`;T&&!b?R[K]=this.translate(G,{...i,defaultValue:AA(C)?C[K]:void 0,joinArrays:!1,ns:c}):R[K]=this.translate(G,{...i,joinArrays:!1,ns:c}),R[K]===G&&(R[K]=D[K])}b=R}}else if(S&&qt(M)&&Array.isArray(b))b=b.join(M),b&&(b=this.extendTranslation(b,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(b)&&T&&(q=!0,b=C),this.isValidLookup(b)||(R=!0,b=o);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:b,G=T&&C!==b&&this.options.updateMissing;if(R||q||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,o,G?C:b),s){const U=this.resolve(o,{...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 ee=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let U=0;U<Z.length;U++)ee.push(Z[U]);else this.options.saveMissingTo==="all"?ee=this.languageUtils.toResolveHierarchy(i.lng||this.language):ee.push(i.lng||this.language);const Q=(U,$,X)=>{const te=T&&X!==b?X:K;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,$,te,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,$,te,G,i),this.emit("missingKey",U,u,$,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?ee.forEach(U=>{const $=this.pluralResolver.getSuffixes(U,i);I&&i[`defaultValue${this.options.pluralSeparator}zero`]&&$.indexOf(`${this.options.pluralSeparator}zero`)<0&&$.push(`${this.options.pluralSeparator}zero`),$.forEach(X=>{Q([U],o+X,i[`defaultValue${X}`]||C)})}):Q(ee,o,C))}b=this.extendTranslation(b,e,i,m,r),R&&b===o&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${o}`),(R||q)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${o}`:o,q?b:void 0,i))}return a?(m.res=b,m.usedParams=this.getUsedParamsDetails(i),m):b}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=qt(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&&!qt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const s=r.postProcess||this.options.postProcess,o=qt(s)?[s]:s;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=S9.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,s,o;return qt(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!qt(n.count),m=g&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(qt(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(o=v,!mF[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(mF[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(x=>{if(this.isValidLookup(r))return;s=x;const M=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,d,x,v,n);else{let A;g&&(A=this.pluralResolver.getSuffix(x,n.count,n));const T=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&A.indexOf(k)===0&&M.push(d+A.replace(k,this.options.pluralSeparator)),M.push(d+A),m&&M.push(d+T)),b){const N=`${d}${this.options.contextSeparator||"_"}${n.context}`;M.push(N),g&&(n.ordinal&&A.indexOf(k)===0&&M.push(N+A.replace(k,this.options.pluralSeparator)),M.push(N+A),m&&M.push(N+T))}}let S;for(;S=M.pop();)this.isValidLookup(r)||(a=S,r=this.getResource(x,v,S,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:s,usedNS:o}}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&&!qt(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 gF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=al.create("languageUtils")}getScriptPartFromCode(e){if(e=p0(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=p0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(qt(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(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),qt(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=s=>{s&&(this.isSupportedCode(s)?i.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return qt(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))):qt(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const xF={zero:0,one:1,two:2,few:3,many:4,other:5},bF={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Kre{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=al.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=p0(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 s;try{s=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),bF;if(!e.match(/-|_/))return bF;const c=this.languageUtils.getLanguagePartFromCode(e);s=this.getRule(c,n)}return this.pluralRulesCache[a]=s,s}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)=>xF[i]-xF[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 yF=(t,e,n,r=".",i=!0)=>{let a=Ure(t,e,n);return!a&&i&&qt(n)&&(a=xk(t,n,r),a===void 0&&(a=xk(e,n,r))),a},TA=t=>t.replace(/\$/g,"$$$$");class Xre{constructor(e={}){this.logger=al.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:s,suffix:o,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:b,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:Bre,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Kf(a):s||"{{",this.suffix=o?Kf(o):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?Kf(g):m||Kf("$t("),this.nestingSuffix=b?Kf(b):y||Kf(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||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,s,o;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const x=yF(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:m}):x}const b=m.split(this.formatSeparator),y=b.shift().trim(),v=b.join(this.formatSeparator).trim();return this.format(yF(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>TA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?TA(this.escape(m)):TA(m)}].forEach(m=>{for(o=0;a=m.regex.exec(e);){const b=a[1].trim();if(s=u(b),s===void 0)if(typeof d=="function"){const v=d(e,a,i);s=qt(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),s="";else!qt(s)&&!this.useRawValueToEscape&&(s=uF(s));const y=m.safeValue(s);if(e=e.replace(a[0],y),f?(m.regex.lastIndex+=s.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,s;const o=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;c=f[0],g=this.interpolate(g,s);const m=g.match(/'/g),b=g.match(/"/g);((m?.length??0)%2===0&&!b||b.length%2!==0)&&(g=g.replace(/'/g,'"'));try{s=JSON.parse(g),u&&(s={...u,...s})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${g}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];s={...r},s=s.replace&&!qt(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.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(o.call(this,i[1].trim(),s),s),a&&i[0]===e&&!qt(a))return a;qt(a)||(a=uF(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 Yre=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(s=>{if(s){const[o,...c]=s.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=o.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}},vF=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 s=r+JSON.stringify(a);let o=e[s];return o||(o=t(p0(r),i),e[s]=o),o(n)}},Zre=t=>(e,n,r)=>t(p0(n),r)(e);class Qre{constructor(e={}){this.logger=al.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?vF:Zre;this.formats={number:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a});return o=>s.format(o)}),currency:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a,style:"currency"});return o=>s.format(o)}),datetime:r((i,a)=>{const s=new Intl.DateTimeFormat(i,{...a});return o=>s.format(o)}),relativetime:r((i,a)=>{const s=new Intl.RelativeTimeFormat(i,{...a});return o=>s.format(o,a.range||"day")}),list:r((i,a)=>{const s=new Intl.ListFormat(i,{...a});return o=>s.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=vF(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(o=>o.indexOf(")")>-1)){const o=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,c)=>{const{formatName:u,formatOptions:d}=Yre(c);if(this.formats[u]){let f=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},m=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[u](o,m,{...d,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const Jre=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class eie extends jS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=al.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={},s={},o={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?s[g]===void 0&&(s[g]=!0):(this.state[g]=1,d=!1,s[g]===void 0&&(s[g]=!0),a[g]===void 0&&(a[g]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(o[u]=!0)}),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],s=i[1];n&&this.emit("failedLoading",a,s,n),!n&&r&&this.store.addResourceBundle(a,s,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const o={};this.queue.forEach(c=>{Fre(c.loaded,[a],s),Jre(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{o[u]||(o[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{o[u][f]===void 0&&(o[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,s){if(!e.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:s});return}this.readingCalls++;const o=(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,s)},a);return}s(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=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}return}return c(e,n,o)}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();qt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),qt(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(s=>{this.loadOne(s)})}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,(s,o)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,s),!s&&o&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,o),this.loaded(e,s,o)})}saveMissing(e,n,r,i,a,s={},o=()=>{}){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={...s,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=>o(null,f)).catch(o):o(null,d)}catch(d){o(d)}else u(e,n,r,i,o,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const _F=()=>({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]),qt(t[1])&&(e.defaultValue=t[1]),qt(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}),wF=t=>(qt(t.ns)&&(t.ns=[t.ns]),qt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),qt(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),fv=()=>{},tie=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Wx extends jS{constructor(e={},n){if(super(),this.options=wF(e),this.services={},this.logger=al,this.modules={external:[]},tie(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&&(qt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=_F();this.options={...r,...this.options,...wF(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?al.init(i(this.modules.logger),this.options):al.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Qre;const d=new gF(this.options);this.store=new pF(this.options.resources,this.options);const f=this.services;f.logger=al,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Kre(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 Xre(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new eie(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new S1(this.services,this.options),this.translator.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=fv),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 o=ix(),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),o.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),o}loadResources(e,n=fv){let r=n;const i=qt(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=[],s=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>s(c)),this.options.preload?.forEach?.(o=>s(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=ix();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=fv),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"&&S9.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=ix();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},a=(o,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(o,(...u)=>this.t(...u))},s=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const c=qt(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(qt(o)?[o]:o);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?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),r}getFixedT(e,n,r){const i=(a,s,...o)=>{let c;typeof s!="object"?c=this.options.overloadTranslationOptionHandler([a,s].concat(o)):c={...s},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=bk(f,{...this.options,...s})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=bk(a,{...this.options,...s})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return qt(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 s=(o,c)=>{const u=this.services.backendConnector.state[`${o}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const o=n.precheck(this,s);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,e)&&(!i||s(a,e)))}loadNamespaces(e,n){const r=ix();return this.options.ns?(qt(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=ix();qt(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(s=>i.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return a.length?(this.options.preload=i.concat(a),this.loadResources(s=>{r.resolve(),n&&n(s)}),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 gF(_F());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 Wx(e,n);return r.createInstance=Wx.createInstance,r}cloneInstance(e={},n=fv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new Wx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const o=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 pF(o,i),a.services.resourceStore=a.store}return a.translator=new S1(a.services,i),a.translator.on("*",(o,...c)=>{a.emit(o,...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 Da=Wx.createInstance();Da.createInstance;Da.dir;Da.init;Da.loadResources;Da.reloadResources;Da.use;Da.changeLanguage;Da.getFixedT;Da.t;Da.exists;Da.setDefaultNamespace;Da.hasLoadedNamespace;Da.loadNamespaces;Da.loadLanguages;const nie=(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);Ih(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},SF={},E9=(t,e,n,r)=>{Ih(n)&&SF[n]||(Ih(n)&&(SF[n]=new Date),nie(t,e,n,r))},A9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},yk=(t,e,n)=>{t.loadNamespaces(e,A9(t,n))},MF=(t,e,n,r)=>{if(Ih(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return yk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,A9(t,r))},rie=(t,e,n={})=>!e.languages||!e.languages.length?(E9(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}}),Ih=t=>typeof t=="string",iie=t=>typeof t=="object"&&t!==null,aie=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,sie={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},oie=t=>sie[t],lie=t=>t.replace(aie,oie);let vk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:lie};const cie=(t={})=>{vk={...vk,...t}},uie=()=>vk;let T9;const die=t=>{T9=t},hie=()=>T9,fie={type:"3rdParty",init(t){cie(t.options.react),die(t)}},pie=E.createContext();class mie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var CA={exports:{}},NA={};var EF;function gie(){if(EF)return NA;EF=1;var t=$m();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function o(f,g){var m=g(),b=r({inst:{value:m,getSnapshot:g}}),y=b[0].inst,v=b[1];return a(function(){y.value=m,y.getSnapshot=g,c(y)&&v({inst:y})},[f,m,g]),i(function(){return c(y)&&v({inst:y}),f(function(){c(y)&&v({inst:y})})},[f]),s(m),m}function c(f){var g=f.getSnapshot;f=f.value;try{var m=g();return!n(f,m)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:o;return NA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,NA}var AF;function C9(){return AF||(AF=1,CA.exports=gie()),CA.exports}var CR=C9();const xie=(t,e)=>Ih(e)?e:iie(e)&&Ih(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,bie={t:xie,ready:!1},yie=()=>()=>{},Vm=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=E.useContext(pie)||{},a=n||r||hie();a&&!a.reportNamespaces&&(a.reportNamespaces=new mie),a||E9(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=E.useMemo(()=>({...uie(),...a?.options?.react,...e}),[a,e]),{useSuspense:o,keyPrefix:c}=s,u=i||a?.options?.defaultNS,d=Ih(u)?[u]:u||["translation"],f=E.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const g=E.useRef(0),m=E.useCallback(C=>{if(!a)return yie;const{bindI18n:D,bindI18nStore:F}=s,O=()=>{g.current+=1,C()};return D&&a.on(D,O),F&&a.store.on(F,O),()=>{D&&D.split(" ").forEach(q=>a.off(q,O)),F&&F.split(" ").forEach(q=>a.store.off(q,O))}},[a,s]),b=E.useRef(),y=E.useCallback(()=>{if(!a)return bie;const C=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>rie(W,a,s)),D=e.lng||a.language,F=g.current,O=b.current;if(O&&O.ready===C&&O.lng===D&&O.keyPrefix===c&&O.revision===F)return O;const R={t:a.getFixedT(D,s.nsMode==="fallback"?f:f[0],c),ready:C,lng:D,keyPrefix:c,revision:F};return b.current=R,R},[a,f,c,s,e.lng]),[v,x]=E.useState(0),{t:M,ready:S}=CR.useSyncExternalStore(m,y,y);E.useEffect(()=>{if(a&&!S&&!o){const C=()=>x(D=>D+1);e.lng?MF(a,e.lng,f,C):yk(a,f,C)}},[a,e.lng,f,S,o,v]);const A=a||{},T=E.useRef(null),k=E.useRef(),N=C=>{const D=Object.getOwnPropertyDescriptors(C);D.__original&&delete D.__original;const F=Object.create(Object.getPrototypeOf(C),D);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},I=E.useMemo(()=>{const C=A,D=C?.language;let F=C;C&&(T.current&&T.current.__original===C?k.current!==D?(F=N(C),T.current=F,k.current=D):F=T.current:(F=N(C),T.current=F,k.current=D));const O=[M,F,S];return O.t=M,O.i18n=F,O.ready=S,O},[M,A,S,A.resolvedLanguage,A.language,A.languages]);if(a&&o&&!S)throw new Promise(C=>{const D=()=>C();e.lng?MF(a,e.lng,f,D):yk(a,f,D)});return I},{slice:vie,forEach:_ie}=[];function wie(t){return _ie.call(vie.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Sie(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 TF=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Mie=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 s=r.maxAge-0;if(Number.isNaN(s))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(s)}`}if(r.domain){if(!TF.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!TF.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},CF={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=Mie(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 Eie={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return CF.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&CF.create(n,t,r,i,a)}},Aie={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 s=0;s<a.length;s++){const o=a[s].indexOf("=");o>0&&a[s].substring(0,o)===e&&(n=a[s].substring(o+1))}}return n}},Tie={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 s=a.split("&");for(let o=0;o<s.length;o++){const c=s[o].indexOf("=");c>0&&s[o].substring(0,c)===e&&(r=s[o].substring(c+1))}}if(r)return r;if(!r&&n>-1){const s=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(s)?s[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let Xf=null;const NF=()=>{if(Xf!==null)return Xf;try{if(Xf=typeof window<"u"&&window.localStorage!==null,!Xf)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Xf=!1}return Xf};var Cie={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&NF())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&NF()&&window.localStorage.setItem(n,t)}};let Yf=null;const kF=()=>{if(Yf!==null)return Yf;try{if(Yf=typeof window<"u"&&window.sessionStorage!==null,!Yf)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Yf=!1}return Yf};var Nie={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&kF())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&kF()&&window.sessionStorage.setItem(n,t)}},kie={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}},Pie={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}},Rie={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}},Die={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 N9=!1;try{document.cookie,N9=!0}catch{}const k9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];N9||k9.splice(1,1);const jie=()=>({order:k9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class P9{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=wie(n,this.options||{},jie()),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(Eie),this.addDetector(Aie),this.addDetector(Cie),this.addDetector(Nie),this.addDetector(kie),this.addDetector(Pie),this.addDetector(Rie),this.addDetector(Die),this.addDetector(Tie)}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&&!Sie(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)}))}}P9.type="languageDetector";const Oie={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app and which versions 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:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"IP addresses or location data",telemetryInfoNotItem2:"Printer names, serial numbers, or any printer data",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?"}},Lie={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},Iie={en:{translation:Oie},de:{translation:Lie}};Da.use(P9).use(fie).init({resources:Iie,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const PF=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var RF="popstate";function Fie(t={}){function e(r,i){let{pathname:a,search:s,hash:o}=r.location;return _k("",{pathname:a,search:s,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:m0(i)}return zie(e,n,null,t)}function vr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Fo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Uie(){return Math.random().toString(36).substring(2,10)}function DF(t,e){return{usr:t.state,key:t.key,idx:e}}function _k(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Gm(e):e,state:n,key:e&&e.key||r||Uie()}}function m0({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 Gm(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 zie(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,s=i.history,o="POP",c=null,u=d();u==null&&(u=0,s.replaceState({...s.state,idx:u},""));function d(){return(s.state||{idx:null}).idx}function f(){o="POP";let v=d(),x=v==null?null:v-u;u=v,c&&c({action:o,location:y.location,delta:x})}function g(v,x){o="PUSH";let M=_k(y.location,v,x);u=d()+1;let S=DF(M,u),A=y.createHref(M);try{s.pushState(S,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}a&&c&&c({action:o,location:y.location,delta:1})}function m(v,x){o="REPLACE";let M=_k(y.location,v,x);u=d();let S=DF(M,u),A=y.createHref(M);s.replaceState(S,"",A),a&&c&&c({action:o,location:y.location,delta:0})}function b(v){return Bie(v)}let y={get action(){return o},get location(){return t(i,s)},listen(v){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(RF,f),c=v,()=>{i.removeEventListener(RF,f),c=null}},createHref(v){return e(i,v)},createURL:b,encodeLocation(v){let x=b(v);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:g,replace:m,go(v){return s.go(v)}};return y}function Bie(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),vr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:m0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function R9(t,e,n="/"){return Hie(t,e,n,!1)}function Hie(t,e,n,r){let i=typeof e=="string"?Gm(e):e,a=Tc(i.pathname||"/",n);if(a==null)return null;let s=D9(t);$ie(s);let o=null;for(let c=0;o==null&&c<s.length;++c){let u=eae(a);o=Qie(s[c],u,r)}return o}function D9(t,e=[],n=[],r="",i=!1){let a=(s,o,c=i,u)=>{let d={relativePath:u===void 0?s.path||"":u,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;vr(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=yc([r,d.relativePath]),g=n.concat(d);s.children&&s.children.length>0&&(vr(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),D9(s.children,e,g,f,c)),!(s.path==null&&!s.index)&&e.push({path:f,score:Yie(f,s.index),routesMeta:g})};return t.forEach((s,o)=>{if(s.path===""||!s.path?.includes("?"))a(s,o);else for(let c of j9(s.path))a(s,o,!0,c)}),e}function j9(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 s=j9(r.join("/")),o=[];return o.push(...s.map(c=>c===""?a:[a,c].join("/"))),i&&o.push(...s),o.map(c=>t.startsWith("/")&&c===""?"/":c)}function $ie(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Zie(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Vie=/^:[\w-]+$/,Gie=3,Wie=2,qie=1,Kie=10,Xie=-2,jF=t=>t==="*";function Yie(t,e){let n=t.split("/"),r=n.length;return n.some(jF)&&(r+=Xie),e&&(r+=Wie),n.filter(i=>!jF(i)).reduce((i,a)=>i+(Vie.test(a)?Gie:a===""?qie:Kie),r)}function Zie(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 Qie(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",s=[];for(let o=0;o<r.length;++o){let c=r[o],u=o===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=M1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=M1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),s.push({params:i,pathname:yc([a,f.pathname]),pathnameBase:aae(yc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=yc([a,f.pathnameBase]))}return s}function M1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Jie(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],s=a.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let b=o[g]||"";s=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const m=o[g];return f&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:s,pattern:t}}function Jie(t,e=!1,n=!0){Fo(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,(s,o,c)=>(r.push({paramName:o,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 eae(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Fo(!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 Tc(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 tae=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nae=t=>tae.test(t);function rae(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Gm(t):t,a;if(n)if(nae(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Fo(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=OF(n.substring(1),"/"):a=OF(n,e)}else a=e;return{pathname:a,search:sae(r),hash:oae(i)}}function OF(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 kA(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 iae(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function O9(t){let e=iae(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function L9(t,e,n,r=!1){let i;typeof t=="string"?i=Gm(t):(i={...t},vr(!i.pathname||!i.pathname.includes("?"),kA("?","pathname","search",i)),vr(!i.pathname||!i.pathname.includes("#"),kA("#","pathname","hash",i)),vr(!i.search||!i.search.includes("#"),kA("#","search","hash",i)));let a=t===""||i.pathname==="",s=a?"/":i.pathname,o;if(s==null)o=n;else{let f=e.length-1;if(!r&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}o=f>=0?e[f]:"/"}let c=rae(i,o),u=s&&s!=="/"&&s.endsWith("/"),d=(a||s===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var yc=t=>t.join("/").replace(/\/\/+/g,"/"),aae=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),sae=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,oae=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function lae(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 I9=["POST","PUT","PATCH","DELETE"];new Set(I9);var cae=["GET",...I9];new Set(cae);var Wm=E.createContext(null);Wm.displayName="DataRouter";var OS=E.createContext(null);OS.displayName="DataRouterState";E.createContext(!1);var F9=E.createContext({isTransitioning:!1});F9.displayName="ViewTransition";var uae=E.createContext(new Map);uae.displayName="Fetchers";var dae=E.createContext(null);dae.displayName="Await";var _l=E.createContext(null);_l.displayName="Navigation";var fb=E.createContext(null);fb.displayName="Location";var Bo=E.createContext({outlet:null,matches:[],isDataRoute:!1});Bo.displayName="Route";var NR=E.createContext(null);NR.displayName="RouteError";function hae(t,{relative:e}={}){vr(pb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=E.useContext(_l),{hash:i,pathname:a,search:s}=mb(t,{relative:e}),o=a;return n!=="/"&&(o=a==="/"?n:yc([n,a])),r.createHref({pathname:o,search:s,hash:i})}function pb(){return E.useContext(fb)!=null}function xd(){return vr(pb(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(fb).location}var U9="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function z9(t){E.useContext(_l).static||E.useLayoutEffect(t)}function kR(){let{isDataRoute:t}=E.useContext(Bo);return t?Tae():fae()}function fae(){vr(pb(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(Wm),{basename:e,navigator:n}=E.useContext(_l),{matches:r}=E.useContext(Bo),{pathname:i}=xd(),a=JSON.stringify(O9(r)),s=E.useRef(!1);return z9(()=>{s.current=!0}),E.useCallback((c,u={})=>{if(Fo(s.current,U9),!s.current)return;if(typeof c=="number"){n.go(c);return}let d=L9(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:yc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var pae=E.createContext(null);function mae(t){let e=E.useContext(Bo).outlet;return E.useMemo(()=>e&&E.createElement(pae.Provider,{value:t},e),[e,t])}function B9(){let{matches:t}=E.useContext(Bo),e=t[t.length-1];return e?e.params:{}}function mb(t,{relative:e}={}){let{matches:n}=E.useContext(Bo),{pathname:r}=xd(),i=JSON.stringify(O9(n));return E.useMemo(()=>L9(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function gae(t,e){return H9(t,e)}function H9(t,e,n,r,i){vr(pb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=E.useContext(_l),{matches:s}=E.useContext(Bo),o=s[s.length-1],c=o?o.params:{},u=o?o.pathname:"/",d=o?o.pathnameBase:"/",f=o&&o.route;{let M=f&&f.path||"";$9(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 g=xd(),m;if(e){let M=typeof e=="string"?Gm(e):e;vr(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.`),m=M}else m=g;let b=m.pathname||"/",y=b;if(d!=="/"){let M=d.replace(/^\//,"").split("/");y="/"+b.replace(/^\//,"").split("/").slice(M.length).join("/")}let v=R9(t,{pathname:y});Fo(f||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Fo(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=_ae(v&&v.map(M=>Object.assign({},M,{params:Object.assign({},c,M.params),pathname:yc([d,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?d:yc([d,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),s,n,r,i);return e&&x?E.createElement(fb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function xae(){let t=Aae(),e=lae(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},s=null;return console.error("Error handled by React Router default ErrorBoundary:",t),s=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:a},"ErrorBoundary")," or"," ",E.createElement("code",{style:a},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:i},n):null,s)}var bae=E.createElement(xae,null),yae=class extends E.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?E.createElement(Bo.Provider,{value:this.props.routeContext},E.createElement(NR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function vae({routeContext:t,match:e,children:n}){let r=E.useContext(Wm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(Bo.Provider,{value:t},n)}function _ae(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,s=n?.errors;if(s!=null){let d=a.findIndex(f=>f.route.id&&s?.[f.route.id]!==void 0);vr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:g,errors:m}=n,b=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||b){o=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,g)=>{let m,b=!1,y=null,v=null;n&&(m=s&&f.route.id?s[f.route.id]:void 0,y=f.route.errorElement||bae,o&&(c<0&&g===0?($9("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):c===g&&(b=!0,v=f.route.hydrateFallbackElement||null)));let x=e.concat(a.slice(0,g+1)),M=()=>{let S;return m?S=y:b?S=v:f.route.Component?S=E.createElement(f.route.Component,null):f.route.element?S=f.route.element:S=d,E.createElement(vae,{match:f,routeContext:{outlet:d,matches:x,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?E.createElement(yae,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:M(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:u}):M()},null)}function PR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wae(t){let e=E.useContext(Wm);return vr(e,PR(t)),e}function Sae(t){let e=E.useContext(OS);return vr(e,PR(t)),e}function Mae(t){let e=E.useContext(Bo);return vr(e,PR(t)),e}function RR(t){let e=Mae(t),n=e.matches[e.matches.length-1];return vr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Eae(){return RR("useRouteId")}function Aae(){let t=E.useContext(NR),e=Sae("useRouteError"),n=RR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Tae(){let{router:t}=wae("useNavigate"),e=RR("useNavigate"),n=E.useRef(!1);return z9(()=>{n.current=!0}),E.useCallback(async(i,a={})=>{Fo(n.current,U9),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var LF={};function $9(t,e,n){!e&&!LF[t]&&(LF[t]=!0,Fo(!1,n))}E.memo(Cae);function Cae({routes:t,future:e,state:n,unstable_onError:r}){return H9(t,void 0,n,r,e)}function Nae(t){return mae(t.context)}function fs(t){vr(!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 kae({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){vr(!pb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),o=E.useMemo(()=>({basename:s,navigator:i,static:a,future:{}}),[s,i,a]);typeof n=="string"&&(n=Gm(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,m=E.useMemo(()=>{let b=Tc(c,s);return b==null?null:{location:{pathname:b,search:u,hash:d,state:f,key:g},navigationType:r}},[s,c,u,d,f,g,r]);return Fo(m!=null,`<Router basename="${s}"> 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.`),m==null?null:E.createElement(_l.Provider,{value:o},E.createElement(fb.Provider,{children:e,value:m}))}function Pae({children:t,location:e}){return gae(wk(t),e)}function wk(t,e=[]){let n=[];return E.Children.forEach(t,(r,i)=>{if(!E.isValidElement(r))return;let a=[...e,i];if(r.type===E.Fragment){n.push.apply(n,wk(r.props.children,a));return}vr(r.type===fs,`[${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>`),vr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={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&&(s.children=wk(r.props.children,a)),n.push(s)}),n}var Z_="get",Q_="application/x-www-form-urlencoded";function LS(t){return t!=null&&typeof t.tagName=="string"}function Rae(t){return LS(t)&&t.tagName.toLowerCase()==="button"}function Dae(t){return LS(t)&&t.tagName.toLowerCase()==="form"}function jae(t){return LS(t)&&t.tagName.toLowerCase()==="input"}function Oae(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Lae(t,e){return t.button===0&&(!e||e==="_self")&&!Oae(t)}var pv=null;function Iae(){if(pv===null)try{new FormData(document.createElement("form"),0),pv=!1}catch{pv=!0}return pv}var Fae=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function PA(t){return t!=null&&!Fae.has(t)?(Fo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Q_}"`),null):t}function Uae(t,e){let n,r,i,a,s;if(Dae(t)){let o=t.getAttribute("action");r=o?Tc(o,e):null,n=t.getAttribute("method")||Z_,i=PA(t.getAttribute("enctype"))||Q_,a=new FormData(t)}else if(Rae(t)||jae(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||o.getAttribute("action");if(r=c?Tc(c,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||Z_,i=PA(t.getAttribute("formenctype"))||PA(o.getAttribute("enctype"))||Q_,a=new FormData(o,t),!Iae()){let{name:u,type:d,value:f}=t;if(d==="image"){let g=u?`${u}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else u&&a.append(u,f)}}else{if(LS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Z_,r=null,i=Q_,s=t}return a&&i==="text/plain"&&(s=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function DR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function zae(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&&Tc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Bae(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 Hae(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 $ae(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await Bae(a,n);return s.links?s.links():[]}return[]}));return qae(r.flat(1).filter(Hae).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function IF(t,e,n,r,i,a){let s=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,o=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>s(c,u)||o(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(s(c,u)||o(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 Vae(t,e,{includeHydrateFallback:n}={}){return Gae(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 Gae(t){return[...new Set(t)]}function Wae(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function qae(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Wae(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function V9(){let t=E.useContext(Wm);return DR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Kae(){let t=E.useContext(OS);return DR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var jR=E.createContext(void 0);jR.displayName="FrameworkContext";function G9(){let t=E.useContext(jR);return DR(t,"You must render this element inside a <HydratedRouter> element"),t}function Xae(t,e){let n=E.useContext(jR),[r,i]=E.useState(!1),[a,s]=E.useState(!1),{onFocus:o,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=E.useRef(null);E.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let y=x=>{x.forEach(M=>{s(M.isIntersecting)})},v=new IntersectionObserver(y,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.disconnect()}}},[t]),E.useEffect(()=>{if(r){let y=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},b=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:ax(o,m),onBlur:ax(c,b),onMouseEnter:ax(u,m),onMouseLeave:ax(d,b),onTouchStart:ax(f,m)}]:[!1,g,{}]}function ax(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Yae({page:t,...e}){let{router:n}=V9(),r=E.useMemo(()=>R9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?E.createElement(Qae,{page:t,matches:r,...e}):null}function Zae(t){let{manifest:e,routeModules:n}=G9(),[r,i]=E.useState([]);return E.useEffect(()=>{let a=!1;return $ae(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function Qae({page:t,matches:e,...n}){let r=xd(),{manifest:i,routeModules:a}=G9(),{basename:s}=V9(),{loaderData:o,matches:c}=Kae(),u=E.useMemo(()=>IF(t,e,c,i,r,"data"),[t,e,c,i,r]),d=E.useMemo(()=>IF(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=E.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,y=!1;if(e.forEach(x=>{let M=i.routes[x.route.id];!M||!M.hasLoader||(!u.some(S=>S.route.id===x.route.id)&&x.route.id in o&&a[x.route.id]?.shouldRevalidate||M.hasClientLoader?y=!0:b.add(x.route.id))}),b.size===0)return[];let v=zae(t,s,"data");return y&&b.size>0&&v.searchParams.set("_routes",e.filter(x=>b.has(x.route.id)).map(x=>x.route.id).join(",")),[v.pathname+v.search]},[s,o,r,i,u,e,t,a]),g=E.useMemo(()=>Vae(d,i),[d,i]),m=Zae(d);return E.createElement(E.Fragment,null,f.map(b=>E.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),g.map(b=>E.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),m.map(({key:b,link:y})=>E.createElement("link",{key:b,nonce:n.nonce,...y})))}function Jae(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var W9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{W9&&(window.__reactRouterVersion="7.9.6")}catch{}function ese({basename:t,children:e,window:n}){let r=E.useRef();r.current==null&&(r.current=Fie({window:n,v5Compat:!0}));let i=r.current,[a,s]=E.useState({action:i.action,location:i.location}),o=E.useCallback(c=>{E.startTransition(()=>s(c))},[s]);return E.useLayoutEffect(()=>i.listen(o),[i,o]),E.createElement(kae,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var q9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,IS=E.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:s,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},m){let{basename:b}=E.useContext(_l),y=typeof u=="string"&&q9.test(u),v,x=!1;if(typeof u=="string"&&y&&(v=u,W9))try{let C=new URL(window.location.href),D=u.startsWith("//")?new URL(C.protocol+u):new URL(u),F=Tc(D.pathname,b);D.origin===C.origin&&F!=null?u=F+D.search+D.hash:x=!0}catch{Fo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=hae(u,{relative:i}),[S,A,T]=Xae(r,g),k=rse(u,{replace:s,state:o,target:c,preventScrollReset:d,relative:i,viewTransition:f});function N(C){e&&e(C),C.defaultPrevented||k(C)}let I=E.createElement("a",{...g,...T,href:v||M,onClick:x||a?e:N,ref:Jae(m,A),target:c,"data-discover":!y&&n==="render"?"true":void 0});return S&&!y?E.createElement(E.Fragment,null,I,E.createElement(Yae,{page:M})):I});IS.displayName="Link";var Rx=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:s,viewTransition:o,children:c,...u},d){let f=mb(s,{relative:u.relative}),g=xd(),m=E.useContext(OS),{navigator:b,basename:y}=E.useContext(_l),v=m!=null&&lse(f)&&o===!0,x=b.encodeLocation?b.encodeLocation(f).pathname:f.pathname,M=g.pathname,S=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(M=M.toLowerCase(),S=S?S.toLowerCase():null,x=x.toLowerCase()),S&&y&&(S=Tc(S,y)||S);const A=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let T=M===x||!i&&M.startsWith(x)&&M.charAt(A)==="/",k=S!=null&&(S===x||!i&&S.startsWith(x)&&S.charAt(x.length)==="/"),N={isActive:T,isPending:k,isTransitioning:v},I=T?e:void 0,C;typeof r=="function"?C=r(N):C=[r,T?"active":null,k?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let D=typeof a=="function"?a(N):a;return E.createElement(IS,{...u,"aria-current":I,className:C,ref:d,style:D,to:s,viewTransition:o},typeof c=="function"?c(N):c)});Rx.displayName="NavLink";var tse=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:s=Z_,action:o,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},m)=>{let b=sse(),y=ose(o,{relative:u}),v=s.toLowerCase()==="get"?"get":"post",x=typeof o=="string"&&q9.test(o),M=S=>{if(c&&c(S),S.defaultPrevented)return;S.preventDefault();let A=S.nativeEvent.submitter,T=A?.getAttribute("formmethod")||s;b(A||S.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return E.createElement("form",{ref:m,method:v,action:y,onSubmit:r?c:M,...g,"data-discover":!x&&t==="render"?"true":void 0})});tse.displayName="Form";function nse(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function K9(t){let e=E.useContext(Wm);return vr(e,nse(t)),e}function rse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let o=kR(),c=xd(),u=mb(t,{relative:a});return E.useCallback(d=>{if(Lae(d,e)){d.preventDefault();let f=n!==void 0?n:m0(c)===m0(u);o(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:s})}},[c,o,u,n,r,e,t,i,a,s])}var ise=0,ase=()=>`__${String(++ise)}__`;function sse(){let{router:t}=K9("useSubmit"),{basename:e}=E.useContext(_l),n=Eae();return E.useCallback(async(r,i={})=>{let{action:a,method:s,encType:o,formData:c,body:u}=Uae(r,e);if(i.navigate===!1){let d=i.fetcherKey||ase();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function ose(t,{relative:e}={}){let{basename:n}=E.useContext(_l),r=E.useContext(Bo);vr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...mb(t||".",{relative:e})},s=xd();if(t==null){a.search=s.search;let o=new URLSearchParams(a.search),c=o.getAll("index");if(c.some(d=>d==="")){o.delete("index"),c.filter(f=>f).forEach(f=>o.append("index",f));let d=o.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:yc([n,a.pathname])),m0(a)}function lse(t,{relative:e}={}){let n=E.useContext(F9);vr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=K9("useViewTransitionState"),i=mb(t,{relative:e});if(!n.isTransitioning)return!1;let a=Tc(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=Tc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return M1(i.pathname,s)!=null||M1(i.pathname,a)!=null}var hc=_9();const cse=fo(hc);var qm=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(){}},use={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},dse=class{#e=use;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},fh=new dse;function hse(t){setTimeout(t,0)}var Fh=typeof window>"u"||"Deno"in globalThis;function wa(){}function fse(t,e){return typeof t=="function"?t(e):t}function Sk(t){return typeof t=="number"&&t>=0&&t!==1/0}function X9(t,e){return Math.max(t+(e||0)-Date.now(),0)}function qu(t,e){return typeof t=="function"?t(e):t}function Ws(t,e){return typeof t=="function"?t(e):t}function FF(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:o}=t;if(s){if(r){if(e.queryHash!==OR(s,e.options))return!1}else if(!g0(e.queryKey,s))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||a&&!a(e))}function UF(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Uh(e.options.mutationKey)!==Uh(a))return!1}else if(!g0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function OR(t,e){return(e?.queryKeyHashFn||Uh)(t)}function Uh(t){return JSON.stringify(t,(e,n)=>Mk(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function g0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>g0(t[n],e[n])):!1}var pse=Object.prototype.hasOwnProperty;function Y9(t,e){if(t===e)return t;const n=zF(t)&&zF(e);if(!n&&!(Mk(t)&&Mk(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,o=n?new Array(s):{};let c=0;for(let u=0;u<s;u++){const d=n?u:a[u],f=t[d],g=e[d];if(f===g){o[d]=f,(n?u<i:pse.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[d]=g;continue}const m=Y9(f,g);o[d]=m,m===f&&c++}return i===s&&c===i?t:o}function E1(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 zF(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Mk(t){if(!BF(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!BF(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function BF(t){return Object.prototype.toString.call(t)==="[object Object]"}function mse(t){return new Promise(e=>{fh.setTimeout(e,t)})}function Ek(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?Y9(t,e):e}function gse(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function xse(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var LR=Symbol();function Z9(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===LR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Q9(t,e){return typeof t=="function"?t(...e):!!t}var bse=class extends qm{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Fh&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},IR=new bse;function Ak(){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 yse=hse;function vse(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=yse;const a=o=>{e?t.push(o):i(()=>{n(o)})},s=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;e++;try{c=o()}finally{e--,e||s()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var hi=vse(),_se=class extends qm{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Fh&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},A1=new _se;function wse(t){return Math.min(1e3*2**t,3e4)}function J9(t){return(t??"online")==="online"?A1.isOnline():!0}var Tk=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function eG(t){let e=!1,n=0,r;const i=Ak(),a=()=>i.status!=="pending",s=y=>{if(!a()){const v=new Tk(y);g(v),t.onCancel?.(v)}},o=()=>{e=!0},c=()=>{e=!1},u=()=>IR.isFocused()&&(t.networkMode==="always"||A1.isOnline())&&t.canRun(),d=()=>J9(t.networkMode)&&t.canRun(),f=y=>{a()||(r?.(),i.resolve(y))},g=y=>{a()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=v=>{(a()||u())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),b=()=>{if(a())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(x){y=Promise.reject(x)}Promise.resolve(y).then(f).catch(x=>{if(a())return;const M=t.retry??(Fh?0:3),S=t.retryDelay??wse,A=typeof S=="function"?S(n,x):S,T=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,x);if(e||!T){g(x);return}n++,t.onFail?.(n,x),mse(A).then(()=>u()?void 0:m()).then(()=>{e?g(x):b()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?b():m().then(b),i)}}var tG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Sk(this.gcTime)&&(this.#e=fh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Fh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(fh.clearTimeout(this.#e),this.#e=void 0)}},Sse=class extends tG{#e;#t;#n;#i;#r;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=$F(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=$F(this.options);e.data!==void 0&&(this.setState(HF(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Ek(this.state.data,t,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#a({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(wa).catch(wa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ws(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===LR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>qu(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:!X9(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(c=>c.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=Z9(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(o,u,this):o(u)},s=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#a({type:"fetch",meta:s.fetchOptions?.meta}),this.#r=eG({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:o=>{o instanceof Tk&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,c)=>{this.#a({type:"failed",failureCount:o,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const o=await this.#r.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof Tk){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#a({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...nG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...HF(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),hi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function nG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:J9(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function HF(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function $F(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 Mse=class extends qm{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=Ak(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#m;#h;#f;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),VF(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ck(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ck(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ws(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),e._defaulted&&!E1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&GF(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Ws(this.options.enabled,this.#t)!==Ws(e.enabled,this.#t)||qu(this.options.staleTime,this.#t)!==qu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Ws(this.options.enabled,this.#t)!==Ws(e.enabled,this.#t)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return Ase(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(wa)),e}#g(){this.#v();const t=qu(this.options.staleTime,this.#t);if(Fh||this.#i.isStale||!Sk(t))return;const n=X9(this.#i.dataUpdatedAt,t)+1;this.#c=fh.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(Fh||Ws(this.options.enabled,this.#t)===!1||!Sk(this.#l)||this.#l===0)&&(this.#u=fh.setInterval(()=>{(this.options.refetchIntervalInBackground||IR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(fh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(fh.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,a=this.#r,s=this.#s,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const I=this.hasListeners(),C=!I&&VF(t,e),D=I&&GF(t,n,e,r);(C||D)&&(d={...d,...nG(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:b,status:y}=d;g=d.data;let v=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(I=i.data,v=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,I!==void 0&&(y="success",g=Ek(i?.data,I,e),f=!0)}if(e.select&&g!==void 0&&!v)if(i&&g===a?.data&&e.select===this.#m)g=this.#h;else try{this.#m=e.select,g=e.select(g),g=Ek(i?.data,g,e),this.#h=g,this.#a=null}catch(I){this.#a=I}this.#a&&(m=this.#a,g=this.#h,b=Date.now(),y="error");const x=d.fetchStatus==="fetching",M=y==="pending",S=y==="error",A=M&&x,T=g!==void 0,N={status:y,fetchStatus:d.fetchStatus,isPending:M,isSuccess:y==="success",isError:S,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:x,isRefetching:x&&!M,isLoadingError:S&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&T,isStale:FR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ws(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=F=>{N.status==="error"?F.reject(N.error):N.data!==void 0&&F.resolve(N.data)},C=()=>{const F=this.#o=N.promise=Ak();I(F)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&I(D);break;case"fulfilled":(N.status==="error"||N.data!==D.value)&&C();break;case"rejected":(N.status!=="error"||N.error!==D.reason)&&C();break}}return N}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#s=this.options,this.#r.data!==void 0&&(this.#f=this.#t),E1(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(s=>{const o=s;return this.#i[o]!==t[o]&&a.has(o)})};this.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){hi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Ese(t,e){return Ws(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function VF(t,e){return Ese(t,e)||t.state.data!==void 0&&Ck(t,e,e.refetchOnMount)}function Ck(t,e,n){if(Ws(e.enabled,t)!==!1&&qu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&FR(t,e)}return!1}function GF(t,e,n,r){return(t!==e||Ws(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&FR(t,n)}function FR(t,e){return Ws(e.enabled,t)!==!1&&t.isStaleByTime(qu(e.staleTime,t))}function Ase(t,e){return!E1(t.getCurrentResult(),e)}function WF(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=Z9(e.options,e.fetchOptions),m=async(b,y,v)=>{if(d)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const M=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return f(k),k})(),S=await g(M),{maxPages:A}=e.options,T=v?xse:gse;return{pages:T(b.pages,S,A),pageParams:T(b.pageParams,y,A)}};if(i&&a.length){const b=i==="backward",y=b?Tse:qF,v={pages:a,pageParams:s},x=y(r,v);o=await m(v,x,b)}else{const b=t??a.length;do{const y=c===0?s[0]??r.initialPageParam:qF(r,o);if(c>0&&y==null)break;o=await m(o,y),c++}while(c<b)}return o};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 qF(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 Tse(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Cse=class extends tG{#e;#t;#n;#i;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||rG(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=eG({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,s)=>{this.#r({type:"failed",failureCount:a,error:s})},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 s=await this.options.onMutate?.(t,n);s!==this.state.context&&this.#r({type:"pending",context:s,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),hi.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function rG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Nse=class extends qm{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const r=new Cse({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=mv(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=mv(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=mv(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=mv(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){hi.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>UF(e,n))}findAll(t={}){return this.getAll().filter(e=>UF(t,e))}notify(t){hi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return hi.batch(()=>Promise.all(t.map(e=>e.continue().catch(wa))))}};function mv(t){return t.options.scope?.id}var kse=class extends qm{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),E1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Uh(n.mutationKey)!==Uh(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#s()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??rG();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){hi.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},Pse=class extends qm{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??OR(r,e);let a=this.get(i);return a||(a=new Sse({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){hi.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>FF(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>FF(t,n)):e}notify(t){hi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){hi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){hi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Rse=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new Pse,this.#t=t.mutationCache||new Nse,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=IR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=A1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(qu(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#e.get(r.queryHash)?.state.data,s=fse(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return hi.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;hi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return hi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=hi.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(wa).catch(wa)}invalidateQueries(t,e={}){return hi.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=hi.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(wa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(wa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(qu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(wa).catch(wa)}fetchInfiniteQuery(t){return t.behavior=WF(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(wa).catch(wa)}ensureInfiniteQueryData(t){return t.behavior=WF(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return A1.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Uh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{g0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Uh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{g0(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=OR(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===LR&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},iG=E.createContext(void 0),En=t=>{const e=E.useContext(iG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Dse=({client:t,children:e})=>(E.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(iG.Provider,{value:t,children:e})),aG=E.createContext(!1),jse=()=>E.useContext(aG);aG.Provider;function Ose(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Lse=E.createContext(Ose()),Ise=()=>E.useContext(Lse),Fse=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Use=t=>{E.useEffect(()=>{t.clearReset()},[t])},zse=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Q9(n,[t.error,r])),Bse=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))}},Hse=(t,e)=>t.isLoading&&t.isFetching&&!e,$se=(t,e)=>t?.suspense&&e.isPending,KF=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Vse(t,e,n){const r=jse(),i=Ise(),a=En(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",Bse(s),Fse(s,i),Use(i);const o=!a.getQueryCache().get(s.queryHash),[c]=E.useState(()=>new e(a,s)),u=c.getOptimisticResult(s),d=!r&&t.subscribed!==!1;if(E.useSyncExternalStore(E.useCallback(f=>{const g=d?c.subscribe(hi.batchCalls(f)):wa;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),E.useEffect(()=>{c.setOptions(s)},[s,c]),$se(s,u))throw KF(s,c,i);if(zse({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(s,u),s.experimental_prefetchInRender&&!Fh&&Hse(u,r)&&(o?KF(s,c,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(wa).finally(()=>{c.updateResult()}),s.notifyOnChangeProps?u:c.trackResult(u)}function vt(t,e){return Vse(t,Mse)}function wt(t,e){const n=En(),[r]=E.useState(()=>new kse(n,t));E.useEffect(()=>{r.setOptions(t)},[r,t]);const i=E.useSyncExternalStore(E.useCallback(s=>r.subscribe(hi.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=E.useCallback((s,o)=>{r.mutate(s,o).catch(wa)},[r]);if(i.error&&Q9(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Gse=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wse=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),XF=t=>{const e=Wse(t);return e.charAt(0).toUpperCase()+e.slice(1)},sG=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),qse=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Kse={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 Xse=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:s,...o},c)=>E.createElement("svg",{ref:c,...Kse,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:sG("lucide",i),...!a&&!qse(o)&&{"aria-hidden":"true"},...o},[...s.map(([u,d])=>E.createElement(u,d)),...Array.isArray(a)?a:[a]]));const qe=(t,e)=>{const n=E.forwardRef(({className:r,...i},a)=>E.createElement(Xse,{ref:a,iconNode:e,className:sG(`lucide-${Gse(XF(t))}`,`lucide-${t}`,r),...i}));return n.displayName=XF(t),n};const Yse=[["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"}]],wh=qe("archive",Yse);const Zse=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],x0=qe("arrow-down",Zse);const Qse=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Nk=qe("arrow-right",Qse);const Jse=[["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"}]],eoe=qe("arrow-up-down",Jse);const toe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],dm=qe("arrow-up",toe);const noe=[["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"}]],Sh=qe("bell",noe);const roe=[["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"}]],ioe=qe("bold",roe);const aoe=[["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"}]],soe=qe("book",aoe);const ooe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],loe=qe("bookmark",ooe);const coe=[["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"}]],hm=qe("box",coe);const uoe=[["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"}]],doe=qe("cable",uoe);const hoe=[["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"}]],foe=qe("calendar-days",hoe);const poe=[["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"}]],Zr=qe("calendar",poe);const moe=[["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"}]],b0=qe("camera",moe);const goe=[["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"}]],xoe=qe("chart-column",goe);const boe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],zh=qe("check",boe);const yoe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],bd=qe("chevron-down",yoe);const voe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],uf=qe("chevron-right",voe);const _oe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bh=qe("chevron-left",_oe);const woe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],FS=qe("chevron-up",woe);const Soe=[["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"}]],lo=qe("circle-alert",Soe);const Moe=[["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"}]],RA=qe("circle-arrow-up",Moe);const Eoe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],fi=qe("circle-check-big",Eoe);const Aoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Toe=qe("circle-check",Aoe);const Coe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Noe=qe("circle-dot",Coe);const koe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Poe=qe("circle-stop",koe);const Roe=[["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"}]],gs=qe("circle-x",Roe);const Doe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_r=qe("clock",Doe);const joe=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],US=qe("cloud",joe);const Ooe=[["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"}]],Loe=qe("code-xml",Ooe);const Ioe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],oG=qe("code",Ioe);const Foe=[["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"}]],Uoe=qe("coffee",Foe);const zoe=[["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"}]],Boe=qe("cog",zoe);const Hoe=[["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"}]],$oe=qe("compass",Hoe);const Voe=[["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"}]],Hh=qe("copy",Voe);const Goe=[["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"}]],gv=qe("cpu",Goe);const Woe=[["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"}]],fm=qe("database",Woe);const qoe=[["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"}]],kk=qe("dollar-sign",qoe);const Koe=[["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"}]],Es=qe("download",Koe);const Xoe=[["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"}]],UR=qe("droplet",Xoe);const Yoe=[["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"}]],lG=qe("droplets",Yoe);const Zoe=[["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"}]],cG=qe("ellipsis-vertical",Zoe);const Qoe=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],DA=qe("equal",Qoe);const Joe=[["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"}]],As=qe("external-link",Joe);const ele=[["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"}]],zR=qe("eye-off",ele);const tle=[["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"}]],pm=qe("eye",tle);const nle=[["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"}]],rle=qe("fan",nle);const ile=[["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"}]],ale=qe("file-box",ile);const sle=[["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"}]],YF=qe("file-code",sle);const ole=[["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"}]],lle=qe("file-exclamation-point",ole);const cle=[["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"}]],T1=qe("file-spreadsheet",cle);const ule=[["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"}]],to=qe("file-text",ule);const dle=[["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"}]],uG=qe("file",dle);const hle=[["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"}]],Yp=qe("film",hle);const fle=[["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"}]],ple=qe("flame",fle);const mle=[["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"}]],Ku=qe("folder-kanban",mle);const gle=[["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"}]],xle=qe("folder-open",gle);const ble=[["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"}]],dG=qe("folder",ble);const yle=[["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"}]],BR=qe("funnel",yle);const vle=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],HR=qe("gauge",vle);const _le=[["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"}]],wle=qe("gift",_le);const Sle=[["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"}]],Zp=qe("git-compare",Sle);const Mle=[["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"}]],ZF=qe("github",Mle);const Ele=[["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"}]],y0=qe("globe",Ele);const Ale=[["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"}]],v0=qe("grip-vertical",Ale);const Tle=[["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"}]],$R=qe("hard-drive",Tle);const Cle=[["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"}]],Nle=qe("heart",Cle);const kle=[["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"}]],Pk=qe("history",kle);const Ple=[["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"}]],Rle=qe("house",Ple);const Dle=[["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"}]],gb=qe("image",Dle);const jle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],_0=qe("info",jle);const Ole=[["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"}]],Lle=qe("italic",Ole);const Ile=[["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"}]],$p=qe("key",Ile);const Fle=[["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"}]],Rk=qe("keyboard",Fle);const Ule=[["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"}]],$h=qe("layers",Ule);const zle=[["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"}]],hG=qe("layout-grid",zle);const Ble=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],Hle=qe("layout-list",Ble);const $le=[["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"}]],Vle=qe("link-2-off",$le);const Gle=[["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"}]],Dk=qe("link-2",Gle);const Wle=[["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"}]],zS=qe("link",Wle);const qle=[["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"}]],fG=qe("list-ordered",qle);const Kle=[["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"}]],Xle=qe("list-todo",Kle);const Yle=[["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"}]],VR=qe("list",Yle);const Zle=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Et=qe("loader-circle",Zle);const Qle=[["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"}]],QF=qe("log-in",Qle);const Jle=[["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"}]],ece=qe("log-out",Jle);const tce=[["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"}]],nce=qe("mail",tce);const rce=[["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"}]],ice=qe("map",rce);const ace=[["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"}]],sce=qe("maximize-2",ace);const oce=[["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"}]],lce=qe("maximize",oce);const cce=[["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"}]],uce=qe("memory-stick",cce);const dce=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],hce=qe("menu",dce);const fce=[["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"}]],pce=qe("minimize-2",fce);const mce=[["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"}]],gce=qe("minimize",mce);const xce=[["path",{d:"M5 12h14",key:"1ays0h"}]],jk=qe("minus",xce);const bce=[["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"}]],C1=qe("moon",bce);const yce=[["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"}]],vce=qe("music",yce);const _ce=[["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"}]],w0=qe("package",_ce);const wce=[["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"}]],pG=qe("palette",wce);const Sce=[["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"}]],Mce=qe("pause",Sce);const Ece=[["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"}]],S0=qe("pen-line",Ece);const Ace=[["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"}]],GR=qe("pen",Ace);const Tce=[["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"}]],id=qe("pencil",Tce);const Cce=[["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"}]],Nce=qe("phone",Cce);const kce=[["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"}]],BS=qe("play",kce);const Pce=[["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"}]],Qp=qe("plug",Pce);const Rce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pr=qe("plus",Rce);const Dce=[["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"}]],WR=qe("power-off",Dce);const jce=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],yd=qe("power",jce);const Oce=[["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"}]],Ts=qe("printer",Oce);const Lce=[["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"}]],Ice=qe("qr-code",Lce);const Fce=[["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"}]],Ta=qe("refresh-cw",Fce);const Uce=[["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"}]],Km=qe("rotate-ccw",Uce);const zce=[["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"}]],Bce=qe("ruler",zce);const Hce=[["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"}]],Ro=qe("save",Hce);const $ce=[["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"}]],Vce=qe("scan-search",$ce);const Gce=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Cc=qe("search",Gce);const Wce=[["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"}]],qR=qe("send",Wce);const qce=[["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"}]],nh=qe("server",qce);const Kce=[["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"}]],HS=qe("settings-2",Kce);const Xce=[["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"}]],KR=qe("settings",Xce);const Yce=[["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"}]],Zce=qe("shield",Yce);const Qce=[["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"}]],Jce=qe("shopping-cart",Qce);const eue=[["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"}]],tue=qe("signal",eue);const nue=[["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"}]],rue=qe("skip-back",nue);const iue=[["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"}]],N1=qe("skip-forward",iue);const aue=[["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"}]],JF=qe("sliders-vertical",aue);const sue=[["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"}]],M0=qe("sparkles",sue);const oue=[["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"}]],Vh=qe("square-check-big",oue);const lue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],mm=qe("square",lue);const cue=[["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"}]],gm=qe("star",cue);const uue=[["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"}]],mG=qe("sticky-note",uue);const due=[["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"}]],eU=qe("sun",due);const hue=[["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"}]],E0=qe("tag",hue);const fue=[["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"}]],gG=qe("target",fue);const pue=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],xG=qe("terminal",pue);const mue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],gue=qe("text-align-center",mue);const xue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],bue=qe("text-align-end",xue);const yue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],vue=qe("text-align-start",yue);const _ue=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],$S=qe("thermometer",_ue);const wue=[["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"}]],zu=qe("timer",wue);const Sue=[["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"}]],Rn=qe("trash-2",Sue);const Mue=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],bG=qe("trending-down",Mue);const Eue=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],yG=qe("trending-up",Eue);const Aue=[["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"}]],ti=qe("triangle-alert",Aue);const Tue=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Cue=qe("underline",Tue);const Nue=[["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"}]],vG=qe("unlink",Nue);const kue=[["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"}]],vs=qe("upload",kue);const Pue=[["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"}]],Ok=qe("user",Pue);const Rue=[["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"}]],Due=qe("users",Rue);const jue=[["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"}]],_G=qe("video",jue);const Oue=[["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"}]],XR=qe("wifi-off",Oue);const Lue=[["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"}]],wG=qe("wifi",Lue);const Iue=[["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"}]],Fue=qe("wind",Iue);const Uue=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ad=qe("wrench",Uue);const zue=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=qe("x",zue);const Bue=[["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"}]],Hue=qe("zoom-in",Bue);const $ue=[["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"}]],xm=qe("zap",$ue);const Vue=[["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"}]],Gue=qe("zoom-out",Vue),SG=E.createContext(void 0);function Wue({children:t}){const[e,n]=E.useState(()=>{const a=localStorage.getItem("theme");return a||"dark"});E.useEffect(()=>{const a=document.documentElement;e==="dark"?a.classList.add("dark"):a.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(a=>a==="dark"?"light":"dark")},i=a=>{n(a)};return l.jsx(SG.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function xb(){const t=E.useContext(SG);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Nt({children:t,className:e="",onClick:n,onContextMenu:r}){return l.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function Ha({children:t,className:e=""}){return l.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Rt({children:t,className:e=""}){return l.jsx("div",{className:`p-6 ${e}`,children:t})}function que(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 tU({children:t}){return l.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 Kue({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Vm(),i=que(n,e,r);return E.useEffect(()=>{const a=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Rk,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),l.jsx("div",{className:"space-y-2",children:a.items.map(s=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[s.description,s.isExternal&&l.jsx(As,{className:"w-3 h-3 text-bambu-gray"})]}),l.jsx("div",{className:"flex gap-1",children:s.keys.map(o=>l.jsx(tU,{children:o},o))})]},s.description))})]},a.category))}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",l.jsx(tU,{children:"Esc"})," or click outside to close"]})})]})})})}const er="/api/v1";async function Qe(t,e={}){const n=await fetch(`${er}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.json()}const ke={getPrinters:()=>Qe("/printers/"),getPrinter:t=>Qe(`/printers/${t}`),createPrinter:t=>Qe("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Qe(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>Qe(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>Qe(`/printers/${t}/status`),connectPrinter:t=>Qe(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Qe(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>Qe(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Qe(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Qe(`/printers/${t}/logging`),clearMQTTLogs:t=>Qe(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Qe(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${er}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Qe(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Qe(`/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)),Qe(`/archives/?${i}`)},getArchive:t=>Qe(`/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)),Qe(`/archives/search?${n}`)},rebuildSearchIndex:()=>Qe("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Qe(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Qe(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Qe(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Qe("/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)),Qe(`/archives/analysis/failures?${e}`)},compareArchives:t=>Qe(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Qe(`/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(`${er}/archives/export?${e}`);if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.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 s=r.match(/filename="?([^"]+)"?/);s&&(i=s[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(`${er}/archives/stats/export?${e}`);if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.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 s=r.match(/filename="?([^"]+)"?/);s&&(i=s[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>Qe(`/archives/${t}/duplicates`),backfillContentHashes:()=>Qe("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${er}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${er}/archives/${t}/download`,getArchiveGcode:t=>`${er}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${er}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>Qe(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Qe(`/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(`${er}/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()},getArchivePhotoUrl:(t,e)=>`${er}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${er}/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)=>Qe(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${er}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${er}/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(`${er}/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=>Qe(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${er}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Qe(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Qe(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Qe(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${er}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${er}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>Qe(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${er}/archives/upload?printer_id=${e}`:`${er}/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?`${er}/archives/upload-bulk?printer_id=${e}`:`${er}/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:()=>Qe("/settings/"),updateSettings:t=>Qe("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>Qe("/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.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.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)));const n=`${er}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n),i=r.headers.get("Content-Disposition");let a="bambuddy-backup.json";if(i){const o=i.match(/filename=([^;]+)/);o&&(a=o[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${er}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Qe("/settings/check-ffmpeg"),getCloudStatus:()=>Qe("/cloud/status"),cloudLogin:(t,e,n="global")=>Qe("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Qe("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Qe("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Qe("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Qe(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Qe(`/cloud/settings/${t}`),createCloudSetting:t=>Qe("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Qe(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Qe(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Qe("/cloud/devices"),getCloudFields:t=>Qe(`/cloud/fields/${t}`),getAllCloudFields:()=>Qe("/cloud/fields"),getSmartPlugs:()=>Qe("/smart-plugs/"),getSmartPlug:t=>Qe(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Qe(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Qe("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Qe(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Qe(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Qe(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Qe(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Qe("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Qe(`/queue/?${n}`)},getQueueItem:t=>Qe(`/queue/${t}`),addToQueue:t=>Qe("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Qe(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Qe(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Qe("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Qe(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Qe(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Qe(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Qe(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Qe(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Qe(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Qe(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Qe(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Qe(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Qe(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Qe(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Qe(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Qe(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>Qe("/filaments/"),getFilament:t=>Qe(`/filaments/${t}`),getFilamentsByType:t=>Qe(`/filaments/by-type/${t}`),getNotificationProviders:()=>Qe("/notifications/"),getNotificationProvider:t=>Qe(`/notifications/${t}`),createNotificationProvider:t=>Qe("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Qe(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Qe(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Qe(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Qe("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Qe("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Qe("/notification-templates"),getNotificationTemplate:t=>Qe(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Qe(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Qe(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Qe("/notification-templates/variables"),previewTemplate:t=>Qe("/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)),Qe(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Qe(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Qe(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Qe("/spoolman/status"),connectSpoolman:()=>Qe("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Qe("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Qe(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Qe("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Qe("/spoolman/spools"),getSpoolmanFilaments:()=>Qe("/spoolman/filaments"),getVersion:()=>Qe("/updates/version"),checkForUpdates:()=>Qe("/updates/check"),applyUpdate:()=>Qe("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Qe("/updates/status"),getMaintenanceTypes:()=>Qe("/maintenance/types"),createMaintenanceType:t=>Qe("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Qe(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Qe(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Qe("/maintenance/overview"),getPrinterMaintenance:t=>Qe(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Qe(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Qe(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Qe(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Qe("/maintenance/summary"),setPrinterHours:(t,e)=>Qe(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),getCameraStreamUrl:(t,e=10)=>`${er}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${er}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Qe(`/printers/${t}/camera/test`),getExternalLinks:()=>Qe("/external-links/"),getExternalLink:t=>Qe(`/external-links/${t}`),createExternalLink:t=>Qe("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Qe(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Qe(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Qe("/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(`${er}/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=>Qe(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${er}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Qe(`/projects/?${e}`)},getProject:t=>Qe(`/projects/${t}`),createProject:t=>Qe("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Qe(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Qe(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Qe(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Qe(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Qe(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Qe(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),getAPIKeys:()=>Qe("/api-keys/"),createAPIKey:t=>Qe("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Qe(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Qe(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Qe(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Qe("/system/info")},sx={getStatus:()=>Qe("/discovery/status"),startDiscovery:(t=10)=>Qe(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Qe("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Qe("/discovery/printers")},MG=[{name:"globe",icon:y0},{name:"link",icon:zS},{name:"external-link",icon:As},{name:"book",icon:soe},{name:"file-text",icon:to},{name:"home",icon:Rle},{name:"star",icon:gm},{name:"heart",icon:Nle},{name:"bookmark",icon:loe},{name:"shopping-cart",icon:Jce},{name:"music",icon:vce},{name:"video",icon:_G},{name:"image",icon:gb},{name:"camera",icon:b0},{name:"map",icon:ice},{name:"compass",icon:$oe},{name:"coffee",icon:Uoe},{name:"gift",icon:wle},{name:"wrench",icon:ad},{name:"zap",icon:xm},{name:"cloud",icon:US},{name:"database",icon:fm},{name:"folder",icon:dG},{name:"mail",icon:nce},{name:"phone",icon:Nce},{name:"user",icon:Ok},{name:"users",icon:Due},{name:"server",icon:nh},{name:"terminal",icon:xG},{name:"code",icon:oG}];function VS(t){return MG.find(n=>n.name===t)?.icon||zS}function Xue({value:t,onChange:e}){const[n,r]=E.useState(!1),i=VS(t);return l.jsxs("div",{className:"relative",children:[l.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:[l.jsx(i,{className:"w-5 h-5"}),l.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),l.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:l.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:MG.map(({name:a,icon:s})=>l.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:l.jsx(s,{className:"w-5 h-5"})},a))})})]})]})}const nU=768;function EG(){const[t,e]=E.useState(()=>typeof window<"u"?window.innerWidth<nU:!1);return E.useEffect(()=>{const n=window.matchMedia(`(max-width: ${nU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const A0=[{id:"printers",to:"/",icon:Ts,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:wh,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Zr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:xoe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:US,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:ad,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ku,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:KR,labelKey:"nav.settings"}];function Yue(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return A0.map(e=>e.id)}return A0.map(e=>e.id)}function Zue(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function jA(t){return t.startsWith("ext-")}function AG(){return localStorage.getItem("defaultView")||"/"}function Que(t){localStorage.setItem("defaultView",t)}function Jue(){const t=kR(),e=xd(),{theme:n,toggleTheme:r}=xb(),{t:i}=Vm(),a=EG(),[s,o]=E.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=E.useState(!1),[d,f]=E.useState(!1),[g,m]=E.useState(Yue),[b,y]=E.useState(null),[v,x]=E.useState(null),M=E.useRef(!1),[S,A]=E.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=vt({queryKey:["version"],queryFn:ke.getVersion,staleTime:1/0}),{data:k}=vt({queryKey:["settings"],queryFn:ke.getSettings,staleTime:300*1e3}),{data:N}=vt({queryKey:["updateCheck"],queryFn:ke.checkForUpdates,enabled:k?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:I}=vt({queryKey:["external-links"],queryFn:ke.getExternalLinks}),C=new Map(A0.map(Q=>[Q.id,Q])),D=new Map((I||[]).map(Q=>[`ext-${Q.id}`,Q])),F=(()=>{const Q=[],U=new Set;for(const $ of g)(C.has($)||D.has($))&&(Q.push($),U.add($));for(const $ of A0)U.has($.id)||(Q.push($.id),U.add($.id));for(const $ of I||[]){const X=`ext-${$.id}`;U.has(X)||(Q.push(X),U.add(X))}return Q})(),O=(Q,U)=>{y(U),Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("text/plain",U)},q=(Q,U)=>{Q.preventDefault(),Q.dataTransfer.dropEffect="move",x(U)},R=()=>{x(null)},W=(Q,U)=>{if(Q.preventDefault(),b===null||b===U){y(null),x(null);return}const $=[...F],X=$.indexOf(b),te=$.indexOf(U);if(X===-1||te===-1){y(null),x(null);return}$.splice(X,1),$.splice(te,0,b),m($),Zue($),y(null),x(null)},K=()=>{y(null),x(null)},G=N?.update_available&&N.latest_version&&N.latest_version!==S,ee=()=>{N?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",N.latest_version),A(N.latest_version))};E.useEffect(()=>{if(!M.current&&e.pathname==="/"){const Q=AG();Q!=="/"&&(M.current=!0,t(Q,{replace:!0}))}},[e.pathname,t]),E.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]),E.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const Z=E.useCallback(Q=>{const U=Q.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!Q.metaKey&&!Q.ctrlKey&&!Q.altKey){const $=parseInt(Q.key);if($>=1&&$<=F.length&&$<=9){const X=F[$-1];if(Q.preventDefault(),jA(X)){const te=X.replace("ext-","");t(`/external/${te}`)}else{const te=C.get(X);te&&t(te.to)}return}switch(Q.key){case"?":Q.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,F,C]);return E.useEffect(()=>(document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)),[Z]),l.jsxs("div",{className:"flex min-h-screen",children:[a&&l.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:[l.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:l.jsx(hce,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&c&&l.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),l.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${c?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${s?"w-64":"w-16"}`}`,children:[l.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||s?"p-4":"p-2"}`,children:l.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||s?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),l.jsx("nav",{className:"flex-1 p-2",children:l.jsx("ul",{className:"space-y-2",children:F.map(Q=>{if(jA(Q)){const $=D.get(Q);if(!$)return null;const X=$.custom_icon?null:VS($.icon);return l.jsx("li",{draggable:!0,onDragStart:te=>O(te,Q),onDragOver:te=>q(te,Q),onDragLeave:R,onDrop:te=>W(te,Q),onDragEnd:K,className:`relative ${b===Q?"opacity-50":""} ${v===Q&&b!==Q?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Rx,{to:`/external/${$.id}`,className:({isActive:te})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${te?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?$.name:void 0,children:[s&&!a&&l.jsx(v0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),$.custom_icon?l.jsx("img",{src:`/api/v1/external-links/${$.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):X&&l.jsx(X,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&l.jsx("span",{children:$.name})]})},Q)}else{const $=C.get(Q);if(!$)return null;const{to:X,icon:te,labelKey:fe}=$;return l.jsx("li",{draggable:!0,onDragStart:pe=>O(pe,Q),onDragOver:pe=>q(pe,Q),onDragLeave:R,onDrop:pe=>W(pe,Q),onDragEnd:K,className:`relative ${b===Q?"opacity-50":""} ${v===Q&&b!==Q?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Rx,{to:X,className:({isActive:pe})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${pe?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?i(fe):void 0,children:[s&&!a&&l.jsx(v0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),l.jsx(te,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&l.jsx("span",{children:i(fe)})]})},Q)}})})}),!a&&l.jsx("button",{onClick:()=>o(!s),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(s?"nav.collapseSidebar":"nav.expandSidebar"),children:s?l.jsx(Bh,{className:"w-5 h-5"}):l.jsx(uf,{className:"w-5 h-5"})}),l.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||s?l.jsxs("div",{className:"flex items-center justify-between px-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),N?.update_available&&l.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:N.latest_version}),children:[l.jsx(RA,{className:"w-4 h-4"}),l.jsx("span",{children:i("nav.update")})]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Rx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(_0,{className:"w-5 h-5"})}),l.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:l.jsx(ZF,{className:"w-5 h-5"})}),l.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:l.jsx(Rk,{className:"w-5 h-5"})}),l.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"?l.jsx(eU,{className:"w-5 h-5"}):l.jsx(C1,{className:"w-5 h-5"})})]})]}):l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[N?.update_available&&l.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:N.latest_version}),children:l.jsx(RA,{className:"w-5 h-5"})}),l.jsx(Rx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(_0,{className:"w-5 h-5"})}),l.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:l.jsx(ZF,{className:"w-5 h-5"})}),l.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:l.jsx(Rk,{className:"w-5 h-5"})}),l.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"?l.jsx(eU,{className:"w-5 h-5"}):l.jsx(C1,{className:"w-5 h-5"})})]})})]}),l.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":s?"ml-64":"ml-16"}`,children:[G&&l.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(RA,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{children:i("nav.updateAvailableBanner",{version:N?.latest_version,defaultValue:`Version ${N?.latest_version} is available!`})}),l.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),l.jsx("button",{onClick:ee,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsx(Nae,{})]}),d&&l.jsx(Kue,{onClose:()=>f(!1),sidebarItems:F.map(Q=>{if(jA(Q)){const U=D.get(Q);return U?{type:"external",label:U.name}:null}else{const U=C.get(Q);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)})]})}function Le({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",s={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"},o={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 l.jsx("button",{className:`${a} ${s[t]} ${o[e]} ${n}`,...i,children:r})}function Qr({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:s}){E.useEffect(()=>{const u=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]);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 l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-start gap-4",children:[l.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:l.jsx(ti,{className:"w-6 h-6"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),l.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),l.jsxs("div",{className:"flex gap-3 mt-6",children:[l.jsx(Le,{variant:"secondary",onClick:s,className:"flex-1",children:r}),l.jsx(Le,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}const TG=E.createContext(void 0);function ai(){const t=E.useContext(TG);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const ede={success:l.jsx(fi,{className:"w-5 h-5 text-green-400"}),error:l.jsx(gs,{className:"w-5 h-5 text-red-400"}),warning:l.jsx(lo,{className:"w-5 h-5 text-yellow-400"}),info:l.jsx(_0,{className:"w-5 h-5 text-blue-400"}),loading:l.jsx(Et,{className:"w-5 h-5 text-bambu-green animate-spin"})},tde={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 nde({children:t}){const[e,n]=E.useState([]),r=E.useCallback((s,o="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:s,type:o}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=E.useCallback((s,o,c="info")=>{n(u=>u.find(f=>f.id===s)?u.map(f=>f.id===s?{...f,message:o,type:c,persistent:!0}:f):[...u,{id:s,message:o,type:c,persistent:!0}])},[]),a=E.useCallback(s=>{n(o=>o.filter(c=>c.id!==s))},[]);return l.jsxs(TG.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,l.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>l.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${tde[s.type]}`,children:[ede[s.type],l.jsx("span",{className:"text-white text-sm",children:s.message}),l.jsx("button",{onClick:()=>a(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]},s.id))})]})}function rde(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 rU(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 ide(t,e){if(e)return dG;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return ale;case"gcode":return to;case"mp4":case"avi":return Yp;case"png":case"jpg":case"jpeg":return gb;default:return uG}}function ade({printerId:t,printerName:e,onClose:n}){const{showToast:r}=ai(),i=En(),[a,s]=E.useState("/"),[o,c]=E.useState(null),[u,d]=E.useState(""),[f,g]=E.useState(null);E.useEffect(()=>{const N=I=>{I.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const{data:m,isLoading:b,refetch:y}=vt({queryKey:["printerFiles",t,a],queryFn:()=>ke.getPrinterFiles(t,a)}),{data:v}=vt({queryKey:["printerStorage",t],queryFn:()=>ke.getPrinterStorage(t),staleTime:3e4}),x=wt({mutationFn:N=>ke.deletePrinterFile(t,N),onSuccess:(N,I)=>{r(`Deleted: ${I.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:N=>{r(`Delete failed: ${N.message}`,"error")}}),M=N=>{s(N),c(null)},S=()=>{if(a==="/")return;const N=a.split("/").filter(Boolean);N.pop(),s(N.length?"/"+N.join("/"):"/"),c(null)},A=N=>{window.open(ke.getPrinterFileDownloadUrl(t,N),"_blank")},T=N=>{g(N)},k=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[l.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:N=>N.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx($R,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[v&&(v.used_bytes!=null||v.free_bytes!=null)&&l.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[v.used_bytes!=null&&l.jsxs("span",{children:["Used: ",rU(v.used_bytes)]}),v.used_bytes!=null&&v.free_bytes!=null&&l.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),v.free_bytes!=null&&l.jsxs("span",{children:["Free: ",rU(v.free_bytes)]})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),l.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[k.map(N=>l.jsx("button",{onClick:()=>{M(N.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===N.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:N.label},N.path)),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"relative",children:[l.jsx(Cc,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:N=>d(N.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"})]}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:b,children:l.jsx(Ta,{className:`w-4 h-4 ${b?"animate-spin":""}`})})]}),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[l.jsx("button",{onClick:S,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:l.jsx(Bh,{className:"w-4 h-4"})}),l.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:b?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?l.jsx("div",{className:"space-y-1",children:[...m.files].filter(N=>!u||N.name.toLowerCase().includes(u.toLowerCase())).sort((N,I)=>N.is_directory&&!I.is_directory?-1:!N.is_directory&&I.is_directory?1:N.name.localeCompare(I.name)).map(N=>{const I=ide(N.name,N.is_directory),C=o===N.path;return l.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${C?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{N.is_directory?M(N.path):c(C?null:N.path)},children:[l.jsx(I,{className:`w-5 h-5 flex-shrink-0 ${N.is_directory?"text-bambu-green":"text-bambu-gray"}`}),l.jsx("span",{className:"flex-1 text-white truncate",children:N.name}),!N.is_directory&&l.jsx("span",{className:"text-sm text-bambu-gray",children:rde(N.size)}),N.is_directory&&l.jsx(Bh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${m?.files?.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[l.jsx(Es,{className:"w-4 h-4"}),"Download"]}),l.jsxs(Le,{variant:"secondary",disabled:!o||x.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[x.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&l.jsx(Qr,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{x.mutate(f),g(null)},onCancel:()=>g(null)})]})}function sde({printerId:t,printerName:e,onClose:n}){const r=En(),[i,a]=E.useState(!0),[s,o]=E.useState(new Set),[c,u]=E.useState(""),[d,f]=E.useState("all"),g=E.useRef(null),{data:m,isLoading:b,refetch:y}=vt({queryKey:["mqtt-logs",t],queryFn:()=>ke.getMQTTLogs(t),refetchInterval:1e3}),v=wt({mutationFn:()=>ke.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),x=wt({mutationFn:()=>ke.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=wt({mutationFn:()=>ke.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});E.useEffect(()=>{const C=D=>{D.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]),E.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[m?.logs,i]);const S=C=>{o(D=>{const F=new Set(D);return F.has(C)?F.delete(C):F.add(C),F})},A=C=>new Date(C).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(C,D)=>{if(C==null)return"<empty>";const F=typeof C=="string"?JSON.parse(C):C,O=JSON.stringify(F,null,D?2:0);return!D&&O.length>100?O.substring(0,100)+"...":O},k=m?.logging_enabled??!1,N=m?.logs??[],I=E.useMemo(()=>N.filter(C=>{if(d!=="all"&&C.direction!==d)return!1;if(c.trim()){const D=c.toLowerCase(),F=C.topic.toLowerCase().includes(D),q=JSON.stringify(C.payload).toLowerCase().includes(D);return F||q}return!0}),[N,c,d]);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[k?l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,children:[l.jsx(mm,{className:"w-4 h-4"}),"Stop"]}):l.jsxs(Le,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[l.jsx(BS,{className:"w-4 h-4"}),"Start Logging"]}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||N.length===0,children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:b,children:l.jsx(Ta,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),l.jsx("div",{className:"flex-1"}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:i,onChange:C=>a(C.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:[I.length,"/",N.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(Cc,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:C=>u(C.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&l.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[l.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"}),l.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:[l.jsx(x0,{className:"w-3 h-3"}),"In"]}),l.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:[l.jsx(dm,{className:"w-3 h-3"}),"Out"]})]})]})]}),l.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:N.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!k&&l.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):I.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages match your filter"}),l.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):l.jsx("div",{className:"space-y-1",children:I.map((C,D)=>{const F=s.has(D),O=C.direction==="in";return l.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>S(D),children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx("span",{className:"text-bambu-gray shrink-0",children:A(C.timestamp)}),l.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?l.jsx(x0,{className:"w-3 h-3"}):l.jsx(dm,{className:"w-3 h-3"})}),l.jsx("span",{className:"text-purple-400 shrink-0",children:C.topic})]}),F?l.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(C.payload,!0)}):l.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(C.payload,!1)})]},D)})})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:k?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):l.jsx("span",{children:"Logging stopped"})}),l.jsx(Le,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const Lk={"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 ode(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:ti};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:ti};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:lo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:_0}}}function Ik(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 lde(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=Ik(e.attr,n);return Lk[r]!==void 0})}function cde(){return"https://wiki.bambulab.com/en/hms/home"}function ude({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,s=Ik(i.attr,a);return Lk[s]!==void 0});return E.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ti,{className:"w-5 h-5 text-orange-400"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),l.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(lo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{children:"No errors"})]}):l.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:s,color:o,bgColor:c,Icon:u}=ode(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=Ik(i.attr,d),g=Lk[f],m=cde(),b=f.replace("_","-");return l.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(u,{className:`w-5 h-5 ${o} flex-shrink-0 mt-0.5`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:`font-mono text-sm ${o}`,children:["[",b,"]"]}),l.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${o}`,children:s})]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g}),l.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[l.jsx(As,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function dde(t){if(!t)return"ASAP";const e=new Date(t),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 hde({printerId:t}){const{data:e}=vt({queryKey:["queue",t,"pending"],queryFn:()=>ke.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:l.jsx(IS,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx(Zr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),l.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[l.jsx(_r,{className:"w-3 h-3"}),dde(n?.scheduled_time||null)]}),r>1&&l.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),l.jsx(uf,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function CG(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=CG(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Mn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=CG(t))&&(r&&(r+=" "),r+=e);return r}var fde=["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 YR(t){if(typeof t!="string")return!1;var e=fde;return e.includes(t)}var pde=["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"],mde=new Set(pde);function NG(t){return typeof t!="string"?!1:mde.has(t)}function kG(t){return typeof t=="string"&&t.startsWith("data-")}function Ca(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(NG(n)||kG(n))&&(e[n]=t[n]);return e}function Gh(t){if(t==null)return null;if(E.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ca(e)}return typeof t=="object"&&!Array.isArray(t)?Ca(t):null}function na(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(NG(n)||kG(n)||YR(n))&&(e[n]=t[n]);return e}function gde(t){return t==null?null:E.isValidElement(t)?na(t.props):typeof t=="object"&&!Array.isArray(t)?na(t):null}var xde=["children","width","height","viewBox","className","style","title","desc"];function Fk(){return Fk=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},Fk.apply(null,arguments)}function bde(t,e){if(t==null)return{};var n,r,i=yde(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 yde(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 ZR=E.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:o,title:c,desc:u}=t,d=bde(t,xde),f=a||{width:r,height:i,x:0,y:0},g=Mn("recharts-surface",s);return E.createElement("svg",Fk({},na(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),E.createElement("title",null,c),E.createElement("desc",null,u),n)}),vde=["children","className"];function Uk(){return Uk=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},Uk.apply(null,arguments)}function _de(t,e){if(t==null)return{};var n,r,i=wde(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 wde(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 wr=E.forwardRef((t,e)=>{var{children:n,className:r}=t,i=_de(t,vde),a=Mn("recharts-layer",r);return E.createElement("g",Uk({className:a},na(i),{ref:e}),n)}),PG=E.createContext(null),Sde=()=>E.useContext(PG);function ir(t){return function(){return t}}const RG=Math.cos,k1=Math.sin,Ho=Math.sqrt,P1=Math.PI,GS=2*P1,zk=Math.PI,Bk=2*zk,rh=1e-6,Mde=Bk-rh;function DG(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Ede(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return DG;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 Ade{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?DG:Ede(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,s){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}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 s=this._x1,o=this._y1,c=r-e,u=i-n,d=s-e,f=o-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>rh)if(!(Math.abs(f*c-u*d)>rh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-s,b=i-o,y=c*c+u*u,v=m*m+b*b,x=Math.sqrt(y),M=Math.sqrt(g),S=a*Math.tan((zk-Math.acos((y+g-v)/(2*x*M)))/2),A=S/M,T=S/x;Math.abs(A-1)>rh&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*m>d*b)},${this._x1=e+T*c},${this._y1=n+T*u}`}}arc(e,n,r,i,a,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),c=r*Math.sin(i),u=e+o,d=n+c,f=1^s,g=s?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>rh||Math.abs(this._y1-d)>rh)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%Bk+Bk),g>Mde?this._append`A${r},${r},0,1,${f},${e-o},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>rh&&this._append`A${r},${r},0,${+(g>=zk)},${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 QR(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 Ade(e)}function JR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function jG(t){this._context=t}jG.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 WS(t){return new jG(t)}function OG(t){return t[0]}function LG(t){return t[1]}function IG(t,e){var n=ir(!0),r=null,i=WS,a=null,s=QR(o);t=typeof t=="function"?t:t===void 0?OG:ir(t),e=typeof e=="function"?e:e===void 0?LG:ir(e);function o(c){var u,d=(c=JR(c)).length,f,g=!1,m;for(r==null&&(a=i(m=s())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===g&&((g=!g)?a.lineStart():a.lineEnd()),g&&a.point(+t(f,u,c),+e(f,u,c));if(m)return a=null,m+""||null}return o.x=function(c){return arguments.length?(t=typeof c=="function"?c:ir(+c),o):t},o.y=function(c){return arguments.length?(e=typeof c=="function"?c:ir(+c),o):e},o.defined=function(c){return arguments.length?(n=typeof c=="function"?c:ir(!!c),o):n},o.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),o):i},o.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),o):r},o}function xv(t,e,n){var r=null,i=ir(!0),a=null,s=WS,o=null,c=QR(u);t=typeof t=="function"?t:t===void 0?OG:ir(+t),e=typeof e=="function"?e:ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?LG:ir(+n);function u(f){var g,m,b,y=(f=JR(f)).length,v,x=!1,M,S=new Array(y),A=new Array(y);for(a==null&&(o=s(M=c())),g=0;g<=y;++g){if(!(g<y&&i(v=f[g],g,f))===x)if(x=!x)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),b=g-1;b>=m;--b)o.point(S[b],A[b]);o.lineEnd(),o.areaEnd()}x&&(S[g]=+t(v,g,f),A[g]=+e(v,g,f),o.point(r?+r(v,g,f):S[g],n?+n(v,g,f):A[g]))}if(M)return o=null,M+""||null}function d(){return IG().defined(i).curve(s).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:ir(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:ir(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:ir(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:ir(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:ir(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:ir(+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:ir(!!f),u):i},u.curve=function(f){return arguments.length?(s=f,a!=null&&(o=s(a)),u):s},u.context=function(f){return arguments.length?(f==null?a=o=null:o=s(a=f),u):a},u}class FG{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 Tde(t){return new FG(t,!0)}function Cde(t){return new FG(t,!1)}const eD={draw(t,e){const n=Ho(e/P1);t.moveTo(n,0),t.arc(0,0,n,0,GS)}},Nde={draw(t,e){const n=Ho(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()}},UG=Ho(1/3),kde=UG*2,Pde={draw(t,e){const n=Ho(e/kde),r=n*UG;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Rde={draw(t,e){const n=Ho(e),r=-n/2;t.rect(r,r,n,n)}},Dde=.8908130915292852,zG=k1(P1/10)/k1(7*P1/10),jde=k1(GS/10)*zG,Ode=-RG(GS/10)*zG,Lde={draw(t,e){const n=Ho(e*Dde),r=jde*n,i=Ode*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=GS*a/5,o=RG(s),c=k1(s);t.lineTo(c*n,-o*n),t.lineTo(o*r-c*i,c*r+o*i)}t.closePath()}},OA=Ho(3),Ide={draw(t,e){const n=-Ho(e/(OA*3));t.moveTo(0,n*2),t.lineTo(-OA*n,-n),t.lineTo(OA*n,-n),t.closePath()}},Fs=-.5,Us=Ho(3)/2,Hk=1/Ho(12),Fde=(Hk/2+1)*3,Ude={draw(t,e){const n=Ho(e/Fde),r=n/2,i=n*Hk,a=r,s=n*Hk+n,o=-a,c=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(o,c),t.lineTo(Fs*r-Us*i,Us*r+Fs*i),t.lineTo(Fs*a-Us*s,Us*a+Fs*s),t.lineTo(Fs*o-Us*c,Us*o+Fs*c),t.lineTo(Fs*r+Us*i,Fs*i-Us*r),t.lineTo(Fs*a+Us*s,Fs*s-Us*a),t.lineTo(Fs*o+Us*c,Fs*c-Us*o),t.closePath()}};function zde(t,e){let n=null,r=QR(i);t=typeof t=="function"?t:ir(t||eD),e=typeof e=="function"?e:ir(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:ir(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:ir(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function R1(){}function D1(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 BG(t){this._context=t}BG.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:D1(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:D1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Bde(t){return new BG(t)}function HG(t){this._context=t}HG.prototype={areaStart:R1,areaEnd:R1,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:D1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Hde(t){return new HG(t)}function $G(t){this._context=t}$G.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:D1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function $de(t){return new $G(t)}function VG(t){this._context=t}VG.prototype={areaStart:R1,areaEnd:R1,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 Vde(t){return new VG(t)}function iU(t){return t<0?-1:1}function aU(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),s=(n-t._y1)/(i||r<0&&-0),o=(a*i+s*r)/(r+i);return(iU(a)+iU(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function sU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function LA(t,e,n){var r=t._x0,i=t._y0,a=t._x1,s=t._y1,o=(a-r)/3;t._context.bezierCurveTo(r+o,i+o*e,a-o,s-o*n,a,s)}function j1(t){this._context=t}j1.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:LA(this,this._t0,sU(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,LA(this,sU(this,n=aU(this,t,e)),n);break;default:LA(this,this._t0,n=aU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function GG(t){this._context=new WG(t)}(GG.prototype=Object.create(j1.prototype)).point=function(t,e){j1.prototype.point.call(this,e,t)};function WG(t){this._context=t}WG.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 Gde(t){return new j1(t)}function Wde(t){return new GG(t)}function qG(t){this._context=t}qG.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=oU(t),i=oU(e),a=0,s=1;s<n;++a,++s)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[s],e[s]);(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 oU(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),s=new Array(n);for(i[0]=0,a[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,s[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,s[e]-=r*s[e-1];for(i[n-1]=s[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(s[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 qde(t){return new qG(t)}function qS(t,e){this._context=t,this._t=e}qS.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 Kde(t){return new qS(t,.5)}function Xde(t){return new qS(t,0)}function Yde(t){return new qS(t,1)}function bm(t,e){if((s=t.length)>1)for(var n=1,r,i,a=t[e[0]],s,o=a.length;n<s;++n)for(i=a,a=t[e[n]],r=0;r<o;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function $k(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Zde(t,e){return t[e]}function Qde(t){const e=[];return e.key=t,e}function Jde(){var t=ir([]),e=$k,n=bm,r=Zde;function i(a){var s=Array.from(t.apply(this,arguments),Qde),o,c=s.length,u=-1,d;for(const f of a)for(o=0,++u;o<c;++o)(s[o][u]=[0,+r(f,s[o].key,u,a)]).data=f;for(o=0,d=JR(e(s));o<c;++o)s[d[o]].index=o;return n(s,d),s}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:ir(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:ir(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?$k:typeof a=="function"?a:ir(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??bm,i):n},i}function ehe(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,s;i<a;++i){for(s=n=0;n<r;++n)s+=t[n][i][1]||0;if(s)for(n=0;n<r;++n)t[n][i][1]/=s}bm(t,e)}}function the(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var s=0,o=0;s<i;++s)o+=t[s][n][1]||0;r[n][1]+=r[n][0]=-o/2}bm(t,e)}}function nhe(t,e){if(!(!((s=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,s;r<a;++r){for(var o=0,c=0,u=0;o<s;++o){for(var d=t[e[o]],f=d[r][1]||0,g=d[r-1][1]||0,m=(f-g)/2,b=0;b<o;++b){var y=t[e[b]],v=y[r][1]||0,x=y[r-1][1]||0;m+=v-x}c+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,bm(t,e)}}var IA={},FA={},lU;function rhe(){return lU||(lU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(FA)),FA}var UA={},cU;function KG(){return cU||(cU=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})(UA)),UA}var zA={},uU;function tD(){return uU||(uU=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})(zA)),zA}var BA={},HA={},dU;function ihe(){return dU||(dU=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})(HA)),HA}var hU;function nD(){return hU||(hU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ihe(),n=tD();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],s=i.length;if(s===0)return a;let o=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),o++);o<s;){const f=i[o];u?f==="\\"&&o+1<s?(o++,c+=i[o]):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,o++}return c&&a.push(c),a}t.toPath=r})(BA)),BA}var fU;function rD(){return fU||(fU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rhe(),n=KG(),r=tD(),i=nD();function a(o,c,u){if(o==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?n.isDeepKey(c)?a(o,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=o[c];return d===void 0?u:d}default:{if(Array.isArray(c))return s(o,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?u:d}}}function s(o,c,u){if(c.length===0)return u;let d=o;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})(IA)),IA}var $A,pU;function ahe(){return pU||(pU=1,$A=rD().get),$A}var she=ahe();const Wh=fo(she);var Li=t=>t===0?0:t>0?1:-1,Za=t=>typeof t=="number"&&t!=+t,Nc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Pt=t=>(typeof t=="number"||t instanceof Number)&&!Za(t),co=t=>Pt(t)||typeof t=="string",ohe=0,T0=t=>{var e=++ohe;return"".concat(t||"").concat(e)},pa=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(!Pt(e)&&typeof e!="string")return r;var a;if(Nc(e)){if(n==null)return r;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return Za(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},XG=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 jn(t,e,n){return Pt(t)&&Pt(e)?t+n*(e-t):e}function YG(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Wh(r,e))===n)}var dr=t=>t===null||typeof t>"u",bb=t=>dr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function lhe(t){return t!=null}function yb(){}var che=["type","size","sizeType"];function Vk(){return Vk=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},Vk.apply(null,arguments)}function mU(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 gU(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mU(Object(n),!0).forEach(function(r){uhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uhe(t,e,n){return(e=dhe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dhe(t){var e=hhe(t,"string");return typeof e=="symbol"?e:e+""}function hhe(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 fhe(t,e){if(t==null)return{};var n,r,i=phe(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 phe(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 ZG={symbolCircle:eD,symbolCross:Nde,symbolDiamond:Pde,symbolSquare:Rde,symbolStar:Lde,symbolTriangle:Ide,symbolWye:Ude},mhe=Math.PI/180,ghe=t=>{var e="symbol".concat(bb(t));return ZG[e]||eD},xhe=(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*mhe;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}},bhe=(t,e)=>{ZG["symbol".concat(bb(t))]=e},iD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=fhe(t,che),a=gU(gU({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var o=()=>{var g=ghe(s),m=zde().type(g).size(xhe(n,r,s)),b=m();if(b!==null)return b},{className:c,cx:u,cy:d}=a,f=na(a);return Pt(u)&&Pt(d)&&Pt(n)?E.createElement("path",Vk({},f,{className:Mn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:o()})):null};iD.registerSymbol=bhe;var QG=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,aD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(E.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{YR(i)&&(r[i]=(a=>n[i](n,a)))}),r},yhe=(t,e,n)=>r=>(t(e,n,r),null),vb=(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];YR(i)&&typeof a=="function"&&(r||(r={}),r[i]=yhe(a,e,n))}),r};function xU(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vhe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xU(Object(n),!0).forEach(function(r){_he(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _he(t,e,n){return(e=whe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function whe(t){var e=She(t,"string");return typeof e=="symbol"?e:e+""}function She(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 Sr(t,e){var n=vhe({},t),r=e,i=Object.keys(e),a=i.reduce((s,o)=>(s[o]===void 0&&r[o]!==void 0&&(s[o]=r[o]),s),n);return a}function O1(){return O1=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},O1.apply(null,arguments)}function bU(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 Mhe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bU(Object(n),!0).forEach(function(r){Ehe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ehe(t,e,n){return(e=Ahe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ahe(t){var e=The(t,"string");return typeof e=="symbol"?e:e+""}function The(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 Vs=32,Che={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Nhe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Vs/2,a=Vs/6,s=Vs/3,o=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return E.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Vs,y2:i,className:"recharts-legend-icon"})}if(c==="line")return E.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(s,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
  12. H`).concat(Vs,"M").concat(2*s,",").concat(i,`
  13. A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return E.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Vs/8,"h").concat(Vs,"v").concat(Vs*3/4,"h").concat(-Vs,"z"),className:"recharts-legend-icon"});if(E.isValidElement(e.legendIcon)){var d=Mhe({},e);return delete d.legendIcon,E.cloneElement(e.legendIcon,d)}return E.createElement(iD,{fill:o,cx:i,cy:i,size:Vs,sizeType:"diameter",type:c})}function khe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,o={x:0,y:0,width:Vs,height:Vs},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,m=Mn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var b=d.inactive?a:d.color,y=g?g(d.value,d,f):d.value;return E.createElement("li",O1({className:m,style:c,key:"legend-item-".concat(f)},vb(t,d,f)),E.createElement(ZR,{width:n,height:n,viewBox:o,style:u,"aria-label":"".concat(y," legend icon")},E.createElement(Nhe,{data:d,iconType:s,inactiveColor:a})),E.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},y))})}var Phe=t=>{var e=Sr(t,Che),{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 E.createElement("ul",{className:"recharts-default-legend",style:a},E.createElement(khe,O1({},e,{payload:n})))},VA={},GA={},yU;function Rhe(){return yU||(yU=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 s=n[a],o=r(s);i.has(o)||i.set(o,s)}return Array.from(i.values())}t.uniqBy=e})(GA)),GA}var WA={},vU;function JG(){return vU||(vU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(WA)),WA}var qA={},KA={},XA={},_U;function Dhe(){return _U||(_U=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(XA)),XA}var wU;function sD(){return wU||(wU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dhe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(KA)),KA}var YA={},SU;function jhe(){return SU||(SU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(YA)),YA}var MU;function Ohe(){return MU||(MU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sD(),n=jhe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(qA)),qA}var ZA={},QA={},EU;function Lhe(){return EU||(EU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(QA)),QA}var JA={},eT={},tT={},nT={},AU;function eW(){return AU||(AU=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})(nT)),nT}var rT={},TU;function tW(){return TU||(TU=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})(rT)),rT}var iT={},CU;function nW(){return CU||(CU=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})(iT)),iT}var NU;function Ihe(){return NU||(NU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eW(),n=tW(),r=nW();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function m(b,y,v,x,M,S){const A=g(b,y,v,x,M,S);return A!==void 0?!!A:a(b,y,m,S)},new Map)}function a(d,f,g,m){if(f===d)return!0;switch(typeof f){case"object":return s(d,f,g,m);case"function":return Object.keys(f).length>0?a(d,{...f},g,m):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function s(d,f,g,m){if(f==null)return!0;if(Array.isArray(f))return c(d,f,g,m);if(f instanceof Map)return o(d,f,g,m);if(f instanceof Set)return u(d,f,g,m);const b=Object.keys(f);if(d==null)return b.length===0;if(b.length===0)return!0;if(m?.has(f))return m.get(f)===d;m?.set(f,d);try{for(let y=0;y<b.length;y++){const v=b[y];if(!n.isPrimitive(d)&&!(v in d)||f[v]===void 0&&d[v]!==void 0||f[v]===null&&d[v]!==null||!g(d[v],f[v],v,d,f,m))return!1}return!0}finally{m?.delete(f)}}function o(d,f,g,m){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[b,y]of f.entries()){const v=d.get(b);if(g(v,y,b,d,f,m)===!1)return!1}return!0}function c(d,f,g,m){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const b=new Set;for(let y=0;y<f.length;y++){const v=f[y];let x=!1;for(let M=0;M<d.length;M++){if(b.has(M))continue;const S=d[M];let A=!1;if(g(S,v,y,d,f,m)&&(A=!0),A){b.add(M),x=!0;break}}if(!x)return!1}return!0}function u(d,f,g,m){return f.size===0?!0:d instanceof Set?c([...d],[...f],g,m):!1}t.isMatchWith=i,t.isSetMatch=u})(tT)),tT}var kU;function rW(){return kU||(kU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ihe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(eT)),eT}var aT={},sT={},oT={},PU;function Fhe(){return PU||(PU=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})(oT)),oT}var lT={},RU;function iW(){return RU||(RU=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})(lT)),lT}var cT={},DU;function aW(){return DU||(DU=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]",s="[object Symbol]",o="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",m="[object Object]",b="[object Error]",y="[object DataView]",v="[object Uint8Array]",x="[object Uint8ClampedArray]",M="[object Uint16Array]",S="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",I="[object BigInt64Array]",C="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=I,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=o,t.errorTag=b,t.float32ArrayTag=C,t.float64ArrayTag=D,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=N,t.int8ArrayTag=T,t.mapTag=c,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=M,t.uint32ArrayTag=S,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=x})(cT)),cT}var uT={},jU;function Uhe(){return jU||(jU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(uT)),uT}var OU;function sW(){return OU||(OU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fhe(),n=iW(),r=aW(),i=tW(),a=Uhe();function s(d,f){return o(d,void 0,d,new Map,f)}function o(d,f,g,m=new Map,b=void 0){const y=b?.(d,f,g,m);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const v=new Array(d.length);m.set(d,v);for(let x=0;x<d.length;x++)v[x]=o(d[x],x,g,m,b);return Object.hasOwn(d,"index")&&(v.index=d.index),Object.hasOwn(d,"input")&&(v.input=d.input),v}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const v=new RegExp(d.source,d.flags);return v.lastIndex=d.lastIndex,v}if(d instanceof Map){const v=new Map;m.set(d,v);for(const[x,M]of d)v.set(x,o(M,x,g,m,b));return v}if(d instanceof Set){const v=new Set;m.set(d,v);for(const x of d)v.add(o(x,void 0,g,m,b));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const v=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,v);for(let x=0;x<d.length;x++)v[x]=o(d[x],x,g,m,b);return v}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const v=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,v),c(v,d,g,m,b),v}if(typeof File<"u"&&d instanceof File){const v=new File([d],d.name,{type:d.type});return m.set(d,v),c(v,d,g,m,b),v}if(typeof Blob<"u"&&d instanceof Blob){const v=new Blob([d],{type:d.type});return m.set(d,v),c(v,d,g,m,b),v}if(d instanceof Error){const v=new d.constructor;return m.set(d,v),v.message=d.message,v.name=d.name,v.stack=d.stack,v.cause=d.cause,c(v,d,g,m,b),v}if(d instanceof Boolean){const v=new Boolean(d.valueOf());return m.set(d,v),c(v,d,g,m,b),v}if(d instanceof Number){const v=new Number(d.valueOf());return m.set(d,v),c(v,d,g,m,b),v}if(d instanceof String){const v=new String(d.valueOf());return m.set(d,v),c(v,d,g,m,b),v}if(typeof d=="object"&&u(d)){const v=Object.create(Object.getPrototypeOf(d));return m.set(d,v),c(v,d,g,m,b),v}return d}function c(d,f,g=d,m,b){const y=[...Object.keys(f),...e.getSymbols(f)];for(let v=0;v<y.length;v++){const x=y[v],M=Object.getOwnPropertyDescriptor(d,x);(M==null||M.writable)&&(d[x]=o(f[x],x,g,m,b))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=s,t.cloneDeepWithImpl=o,t.copyProperties=c})(sT)),sT}var LU;function zhe(){return LU||(LU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(aT)),aT}var IU;function Bhe(){return IU||(IU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rW(),n=zhe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(JA)),JA}var dT={},hT={},fT={},FU;function Hhe(){return FU||(FU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sW(),n=aW();function r(i,a){return e.cloneDeepWith(i,(s,o,c,u)=>{const d=a?.(s,o,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})(fT)),fT}var UU;function $he(){return UU||(UU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hhe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(hT)),hT}var pT={},mT={},zU;function oW(){return zU||(zU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return e.test(r)}}t.isIndex=n})(mT)),mT}var gT={},BU;function Vhe(){return BU||(BU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(gT)),gT}var HU;function Ghe(){return HU||(HU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KG(),n=oW(),r=Vhe(),i=nD();function a(s,o){let c;if(Array.isArray(o)?c=o:typeof o=="string"&&e.isDeepKey(o)&&s?.[o]==null?c=i.toPath(o):c=[o],c.length===0)return!1;let u=s;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})(pT)),pT}var $U;function Whe(){return $U||($U=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rW(),n=tD(),r=$he(),i=rD(),a=Ghe();function s(o,c){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,o);return d===void 0?a.has(u,o):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=s})(dT)),dT}var VU;function qhe(){return VU||(VU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JG(),n=Lhe(),r=Bhe(),i=Whe();function a(s){if(s==null)return e.identity;switch(typeof s){case"function":return s;case"object":return Array.isArray(s)&&s.length===2?i.matchesProperty(s[0],s[1]):r.matches(s);case"string":case"symbol":case"number":return n.property(s)}}t.iteratee=a})(ZA)),ZA}var GU;function Khe(){return GU||(GU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rhe(),n=JG(),r=Ohe(),i=qhe();function a(s,o=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(o)):[]}t.uniqBy=a})(VA)),VA}var xT,WU;function Xhe(){return WU||(WU=1,xT=Khe().uniqBy),xT}var Yhe=Xhe();const qU=fo(Yhe);function lW(t,e,n){return e===!0?qU(t,n):typeof e=="function"?qU(t,e):t}var bT={exports:{}},yT={};var KU;function Zhe(){if(KU)return yT;KU=1;var t=$m(),e=C9();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,s=t.useEffect,o=t.useMemo,c=t.useDebugValue;return yT.useSyncExternalStoreWithSelector=function(u,d,f,g,m){var b=a(null);if(b.current===null){var y={hasValue:!1,value:null};b.current=y}else y=b.current;b=o(function(){function x(k){if(!M){if(M=!0,S=k,k=g(k),m!==void 0&&y.hasValue){var N=y.value;if(m(N,k))return A=N}return A=k}if(N=A,r(S,k))return N;var I=g(k);return m!==void 0&&m(N,I)?(S=k,N):(S=k,A=I)}var M=!1,S,A,T=f===void 0?null:f;return[function(){return x(d())},T===null?void 0:function(){return x(T())}]},[d,f,g,m]);var v=i(u,b[0],b[1]);return s(function(){y.hasValue=!0,y.value=v},[v]),c(v),v},yT}var XU;function Qhe(){return XU||(XU=1,bT.exports=Zhe()),bT.exports}var cW=Qhe(),oD=E.createContext(null),Jhe=t=>t,rr=()=>{var t=E.useContext(oD);return t?t.store.dispatch:Jhe},J_=()=>{},efe=()=>J_,tfe=(t,e)=>t===e;function Ct(t){var e=E.useContext(oD);return cW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:efe,e?e.store.getState:J_,e?e.store.getState:J_,e?t:J_,tfe)}function nfe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function rfe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function ife(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 YU=t=>Array.isArray(t)?t:[t];function afe(t){const e=Array.isArray(t[0])?t[0]:t;return ife(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function sfe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var ofe=class{constructor(t){this.value=t}deref(){return this.value}},lfe=typeof WeakRef<"u"?WeakRef:ofe,cfe=0,ZU=1;function bv(){return{s:cfe,v:void 0,o:null,p:null}}function uW(t,e={}){let n=bv();const{resultEqualityCheck:r}=e;let i,a=0;function s(){let o=n;const{length:c}=arguments;for(let f=0,g=c;f<g;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let b=o.o;b===null&&(o.o=b=new WeakMap);const y=b.get(m);y===void 0?(o=bv(),b.set(m,o)):o=y}else{let b=o.p;b===null&&(o.p=b=new Map);const y=b.get(m);y===void 0?(o=bv(),b.set(m,o)):o=y}}const u=o;let d;if(o.s===ZU)d=o.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 lfe(d):d}return u.s=ZU,u.v=d,d}return s.clearCache=()=>{n=bv(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function ufe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,s=0,o,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),nfe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:m=uW,argsMemoizeOptions:b=[]}=d,y=YU(g),v=YU(b),x=afe(i),M=f(function(){return a++,u.apply(null,arguments)},...y),S=m(function(){s++;const T=sfe(x,arguments);return o=M.apply(null,T),o},...v);return Object.assign(S,{resultFunc:u,memoizedResultFunc:M,dependencies:x,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>o,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var Ge=ufe(uW),dfe=Object.assign((t,e=Ge)=>{rfe(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((s,o,c)=>(s[n[c]]=o,s),{}))},{withTypes:()=>dfe}),vT={},_T={},wT={},QU;function hfe(){return QU||(QU=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 s=e(r),o=e(i);if(s===o&&s===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?o-s:s-o}return 0};t.compareValues=n})(wT)),wT}var ST={},MT={},JU;function dW(){return JU||(JU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(MT)),MT}var ez;function ffe(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dW(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,s){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))||s!=null&&Object.hasOwn(s,a)}t.isKey=i})(ST)),ST}var tz;function pfe(){return tz||(tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hfe(),n=ffe(),r=nD();function i(a,s,o,c){if(a==null)return[];o=c?void 0:o,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const u=(m,b)=>{let y=m;for(let v=0;v<b.length&&y!=null;++v)y=y[b[v]];return y},d=(m,b)=>b==null||m==null?b:typeof m=="object"&&"key"in m?Object.hasOwn(b,m.key)?b[m.key]:u(b,m.path):typeof m=="function"?m(b):Array.isArray(m)?u(b,m):typeof b=="object"?b[m]:b,f=s.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return a.map(m=>({original:m,criteria:f.map(b=>d(b,m))})).slice().sort((m,b)=>{for(let y=0;y<f.length;y++){const v=e.compareValues(m.criteria[y],b.criteria[y],o[y]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=i})(_T)),_T}var ET={},nz;function mfe(){return nz||(nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),s=(o,c)=>{for(let u=0;u<o.length;u++){const d=o[u];Array.isArray(d)&&c<a?s(d,c+1):i.push(d)}};return s(n,0),i}t.flatten=e})(ET)),ET}var AT={},rz;function hW(){return rz||(rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oW(),n=sD(),r=eW(),i=nW();function a(s,o,c){return r.isObject(c)&&(typeof o=="number"&&n.isArrayLike(c)&&e.isIndex(o)&&o<c.length||typeof o=="string"&&o in c)?i.eq(c[o],s):!1}t.isIterateeCall=a})(AT)),AT}var iz;function gfe(){return iz||(iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pfe(),n=mfe(),r=hW();function i(a,...s){const o=s.length;return o>1&&r.isIterateeCall(a,s[0],s[1])?s=[]:o>2&&r.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=i})(vT)),vT}var TT,az;function xfe(){return az||(az=1,TT=gfe().sortBy),TT}var bfe=xfe();const KS=fo(bfe);var fW=t=>t.legend.settings,yfe=t=>t.legend.size,vfe=t=>t.legend.payload,_fe=Ge([vfe,fW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?KS(r,n):r});function wfe(){return Ct(_fe)}var yv=1;function pW(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=E.useState({height:0,left:0,top:0,width:0}),r=E.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),s={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(s.height-e.height)>yv||Math.abs(s.left-e.left)>yv||Math.abs(s.top-e.top)>yv||Math.abs(s.width-e.width)>yv)&&n({height:s.height,left:s.left,top:s.top,width:s.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function Xi(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 Sfe=typeof Symbol=="function"&&Symbol.observable||"@@observable",sz=Sfe,CT=()=>Math.random().toString(36).substring(7).split("").join("."),Mfe={INIT:`@@redux/INIT${CT()}`,REPLACE:`@@redux/REPLACE${CT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${CT()}`},L1=Mfe;function lD(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 mW(t,e,n){if(typeof t!="function")throw new Error(Xi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Xi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Xi(1));return n(mW)(t,e)}let r=t,i=e,a=new Map,s=a,o=0,c=!1;function u(){s===a&&(s=new Map,a.forEach((v,x)=>{s.set(x,v)}))}function d(){if(c)throw new Error(Xi(3));return i}function f(v){if(typeof v!="function")throw new Error(Xi(4));if(c)throw new Error(Xi(5));let x=!0;u();const M=o++;return s.set(M,v),function(){if(x){if(c)throw new Error(Xi(6));x=!1,u(),s.delete(M),a=null}}}function g(v){if(!lD(v))throw new Error(Xi(7));if(typeof v.type>"u")throw new Error(Xi(8));if(typeof v.type!="string")throw new Error(Xi(17));if(c)throw new Error(Xi(9));try{c=!0,i=r(i,v)}finally{c=!1}return(a=s).forEach(M=>{M()}),v}function m(v){if(typeof v!="function")throw new Error(Xi(10));r=v,g({type:L1.REPLACE})}function b(){const v=f;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(Xi(11));function M(){const A=x;A.next&&A.next(d())}return M(),{unsubscribe:v(M)}},[sz](){return this}}}return g({type:L1.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:m,[sz]:b}}function Efe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:L1.INIT})>"u")throw new Error(Xi(12));if(typeof n(void 0,{type:L1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Xi(13))})}function gW(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const s=e[a];typeof t[s]=="function"&&(n[s]=t[s])}const r=Object.keys(n);let i;try{Efe(n)}catch(a){i=a}return function(s={},o){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],m=s[f],b=g(m,o);if(typeof b>"u")throw o&&o.type,new Error(Xi(14));u[f]=b,c=c||b!==m}return c=c||r.length!==Object.keys(s).length,c?u:s}}function I1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Afe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(Xi(15))};const s={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},o=t.map(c=>c(s));return a=I1(...o)(i.dispatch),{...i,dispatch:a}}}function xW(t){return lD(t)&&"type"in t&&typeof t.type=="string"}var bW=Symbol.for("immer-nothing"),oz=Symbol.for("immer-draftable"),Na=Symbol.for("immer-state");function To(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ys=Object,ym=ys.getPrototypeOf,F1="constructor",XS="prototype",Gk="configurable",U1="enumerable",e1="writable",C0="value",kc=t=>!!t&&!!t[Na];function Uo(t){return t?yW(t)||YS(t)||!!t[oz]||!!t[F1]?.[oz]||ZS(t)||QS(t):!1}var Tfe=ys[XS][F1].toString(),lz=new WeakMap;function yW(t){if(!t||!cD(t))return!1;const e=ym(t);if(e===null||e===ys[XS])return!0;const n=ys.hasOwnProperty.call(e,F1)&&e[F1];if(n===Object)return!0;if(!Ip(n))return!1;let r=lz.get(n);return r===void 0&&(r=Function.toString.call(n),lz.set(n,r)),r===Tfe}function _b(t,e,n=!0){wb(t)===0?(n?Reflect.ownKeys(t):ys.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function wb(t){const e=t[Na];return e?e.type_:YS(t)?1:ZS(t)?2:QS(t)?3:0}var cz=(t,e,n=wb(t))=>n===2?t.has(e):ys[XS].hasOwnProperty.call(t,e),Wk=(t,e,n=wb(t))=>n===2?t.get(e):t[e],z1=(t,e,n,r=wb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Cfe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var YS=Array.isArray,ZS=t=>t instanceof Map,QS=t=>t instanceof Set,cD=t=>typeof t=="object",Ip=t=>typeof t=="function",NT=t=>typeof t=="boolean",lc=t=>t.copy_||t.base_,uD=t=>t.modified_?t.copy_:t.base_;function qk(t,e){if(ZS(t))return new Map(t);if(QS(t))return new Set(t);if(YS(t))return Array[XS].slice.call(t);const n=yW(t);if(e===!0||e==="class_only"&&!n){const r=ys.getOwnPropertyDescriptors(t);delete r[Na];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[e1]===!1&&(o[e1]=!0,o[Gk]=!0),(o.get||o.set)&&(r[s]={[Gk]:!0,[e1]:!0,[U1]:o[U1],[C0]:t[s]})}return ys.create(ym(t),r)}else{const r=ym(t);if(r!==null&&n)return{...t};const i=ys.create(r);return ys.assign(i,t)}}function dD(t,e=!1){return JS(t)||kc(t)||!Uo(t)||(wb(t)>1&&ys.defineProperties(t,{set:vv,add:vv,clear:vv,delete:vv}),ys.freeze(t),e&&_b(t,(n,r)=>{dD(r,!0)},!1)),t}function Nfe(){To(2)}var vv={[C0]:Nfe};function JS(t){return t===null||!cD(t)?!0:ys.isFrozen(t)}var B1="MapSet",Kk="Patches",vW={};function vm(t){const e=vW[t];return e||To(0,t),e}var kfe=t=>!!vW[t],N0,_W=()=>N0,Pfe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:kfe(B1)?vm(B1):void 0});function uz(t,e){e&&(t.patchPlugin_=vm(Kk),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Xk(t){Yk(t),t.drafts_.forEach(Rfe),t.drafts_=null}function Yk(t){t===N0&&(N0=t.parent_)}var dz=t=>N0=Pfe(N0,t);function Rfe(t){const e=t[Na];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function hz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Na].modified_&&(Xk(e),To(4)),Uo(t)&&(t=fz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Na].base_,t,e)}else t=fz(e,n);return Dfe(e,t,!0),Xk(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==bW?t:void 0}function fz(t,e){if(JS(e))return e;const n=e[Na];if(!n)return hD(e,t.handledSet_,t);if(!eM(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);MW(n,t)}return n.copy_}function Dfe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&dD(e,n)}function wW(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var eM=(t,e)=>t.scope_===e,jfe=[];function SW(t,e,n,r){const i=lc(t),a=t.type_;if(r!==void 0&&Wk(i,r,a)===e){z1(i,r,n,a);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;_b(i,(c,u)=>{if(kc(u)){const d=o.get(u)||[];d.push(c),o.set(u,d)}})}const s=t.draftLocations_.get(e)??jfe;for(const o of s)z1(i,o,n,a)}function Ofe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!eM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=uD(a);SW(t,a.draft_??a,s,n),MW(a,i)})}function MW(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)}wW(t)}}function Lfe(t,e,n){const{scope_:r}=t;if(kc(n)){const i=n[Na];eM(i,r)&&i.callbacks_.push(function(){t1(t);const s=uD(i);SW(t,n,s,e)})}else Uo(n)&&t.callbacks_.push(function(){const a=lc(t);Wk(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&hD(Wk(t.copy_,e,t.type_),r.handledSet_,r)})}function hD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||kc(t)||e.has(t)||!Uo(t)||JS(t)||(e.add(t),_b(t,(r,i)=>{if(kc(i)){const a=i[Na];if(eM(a,n)){const s=uD(a);z1(t,r,s,t.type_),wW(a)}}else Uo(i)&&hD(i,e,n)})),t}function Ife(t,e){const n=YS(t),r={type_:n?1:0,scope_:e?e.scope_:_W(),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=fD;n&&(i=[r],a=k0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var fD={get(t,e){if(e===Na)return t;const n=lc(t);if(!cz(n,e,t.type_))return Ffe(t,n,e);const r=n[e];if(t.finalized_||!Uo(r))return r;if(r===kT(t.base_,e)){t1(t);const i=t.type_===1?+e:e,a=Qk(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in lc(t)},ownKeys(t){return Reflect.ownKeys(lc(t))},set(t,e,n){const r=EW(lc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=kT(lc(t),e),a=i?.[Na];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Cfe(n,i)&&(n!==void 0||cz(t.base_,e,t.type_)))return!0;t1(t),Zk(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),Lfe(t,e,n)),!0},deleteProperty(t,e){return t1(t),kT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Zk(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=lc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[e1]:!0,[Gk]:t.type_!==1||e!=="length",[U1]:r[U1],[C0]:n[e]}},defineProperty(){To(11)},getPrototypeOf(t){return ym(t.base_)},setPrototypeOf(){To(12)}},k0={};_b(fD,(t,e)=>{k0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});k0.deleteProperty=function(t,e){return k0.set.call(this,t,e,void 0)};k0.set=function(t,e,n){return fD.set.call(this,t[0],e,n,t[0])};function kT(t,e){const n=t[Na];return(n?lc(n):t)[e]}function Ffe(t,e,n){const r=EW(e,n);return r?C0 in r?r[C0]:r.get?.call(t.draft_):void 0}function EW(t,e){if(!(e in t))return;let n=ym(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=ym(n)}}function Zk(t){t.modified_||(t.modified_=!0,t.parent_&&Zk(t.parent_))}function t1(t){t.copy_||(t.assigned_=new Map,t.copy_=qk(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Ufe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Ip(n)&&!Ip(r)){const s=r;r=n;const o=this;return function(u=s,...d){return o.produce(u,f=>r.call(this,f,...d))}}Ip(r)||To(6),i!==void 0&&!Ip(i)&&To(7);let a;if(Uo(n)){const s=dz(this),o=Qk(s,n,void 0);let c=!0;try{a=r(o),c=!1}finally{c?Xk(s):Yk(s)}return uz(s,i),hz(a,s)}else if(!n||!cD(n)){if(a=r(n),a===void 0&&(a=n),a===bW&&(a=void 0),this.autoFreeze_&&dD(a,!0),i){const s=[],o=[];vm(Kk).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:o}),i(s,o)}return a}else To(1,n)},this.produceWithPatches=(n,r)=>{if(Ip(n))return(o,...c)=>this.produceWithPatches(o,u=>n(u,...c));let i,a;return[this.produce(n,r,(o,c)=>{i=o,a=c}),i,a]},NT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),NT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),NT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Uo(e)||To(8),kc(e)&&(e=Lo(e));const n=dz(this),r=Qk(n,e,void 0);return r[Na].isManual_=!0,Yk(n),r}finishDraft(e,n){const r=e&&e[Na];(!r||!r.isManual_)&&To(9);const{scope_:i}=r;return uz(i,n),hz(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=vm(Kk).applyPatches_;return kc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function Qk(t,e,n,r){const[i,a]=ZS(e)?vm(B1).proxyMap_(e,n):QS(e)?vm(B1).proxySet_(e,n):Ife(e,n);return(n?.scope_??_W()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Ofe(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 Lo(t){return kc(t)||To(10,t),AW(t)}function AW(t){if(!Uo(t)||JS(t))return t;const e=t[Na];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=qk(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=qk(t,!0);return _b(n,(i,a)=>{z1(n,i,AW(a))},r),e&&(e.finalized_=!1),n}var zfe=new Ufe,TW=zfe.produce;function CW(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Bfe=CW(),Hfe=CW,$fe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?I1:I1.apply(null,arguments)};function uo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(_s(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=>xW(r)&&r.type===t,n}var NW=class Dx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Dx.prototype)}static get[Symbol.species](){return Dx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Dx(...e[0].concat(this)):new Dx(...e.concat(this))}};function pz(t){return Uo(t)?TW(t,()=>{}):t}function _v(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Vfe(t){return typeof t=="boolean"}var Gfe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new NW;return n&&(Vfe(n)?s.push(Bfe):s.push(Hfe(n.extraArgument))),s},kW="RTK_autoBatch",fr=()=>t=>({payload:t,meta:{[kW]:!0}}),mz=t=>e=>{setTimeout(e,t)},PW=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,s=!1;const o=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:mz(10):t.type==="callback"?t.queueNotification:mz(t.timeout),u=()=>{s=!1,a&&(a=!1,o.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return o.add(d),()=>{g(),o.delete(d)}},dispatch(d){try{return i=!d?.meta?.[kW],a=!i,a&&(s||(s=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Wfe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new NW(t);return r&&i.push(PW(typeof r=="object"?r:void 0)),i};function qfe(t){const e=Gfe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(lD(n))o=gW(n);else throw new Error(_s(1));let c;typeof r=="function"?c=r(e):c=e();let u=I1;i&&(u=$fe({trace:!1,...typeof i=="object"&&i}));const d=Afe(...c),f=Wfe(d);let g=typeof s=="function"?s(f):f();const m=u(...g);return mW(o,a,m)}function RW(t){const e={},n=[];let r;const i={addCase(a,s){const o=typeof a=="string"?a:a.type;if(!o)throw new Error(_s(28));if(o in e)throw new Error(_s(29));return e[o]=s,i},addAsyncThunk(a,s){return s.pending&&(e[a.pending.type]=s.pending),s.rejected&&(e[a.rejected.type]=s.rejected),s.fulfilled&&(e[a.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:a.settled,reducer:s.settled}),i},addMatcher(a,s){return n.push({matcher:a,reducer:s}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function Kfe(t){return typeof t=="function"}function Xfe(t,e){let[n,r,i]=RW(e),a;if(Kfe(t))a=()=>pz(t());else{const o=pz(t);a=()=>o}function s(o=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(kc(d)){const m=f(d,c);return m===void 0?d:m}else{if(Uo(d))return TW(d,g=>f(g,c));{const g=f(d,c);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},o)}return s.getInitialState=a,s}var Yfe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Zfe=(t=21)=>{let e="",n=t;for(;n--;)e+=Yfe[Math.random()*64|0];return e},Qfe=Symbol.for("rtk-slice-createasyncthunk");function Jfe(t,e){return`${t}/${e}`}function epe({creators:t}={}){const e=t?.asyncThunk?.[Qfe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(_s(11));const s=(typeof r.reducers=="function"?r.reducers(npe()):r.reducers)||{},o=Object.keys(s),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,A){const T=typeof S=="string"?S:S.type;if(!T)throw new Error(_s(12));if(T in c.sliceCaseReducersByType)throw new Error(_s(13));return c.sliceCaseReducersByType[T]=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}};o.forEach(S=>{const A=s[S],T={reducerName:S,type:Jfe(i,S),createNotation:typeof r.reducers=="function"};ipe(A)?spe(T,A,u,e):rpe(T,A,u)});function d(){const[S={},A=[],T=void 0]=typeof r.extraReducers=="function"?RW(r.extraReducers):[r.extraReducers],k={...S,...c.sliceCaseReducersByType};return Xfe(r.initialState,N=>{for(let I in k)N.addCase(I,k[I]);for(let I of c.sliceMatchers)N.addMatcher(I.matcher,I.reducer);for(let I of A)N.addMatcher(I.matcher,I.reducer);T&&N.addDefaultCase(T)})}const f=S=>S,g=new Map,m=new WeakMap;let b;function y(S,A){return b||(b=d()),b(S,A)}function v(){return b||(b=d()),b.getInitialState()}function x(S,A=!1){function T(N){let I=N[S];return typeof I>"u"&&A&&(I=_v(m,T,v)),I}function k(N=f){const I=_v(g,A,()=>new WeakMap);return _v(I,N,()=>{const C={};for(const[D,F]of Object.entries(r.selectors??{}))C[D]=tpe(F,N,()=>_v(m,N,v),A);return C})}return{reducerPath:S,getSelectors:k,get selectors(){return k(T)},selectSlice:T}}const M={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:v,...x(a),injectInto(S,{reducerPath:A,...T}={}){const k=A??a;return S.inject({reducerPath:k,reducer:y},T),{...M,...x(k,!0)}}};return M}}function tpe(t,e,n,r){function i(a,...s){let o=e(a);return typeof o>"u"&&r&&(o=n()),t(o,...s)}return i.unwrapped=t,i}var Qa=epe();function npe(){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 rpe({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!ape(r))throw new Error(_s(17));a=r.reducer,s=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?uo(t,s):uo(t))}function ipe(t){return t._reducerDefinitionType==="asyncThunk"}function ape(t){return t._reducerDefinitionType==="reducerWithPrepare"}function spe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(_s(18));const{payloadCreator:a,fulfilled:s,pending:o,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),s&&r.addCase(f.fulfilled,s),o&&r.addCase(f.pending,o),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:s||wv,pending:o||wv,rejected:c||wv,settled:u||wv})}function wv(){}var ope="task",DW="listener",jW="completed",pD="cancelled",lpe=`task-${pD}`,cpe=`task-${jW}`,Jk=`${DW}-${pD}`,upe=`${DW}-${jW}`,tM=class{constructor(t){this.code=t,this.message=`${ope} ${pD} (reason: ${t})`}name="TaskAbortError";message},mD=(t,e)=>{if(typeof t!="function")throw new TypeError(_s(32))},H1=()=>{},OW=(t,e=H1)=>(t.catch(e),t),LW=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Mh=(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))},Eh=t=>{if(t.aborted){const{reason:e}=t;throw new tM(e)}};function IW(t,e){let n=H1;return new Promise((r,i)=>{const a=()=>i(new tM(t.reason));if(t.aborted){a();return}n=LW(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=H1})}var dpe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof tM?"cancelled":"rejected",error:n}}finally{e?.()}},$1=t=>e=>OW(IW(t,e).then(n=>(Eh(t),n))),FW=t=>{const e=$1(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Jp}=Object,gz={},nM="listenerMiddleware",hpe=(t,e)=>{const n=r=>LW(t,()=>Mh(r,t.reason));return(r,i)=>{mD(r);const a=new AbortController;n(a);const s=dpe(async()=>{Eh(t),Eh(a.signal);const o=await r({pause:$1(a.signal),delay:FW(a.signal),signal:a.signal});return Eh(a.signal),o},()=>Mh(a,cpe));return i?.autoJoin&&e.push(s.catch(H1)),{result:$1(t)(s),cancel(){Mh(a,lpe)}}}},fpe=(t,e)=>{const n=async(r,i)=>{Eh(e);let a=()=>{};const o=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),c([f,g.getState(),g.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&o.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await IW(e,Promise.race(o));return Eh(e),c}finally{a()}};return(r,i)=>OW(n(r,i))},UW=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=uo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(_s(21));return mD(a),{predicate:i,type:e,effect:a}},zW=Jp(t=>{const{type:e,predicate:n,effect:r}=UW(t);return{id:Zfe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(_s(22))}}},{withTypes:()=>zW}),xz=(t,e)=>{const{type:n,effect:r,predicate:i}=UW(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},e3=t=>{t.pending.forEach(e=>{Mh(e,Jk)})},ppe=(t,e)=>()=>{for(const n of e.keys())e3(n);t.clear()},bz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},BW=Jp(uo(`${nM}/add`),{withTypes:()=>BW}),mpe=uo(`${nM}/removeAll`),HW=Jp(uo(`${nM}/remove`),{withTypes:()=>HW}),gpe=(...t)=>{console.error(`${nM}/error`,...t)},Sb=(t={})=>{const e=new Map,n=new Map,r=m=>{const b=n.get(m)??0;n.set(m,b+1)},i=m=>{const b=n.get(m)??1;b===1?n.delete(m):n.set(m,b-1)},{extra:a,onError:s=gpe}=t;mD(s);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),b=>{m.unsubscribe(),b?.cancelActive&&e3(m)}),c=m=>{const b=xz(e,m)??zW(m);return o(b)};Jp(c,{withTypes:()=>c});const u=m=>{const b=xz(e,m);return b&&(b.unsubscribe(),m.cancelActive&&e3(b)),!!b};Jp(u,{withTypes:()=>u});const d=async(m,b,y,v)=>{const x=new AbortController,M=fpe(c,x.signal),S=[];try{m.pending.add(x),r(m),await Promise.resolve(m.effect(b,Jp({},y,{getOriginalState:v,condition:(A,T)=>M(A,T).then(Boolean),take:M,delay:FW(x.signal),pause:$1(x.signal),extra:a,signal:x.signal,fork:hpe(x.signal,S),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((A,T,k)=>{A!==x&&(Mh(A,Jk),k.delete(A))})},cancel:()=>{Mh(x,Jk),m.pending.delete(x)},throwIfCancelled:()=>{Eh(x.signal)}})))}catch(A){A instanceof tM||bz(s,A,{raisedBy:"effect"})}finally{await Promise.all(S),Mh(x,upe),i(m),m.pending.delete(x)}},f=ppe(e,n);return{middleware:m=>b=>y=>{if(!xW(y))return b(y);if(BW.match(y))return c(y.payload);if(mpe.match(y)){f();return}if(HW.match(y))return u(y.payload);let v=m.getState();const x=()=>{if(v===gz)throw new Error(_s(23));return v};let M;try{if(M=b(y),e.size>0){const S=m.getState(),A=Array.from(e.values());for(const T of A){let k=!1;try{k=T.predicate(y,S,v)}catch(N){k=!1,bz(s,N,{raisedBy:"predicate"})}k&&d(T,y,m,x)}}}finally{v=gz}return M},startListening:c,stopListening:u,clearListeners:f}};function _s(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 xpe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},$W=Qa({name:"chartLayout",initialState:xpe,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:bpe,setLayout:ype,setChartSize:vpe,setScale:_pe}=$W.actions,wpe=$W.reducer;function VW(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function yz(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 Vp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yz(Object(n),!0).forEach(function(r){Spe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Spe(t,e,n){return(e=Mpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mpe(t){var e=Epe(t,"string");return typeof e=="symbol"?e:e+""}function Epe(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 Bn(t,e,n){return dr(t)||dr(e)?n:co(e)?Wh(t,e,n):typeof e=="function"?e(t):n}var Ape=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:s,layout:o}=e;if((o==="vertical"||o==="horizontal"&&s==="middle")&&a!=="center"&&Pt(t[a]))return Vp(Vp({},t),{},{[a]:t[a]+(r||0)});if((o==="horizontal"||o==="vertical"&&a==="center")&&s!=="middle"&&Pt(t[s]))return Vp(Vp({},t),{},{[s]:t[s]+(i||0)})}return t},wl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",GW=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,a,s=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(a=!0),o.coordinate));return i||s.push(e),a||s.push(n),s},WW=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:s,realScaleType:o,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:m}=t;if(!s)return null;var b=o==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,y=i==="category"&&s.bandwidth?s.bandwidth()/b:0;if(y=m==="angleAxis"&&a&&a.length>=2?Li(a[0]-a[1])*2*y:y,f||g){var v=(f||g||[]).map((x,M)=>{var S=r?r.indexOf(x):x;return{coordinate:s(S)+y,value:x,offset:y,index:M}});return v.filter(x=>!Za(x.coordinate))}return c&&u?u.map((x,M)=>({coordinate:s(x)+y,value:x,index:M,offset:y})):s.ticks&&d!=null?s.ticks(d).map((x,M)=>({coordinate:s(x)+y,value:x,offset:y,index:M})):s.domain().map((x,M)=>({coordinate:s(x)+y,value:r?r[x]:x,index:M,offset:y}))},vz=1e-4,Tpe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-vz,a=Math.max(r[0],r[1])+vz,s=t(e[0]),o=t(e[n-1]);(s<i||s>a||o<i||o>a)&&t.domain([e[0],e[n-1]])}},Cpe=(t,e)=>{if(!e||e.length!==2||!Pt(e[0])||!Pt(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(!Pt(t[0])||t[0]<n)&&(i[0]=n),(!Pt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Npe=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,s=0;s<e;++s){var o=Za(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+o,a=t[s][n][1])}},kpe=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 s=Za(t[a][n][1])?t[a][n][0]:t[a][n][1];s>=0?(t[a][n][0]=i,t[a][n][1]=i+s,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},Ppe={sign:Npe,expand:ehe,none:bm,silhouette:the,wiggle:nhe,positive:kpe},Rpe=(t,e,n)=>{var r=Ppe[n],i=Jde().keys(e).value((a,s)=>Number(Bn(a,s,0))).order($k).offset(r);return i(t)};function qW(t){return t==null?void 0:String(t)}function V1(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!dr(i[e.dataKey])){var o=YG(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Bn(i,dr(s)?e.dataKey:s);return dr(c)?null:e.scale(c)}var _z=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:s}=t;if(e.type==="category")return n[s]?n[s].coordinate+r:null;var o=Bn(a,e.dataKey,e.scale.domain()[s]);return dr(o)?null:e.scale(o)-i/2+r},Dpe=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]},jpe=t=>{var e=t.flat(2).filter(Pt);return[Math.min(...e),Math.max(...e)]},Ope=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Lpe=(t,e,n)=>{if(t!=null)return Ope(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,o=s.reduce((c,u)=>{var d=VW(u,e,n),f=jpe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},wz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Sz=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,sd=(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=KS(e,d=>d.coordinate),a=1/0,s=1,o=i.length;s<o;s++){var c=i[s],u=i[s-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function Mz(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Vp(Vp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function vd(t,e){if(t)return String(t);if(typeof e=="string")return e}var Ipe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Fpe=(t,e)=>e==="centric"?t.angle:t.radius,Fc=t=>t.layout.width,Uc=t=>t.layout.height,Upe=t=>t.layout.scale,KW=t=>t.layout.margin,rM=Ge(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),iM=Ge(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),XW="data-recharts-item-index",YW="data-recharts-item-data-key",Mb=60;function Ez(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 Sv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ez(Object(n),!0).forEach(function(r){zpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ez(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zpe(t,e,n){return(e=Bpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bpe(t){var e=Hpe(t,"string");return typeof e=="symbol"?e:e+""}function Hpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var $pe=t=>t.brush.height;function Vpe(t){var e=iM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Mb;return n+i}return n},0)}function Gpe(t){var e=iM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Mb;return n+i}return n},0)}function Wpe(t){var e=rM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function qpe(t){var e=rM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var bi=Ge([Fc,Uc,KW,$pe,Vpe,Gpe,Wpe,qpe,fW,yfe],(t,e,n,r,i,a,s,o,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+o},g=Sv(Sv({},f),d),m=g.bottom;g.bottom+=r,g=Ape(g,c,u);var b=t-g.left-g.right,y=e-g.top-g.bottom;return Sv(Sv({brushBottom:m},g),{},{width:Math.max(b,0),height:Math.max(y,0)})}),Kpe=Ge(bi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),gD=Ge(Fc,Uc,(t,e)=>({x:0,y:0,width:t,height:e})),Xpe=E.createContext(null),yi=()=>E.useContext(Xpe)!=null,aM=t=>t.brush,sM=Ge([aM,bi,KW],(t,e,n)=>({height:t.height,x:Pt(t.x)?t.x:e.left,y:Pt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Pt(t.width)?t.width:e.width})),PT={},RT={},DT={},Az;function Ype(){return Az||(Az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let s,o=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{o!==null&&(n.apply(s,o),s=void 0,o=null)},f=()=>{u&&d(),y()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},b=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{b(),s=void 0,o=null},v=()=>{d()},x=function(...M){if(i?.aborted)return;s=this,o=M;const S=g==null;m(),c&&S&&d()};return x.schedule=m,x.cancel=y,x.flush=v,i?.addEventListener("abort",y,{once:!0}),x}t.debounce=e})(DT)),DT}var Tz;function Zpe(){return Tz||(Tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ype();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:o=!0,maxWait:c}=a,u=Array(2);s&&(u[0]="leading"),o&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),m=function(...y){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,y),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,y),d)},b=()=>(g.flush(),d);return m.cancel=g.cancel,m.flush=b,m}t.debounce=n})(RT)),RT}var Cz;function Qpe(){return Cz||(Cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zpe();function n(r,i=0,a={}){const{leading:s=!0,trailing:o=!0}=a;return e.debounce(r,i,{leading:s,maxWait:i,trailing:o})}t.throttle=n})(PT)),PT}var jT,Nz;function Jpe(){return Nz||(Nz=1,jT=Qpe().throttle),jT}var eme=Jpe();const tme=fo(eme);var G1=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 s=0;console.warn(n.replace(/%s/g,()=>i[s++]))}},ZW=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,o=Nc(r)?t:Number(r),c=Nc(i)?e:Number(i);return a&&a>0&&(o?c=o/a:c&&(o=c*a),s&&c!=null&&c>s&&(c=s)),{calculatedWidth:o,calculatedHeight:c}},nme={width:0,height:0,overflow:"visible"},rme={width:0,overflowX:"visible"},ime={height:0,overflowY:"visible"},ame={},sme=t=>{var{width:e,height:n}=t,r=Nc(e),i=Nc(n);return r&&i?nme:r?rme:i?ime:ame};function ome(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 Hn(t){return Number.isFinite(t)}function hl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function t3(){return t3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},t3.apply(null,arguments)}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 Pz(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){lme(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 lme(t,e,n){return(e=cme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cme(t){var e=ume(t,"string");return typeof e=="symbol"?e:e+""}function ume(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 QW=E.createContext({width:-1,height:-1});function dme(t){return hl(t.width)&&hl(t.height)}function JW(t){var{children:e,width:n,height:r}=t,i=E.useMemo(()=>({width:n,height:r}),[n,r]);return dme(i)?E.createElement(QW.Provider,{value:i},e):null}var xD=()=>E.useContext(QW),hme=E.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:s=0,minHeight:o,maxHeight:c,children:u,debounce:d=0,id:f,className:g,onResize:m,style:b={}}=t,y=E.useRef(null),v=E.useRef();v.current=m,E.useImperativeHandle(e,()=>y.current);var[x,M]=E.useState({containerWidth:r.width,containerHeight:r.height}),S=E.useCallback((I,C)=>{M(D=>{var F=Math.round(I),O=Math.round(C);return D.containerWidth===F&&D.containerHeight===O?D:{containerWidth:F,containerHeight:O}})},[]);E.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return yb;var I=O=>{var q,{width:R,height:W}=O[0].contentRect;S(R,W),(q=v.current)===null||q===void 0||q.call(v,R,W)};d>0&&(I=tme(I,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(I),{width:D,height:F}=y.current.getBoundingClientRect();return S(D,F),C.observe(y.current),()=>{C.disconnect()}},[S,d]);var{containerWidth:A,containerHeight:T}=x;G1(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:N}=ZW(A,T,{width:i,height:a,aspect:n,maxHeight:c});return G1(k!=null&&k>0||N!=null&&N>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,N,i,a,s,o,n),E.createElement("div",{id:f?"".concat(f):void 0,className:Mn("recharts-responsive-container",g),style:Pz(Pz({},b),{},{width:i,height:a,minWidth:s,minHeight:o,maxHeight:c}),ref:y},E.createElement("div",{style:sme({width:i,height:a})},E.createElement(JW,{width:k,height:N},u)))}),n1=E.forwardRef((t,e)=>{var n=xD();if(hl(n.width)&&hl(n.height))return t.children;var{width:r,height:i}=ome({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=ZW(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Pt(a)&&Pt(s)?E.createElement(JW,{width:a,height:s},t.children):E.createElement(hme,t3({},t,{width:r,height:i,ref:e}))});function eq(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 Eb=()=>{var t,e=yi(),n=Ct(Kpe),r=Ct(sM),i=(t=Ct(aM))===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}},fme={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},tq=()=>{var t;return(t=Ct(bi))!==null&&t!==void 0?t:fme},bD=()=>Ct(Fc),yD=()=>Ct(Uc),pme=()=>Ct(t=>t.layout.margin),xn=t=>t.layout.layoutType,df=()=>Ct(xn),mme=()=>{var t=df();if(t==="horizontal"||t==="vertical")return t},gme=()=>{var t=df();return t!==void 0},oM=t=>{var e=rr(),n=yi(),{width:r,height:i}=t,a=xD(),s=r,o=i;return a&&(s=a.width>0?a.width:r,o=a.height>0?a.height:i),E.useEffect(()=>{!n&&hl(s)&&hl(o)&&e(vpe({width:s,height:o}))},[e,n,s,o]),null},nq=Symbol.for("immer-nothing"),Rz=Symbol.for("immer-draftable"),Cs=Symbol.for("immer-state");function Co(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var P0=Object.getPrototypeOf;function _m(t){return!!t&&!!t[Cs]}function qh(t){return t?rq(t)||Array.isArray(t)||!!t[Rz]||!!t.constructor?.[Rz]||Ab(t)||cM(t):!1}var xme=Object.prototype.constructor.toString(),Dz=new WeakMap;function rq(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=Dz.get(n);return r===void 0&&(r=Function.toString.call(n),Dz.set(n,r)),r===xme}function W1(t,e,n=!0){lM(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 lM(t){const e=t[Cs];return e?e.type_:Array.isArray(t)?1:Ab(t)?2:cM(t)?3:0}function n3(t,e){return lM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function iq(t,e,n){const r=lM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function bme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ab(t){return t instanceof Map}function cM(t){return t instanceof Set}function ih(t){return t.copy_||t.base_}function r3(t,e){if(Ab(t))return new Map(t);if(cM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=rq(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Cs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[s]})}return Object.create(P0(t),r)}else{const r=P0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function vD(t,e=!1){return uM(t)||_m(t)||!qh(t)||(lM(t)>1&&Object.defineProperties(t,{set:Mv,add:Mv,clear:Mv,delete:Mv}),Object.freeze(t),e&&Object.values(t).forEach(n=>vD(n,!0))),t}function yme(){Co(2)}var Mv={value:yme};function uM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var vme={};function Kh(t){const e=vme[t];return e||Co(0,t),e}var R0;function aq(){return R0}function _me(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function jz(t,e){e&&(Kh("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function i3(t){a3(t),t.drafts_.forEach(wme),t.drafts_=null}function a3(t){t===R0&&(R0=t.parent_)}function Oz(t){return R0=_me(R0,t)}function wme(t){const e=t[Cs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Lz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Cs].modified_&&(i3(e),Co(4)),qh(t)&&(t=q1(e,t),e.parent_||K1(e,t)),e.patches_&&Kh("Patches").generateReplacementPatches_(n[Cs].base_,t,e.patches_,e.inversePatches_)):t=q1(e,n,[]),i3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==nq?t:void 0}function q1(t,e,n){if(uM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Cs];if(!i)return W1(e,(a,s)=>Iz(t,i,e,a,s,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return K1(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let s=a,o=!1;i.type_===3&&(s=new Set(a),a.clear(),o=!0),W1(s,(c,u)=>Iz(t,i,a,c,u,n,o),r),K1(t,a,!1),n&&t.patches_&&Kh("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function Iz(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const o=uM(i);if(!(o&&!s)){if(_m(i)){const c=a&&e&&e.type_!==3&&!n3(e.assigned_,r)?a.concat(r):void 0,u=q1(t,i,c);if(iq(n,r,u),_m(u))t.canAutoFreeze_=!1;else return}else s&&n.add(i);if(qh(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;q1(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ab(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&K1(t,i)}}}function K1(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&vD(e,n)}function Sme(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:aq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=_D;n&&(i=[r],a=D0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var _D={get(t,e){if(e===Cs)return t;const n=ih(t);if(!n3(n,e))return Mme(t,n,e);const r=n[e];return t.finalized_||!qh(r)?r:r===OT(t.base_,e)?(LT(t),t.copy_[e]=o3(r,t)):r},has(t,e){return e in ih(t)},ownKeys(t){return Reflect.ownKeys(ih(t))},set(t,e,n){const r=sq(ih(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=OT(ih(t),e),a=i?.[Cs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(bme(n,i)&&(n!==void 0||n3(t.base_,e)))return!0;LT(t),s3(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 OT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,LT(t),s3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=ih(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Co(11)},getPrototypeOf(t){return P0(t.base_)},setPrototypeOf(){Co(12)}},D0={};W1(_D,(t,e)=>{D0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});D0.deleteProperty=function(t,e){return D0.set.call(this,t,e,void 0)};D0.set=function(t,e,n){return _D.set.call(this,t[0],e,n,t[0])};function OT(t,e){const n=t[Cs];return(n?ih(n):t)[e]}function Mme(t,e,n){const r=sq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function sq(t,e){if(!(e in t))return;let n=P0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=P0(n)}}function s3(t){t.modified_||(t.modified_=!0,t.parent_&&s3(t.parent_))}function LT(t){t.copy_||(t.copy_=r3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Eme=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 s=this;return function(c=a,...u){return s.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Co(6),r!==void 0&&typeof r!="function"&&Co(7);let i;if(qh(e)){const a=Oz(this),s=o3(e,void 0);let o=!0;try{i=n(s),o=!1}finally{o?i3(a):a3(a)}return jz(a,r),Lz(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===nq&&(i=void 0),this.autoFreeze_&&vD(i,!0),r){const a=[],s=[];Kh("Patches").generateReplacementPatches_(e,i,a,s),r(a,s)}return i}else Co(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...o)=>this.produceWithPatches(s,c=>e(c,...o));let r,i;return[this.produce(e,n,(s,o)=>{r=s,i=o}),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){qh(t)||Co(8),_m(t)&&(t=Ame(t));const e=Oz(this),n=o3(t,void 0);return n[Cs].isManual_=!0,a3(e),n}finishDraft(t,e){const n=t&&t[Cs];(!n||!n.isManual_)&&Co(9);const{scope_:r}=n;return jz(r,e),Lz(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=Kh("Patches").applyPatches_;return _m(t)?r(t,e):this.produce(t,i=>r(i,e))}};function o3(t,e){const n=Ab(t)?Kh("MapSet").proxyMap_(t,e):cM(t)?Kh("MapSet").proxySet_(t,e):Sme(t,e);return(e?e.scope_:aq()).drafts_.push(n),n}function Ame(t){return _m(t)||Co(10,t),oq(t)}function oq(t){if(!qh(t)||uM(t))return t;const e=t[Cs];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 W1(n,(i,a)=>{iq(n,i,oq(a))},r),e&&(e.finalized_=!1),n}var Tme=new Eme;Tme.produce;var Cme={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},lq=Qa({name:"legend",initialState:Cme,reducers:{setLegendSize(t,e){t.size.width=e.payload.width,t.size.height=e.payload.height},setLegendSettings(t,e){t.settings.align=e.payload.align,t.settings.layout=e.payload.layout,t.settings.verticalAlign=e.payload.verticalAlign,t.settings.itemSorter=e.payload.itemSorter},addLegendPayload:{reducer(t,e){t.payload.push(e.payload)},prepare:fr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:fr()},removeLegendPayload:{reducer(t,e){var n=Lo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:fr()}}}),{setLegendSize:Fz,setLegendSettings:Nme,addLegendPayload:cq,replaceLegendPayload:uq,removeLegendPayload:dq}=lq.actions,kme=lq.reducer,Pme=["contextPayload"];function l3(){return l3=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},l3.apply(null,arguments)}function Uz(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 wm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Uz(Object(n),!0).forEach(function(r){Rme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Uz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rme(t,e,n){return(e=Dme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Dme(t){var e=jme(t,"string");return typeof e=="symbol"?e:e+""}function jme(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ome(t,e){if(t==null)return{};var n,r,i=Lme(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 Lme(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 Ime(t){return t.value}function Fme(t){var{contextPayload:e}=t,n=Ome(t,Pme),r=lW(e,t.payloadUniqBy,Ime),i=wm(wm({},n),{},{payload:r});return E.isValidElement(t.content)?E.cloneElement(t.content,i):typeof t.content=="function"?E.createElement(t.content,i):E.createElement(Phe,i)}function Ume(t,e,n,r,i,a){var{layout:s,align:o,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&s==="vertical"?u={left:((r||0)-a.width)/2}:u=o==="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}),wm(wm({},u),d)}function zme(t){var e=rr();return E.useEffect(()=>{e(Nme(t))},[e,t]),null}function Bme(t){var e=rr();return E.useEffect(()=>(e(Fz(t)),()=>{e(Fz({width:0,height:0}))}),[e,t]),null}function Hme(t,e,n,r){return t==="vertical"&&Pt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var $me={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function wD(t){var e=Sr(t,$me),n=wfe(),r=Sde(),i=pme(),{width:a,height:s,wrapperStyle:o,portal:c}=e,[u,d]=pW([n]),f=bD(),g=yD();if(f==null||g==null)return null;var m=f-(i?.left||0)-(i?.right||0),b=Hme(e.layout,s,a,m),y=c?o:wm(wm({position:"absolute",width:b?.width||a||"auto",height:b?.height||s||"auto"},Ume(o,e,i,f,g,u)),o),v=c??r;if(v==null||n==null)return null;var x=E.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},E.createElement(zme,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&E.createElement(Bme,{width:u.width,height:u.height}),E.createElement(Fme,l3({},e,b,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return hc.createPortal(x,v)}wD.displayName="Legend";function c3(){return c3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c3.apply(null,arguments)}function zz(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 IT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zz(Object(n),!0).forEach(function(r){Vme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vme(t,e,n){return(e=Gme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gme(t){var e=Wme(t,"string");return typeof e=="symbol"?e:e+""}function Wme(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qme(t){return Array.isArray(t)&&co(t[0])&&co(t[1])?t.join(" ~ "):t}var Kme=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:s,itemSorter:o,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,m=()=>{if(a&&a.length){var T={padding:0,margin:0},k=(o?KS(a,o):a).map((N,I)=>{if(N.type==="none")return null;var C=N.formatter||s||qme,{value:D,name:F}=N,O=D,q=F;if(C){var R=C(D,F,N,I,a);if(Array.isArray(R))[O,q]=R;else if(R!=null)O=R;else return null}var W=IT({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},r);return E.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(I),style:W},co(q)?E.createElement("span",{className:"recharts-tooltip-item-name"},q):null,co(q)?E.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,E.createElement("span",{className:"recharts-tooltip-item-value"},O),E.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return E.createElement("ul",{className:"recharts-tooltip-item-list",style:T},k)}return null},b=IT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=IT({margin:0},i),v=!dr(d),x=v?d:"",M=Mn("recharts-default-tooltip",c),S=Mn("recharts-tooltip-label",u);v&&f&&a!==void 0&&a!==null&&(x=f(d,a));var A=g?{role:"status","aria-live":"assertive"}:{};return E.createElement("div",c3({className:M,style:b},A),E.createElement("p",{className:S,style:y},E.isValidElement(x)?x:"".concat(x)),m())},ox="recharts-tooltip-wrapper",Xme={visibility:"hidden"};function Yme(t){var{coordinate:e,translateX:n,translateY:r}=t;return Mn(ox,{["".concat(ox,"-right")]:Pt(n)&&e&&Pt(e.x)&&n>=e.x,["".concat(ox,"-left")]:Pt(n)&&e&&Pt(e.x)&&n<e.x,["".concat(ox,"-bottom")]:Pt(r)&&e&&Pt(e.y)&&r>=e.y,["".concat(ox,"-top")]:Pt(r)&&e&&Pt(e.y)&&r<e.y})}function Bz(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:o,viewBox:c,viewBoxDimension:u}=t;if(a&&Pt(a[r]))return a[r];var d=n[r]-o-(i>0?i:0),f=n[r]+i;if(e[r])return s[r]?d:f;var g=c[r];if(g==null)return 0;if(s[r]){var m=d,b=g;return m<b?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var y=f+o,v=g+u;return y>v?Math.max(d,g):Math.max(f,g)}function Zme(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 Qme(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:s,useTranslate3d:o,viewBox:c}=t,u,d,f;return s.height>0&&s.width>0&&n?(d=Bz({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:c,viewBoxDimension:c.width}),f=Bz({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:c,viewBoxDimension:c.height}),u=Zme({translateX:d,translateY:f,useTranslate3d:o})):u=Xme,{cssProperties:u,cssClasses:Yme({translateX:d,translateY:f,coordinate:n})}}function Hz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ev(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Hz(Object(n),!0).forEach(function(r){u3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Hz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u3(t,e,n){return(e=Jme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jme(t){var e=ege(t,"string");return typeof e=="symbol"?e:e+""}function ege(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class tge extends E.PureComponent{constructor(){super(...arguments),u3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),u3(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:s,hasPayload:o,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:m,wrapperStyle:b,lastBoundingBox:y,innerRef:v,hasPortalFromProps:x}=this.props,{cssClasses:M,cssProperties:S}=Qme({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),A=x?{}:Ev(Ev({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=Ev(Ev({},A),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},b);return E.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:T,ref:v},a)}}var hq=()=>{var t;return(t=Ct(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};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 $z(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Vz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$z(Object(n),!0).forEach(function(r){nge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$z(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nge(t,e,n){return(e=rge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rge(t){var e=ige(t,"string");return typeof e=="symbol"?e:e+""}function ige(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 Gz={curveBasisClosed:Hde,curveBasisOpen:$de,curveBasis:Bde,curveBumpX:Tde,curveBumpY:Cde,curveLinearClosed:Vde,curveLinear:WS,curveMonotoneX:Gde,curveMonotoneY:Wde,curveNatural:qde,curveStep:Kde,curveStepAfter:Yde,curveStepBefore:Xde},X1=t=>Hn(t.x)&&Hn(t.y),Wz=t=>t.base!=null&&X1(t.base)&&X1(t),lx=t=>t.x,cx=t=>t.y,age=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(bb(t));return(n==="curveMonotone"||n==="curveBump")&&e?Gz["".concat(n).concat(e==="vertical"?"Y":"X")]:Gz[n]||WS},sge=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=age(e,i),o=a?n.filter(X1):n,c;if(Array.isArray(r)){var u=n.map((m,b)=>Vz(Vz({},m),{},{base:r[b]}));i==="vertical"?c=xv().y(cx).x1(lx).x0(m=>m.base.x):c=xv().x(lx).y1(cx).y0(m=>m.base.y);var d=c.defined(Wz).curve(s),f=a?u.filter(Wz):u;return d(f)}i==="vertical"&&Pt(r)?c=xv().y(cx).x1(lx).x0(r):Pt(r)?c=xv().x(lx).y1(cx).y0(r):c=IG().x(lx).y(cx);var g=c.defined(X1).curve(s);return g(o)},em=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?sge(t):r;return E.createElement("path",d3({},Ca(t),aD(t),{className:Mn("recharts-curve",e),d:a===null?void 0:a,ref:i}))},oge=["x","y","top","left","width","height","className"];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 qz(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 lge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qz(Object(n),!0).forEach(function(r){cge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cge(t,e,n){return(e=uge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uge(t){var e=dge(t,"string");return typeof e=="symbol"?e:e+""}function dge(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 hge(t,e){if(t==null)return{};var n,r,i=fge(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 fge(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 pge=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),mge=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:o}=t,c=hge(t,oge),u=lge({x:e,y:n,top:r,left:i,width:a,height:s},c);return!Pt(e)||!Pt(n)||!Pt(a)||!Pt(s)||!Pt(r)||!Pt(i)?null:E.createElement("path",h3({},na(u),{className:Mn("recharts-cross",o),d:pge(e,n,a,s,r,i)}))};function gge(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 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 Xz(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){xge(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 xge(t,e,n){return(e=bge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bge(t){var e=yge(t,"string");return typeof e=="symbol"?e:e+""}function yge(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 vge=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),fq=(t,e,n)=>t.map(r=>"".concat(vge(r)," ").concat(e,"ms ").concat(n)).join(","),_ge=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),j0=(t,e)=>Object.keys(e).reduce((n,r)=>Xz(Xz({},n),{},{[r]:t(r,e[r])}),{});function Yz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ui(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Yz(Object(n),!0).forEach(function(r){wge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Yz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wge(t,e,n){return(e=Sge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sge(t){var e=Mge(t,"string");return typeof e=="symbol"?e:e+""}function Mge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Y1=(t,e,n)=>t+(e-t)*n,f3=t=>{var{from:e,to:n}=t;return e!==n},pq=(t,e,n)=>{var r=j0((i,a)=>{if(f3(a)){var[s,o]=t(a.from,a.to,a.velocity);return ui(ui({},a),{},{from:s,velocity:o})}return a},e);return n<1?j0((i,a)=>f3(a)?ui(ui({},a),{},{velocity:Y1(a.velocity,r[i].velocity,n),from:Y1(a.from,r[i].from,n)}):a,e):pq(t,r,n-1)};function Ege(t,e,n,r,i,a){var s,o=r.reduce((g,m)=>ui(ui({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>j0((g,m)=>m.from,o),u=()=>!Object.values(o).filter(f3).length,d=null,f=g=>{s||(s=g);var m=g-s,b=m/n.dt;o=pq(n,o,b),i(ui(ui(ui({},t),e),c())),s=g,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function Age(t,e,n,r,i,a,s){var o=null,c=i.reduce((f,g)=>ui(ui({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,m=j0((y,v)=>Y1(...v,n(g)),c);if(a(ui(ui(ui({},t),e),m)),g<1)o=s.setTimeout(d);else{var b=j0((y,v)=>Y1(...v,n(1)),c);a(ui(ui(ui({},t),e),b))}};return()=>(o=s.setTimeout(d),()=>{var f;(f=o)===null||f===void 0||f()})}const Tge=(t,e,n,r,i,a)=>{var s=_ge(t,e);return n==null?()=>(i(ui(ui({},t),e)),()=>{}):n.isStepper===!0?Ege(t,e,n,s,i,a):Age(t,e,n,r,s,i,a)};var Z1=1e-4,mq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],gq=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),Zz=(t,e)=>n=>{var r=mq(t,e);return gq(r,n)},Cge=(t,e)=>n=>{var r=mq(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return gq(i,n)},Nge=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 s=a[1].split(")")[0].split(",").map(o=>parseFloat(o));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},kge=(t,e,n,r)=>{var i=Zz(t,n),a=Zz(e,r),s=Cge(t,n),o=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var m=i(f)-d,b=s(f);if(Math.abs(m-d)<Z1||b<Z1)return a(f);f=o(f-m/b)}return a(f)};return c.isStepper=!1,c},Qz=function(){return kge(...Nge(...arguments))},Pge=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(s,o,c)=>{var u=-(s-o)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+s;return Math.abs(g-o)<Z1&&Math.abs(f)<Z1?[o,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},Rge=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return Qz(t);case"spring":return Pge();default:if(t.split("(")[0]==="cubic-bezier")return Qz(t)}return typeof t=="function"?t:null};function Dge(t){var e,n=()=>null,r=!1,i=null,a=s=>{if(!r){if(Array.isArray(s)){if(!s.length)return;var o=s,[c,...u]=o;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof s=="string"&&(e=s,n(e)),typeof s=="object"&&(e=s,n(e)),typeof s=="function"&&s()}};return{stop:()=>{r=!0},start:s=>{r=!1,i&&(i(),i=null),a(s)},subscribe:s=>(n=s,()=>{n=()=>null}),getTimeoutController:()=>t}}class jge{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=s=>{s-r>=n?e(s):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function Oge(){return Dge(new jge)}var Lge=E.createContext(Oge);function Ige(t,e){var n=E.useContext(Lge);return E.useMemo(()=>e??n(t),[t,e,n])}var Fge=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Xm={devToolsEnabled:!1,isSsr:Fge()},Uge={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},Jz={t:0},FT={t:1};function Ym(t){var e=Sr(t,Uge),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:o,onAnimationStart:c,children:u}=e,d=n==="auto"?!Xm.isSsr:n,f=Ige(e.animationId,e.animationManager),[g,m]=E.useState(d?Jz:FT),b=E.useRef(null);return E.useEffect(()=>{d||m(FT)},[d]),E.useEffect(()=>{if(!d||!r)return yb;var y=Tge(Jz,FT,Rge(a),i,m,f.getTimeoutController()),v=()=>{b.current=y()};return f.start([c,s,v,i,o]),()=>{f.stop(),b.current&&b.current(),o()}},[d,r,i,a,s,c,o,f]),u(g.t)}function Zm(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=E.useRef(T0(e)),r=E.useRef(t);return r.current!==t&&(n.current=T0(e),r.current=t),n.current}var zge=["radius"],Bge=["radius"];function eB(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 tB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?eB(Object(n),!0).forEach(function(r){Hge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hge(t,e,n){return(e=$ge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $ge(t){var e=Vge(t,"string");return typeof e=="symbol"?e:e+""}function Vge(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 Q1(){return Q1=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},Q1.apply(null,arguments)}function nB(t,e){if(t==null)return{};var n,r,i=Gge(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 Gge(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 rB=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),s=r>=0?1:-1,o=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+s*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+o*d[0],",").concat(e)),u+="L ".concat(t+n-o*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+s*d[1])),u+="L ".concat(t+n,",").concat(e+r-s*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
  18. `).concat(t+n-o*d[2],",").concat(e+r)),u+="L ".concat(t+o*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-s*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);u="M ".concat(t,",").concat(e+s*m,`
  20. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+o*m,",").concat(e,`
  21. L `).concat(t+n-o*m,",").concat(e,`
  22. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+s*m,`
  23. L `).concat(t+n,",").concat(e+r-s*m,`
  24. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-o*m,",").concat(e+r,`
  25. L `).concat(t+o*m,",").concat(e+r,`
  26. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t,",").concat(e+r-s*m," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},iB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},xq=t=>{var e=Sr(t,iB),n=E.useRef(null),[r,i]=E.useState(-1);E.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:s,width:o,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:m,isAnimationActive:b,isUpdateAnimationActive:y}=e,v=E.useRef(o),x=E.useRef(c),M=E.useRef(a),S=E.useRef(s),A=E.useMemo(()=>({x:a,y:s,width:o,height:c,radius:u}),[a,s,o,c,u]),T=Zm(A,"rectangle-");if(a!==+a||s!==+s||o!==+o||c!==+c||o===0||c===0)return null;var k=Mn("recharts-rectangle",d);if(!y){var N=na(e),{radius:I}=N,C=nB(N,zge);return E.createElement("path",Q1({},C,{radius:typeof u=="number"?u:void 0,className:k,d:rB(a,s,o,c,u)}))}var D=v.current,F=x.current,O=M.current,q=S.current,R="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=fq(["strokeDasharray"],g,typeof f=="string"?f:iB.animationEasing);return E.createElement(Ym,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:y,begin:m},G=>{var ee=jn(D,o,G),Z=jn(F,c,G),Q=jn(O,a,G),U=jn(q,s,G);n.current&&(v.current=ee,x.current=Z,M.current=Q,S.current=U);var $;b?G>0?$={transition:K,strokeDasharray:W}:$={strokeDasharray:R}:$={strokeDasharray:W};var X=na(e),{radius:te}=X,fe=nB(X,Bge);return E.createElement("path",Q1({},fe,{radius:typeof u=="number"?u:void 0,className:k,d:rB(Q,U,ee,Z,u),ref:n,style:tB(tB({},$),e.style)}))})};function aB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function sB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aB(Object(n),!0).forEach(function(r){Wge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Wge(t,e,n){return(e=qge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qge(t){var e=Kge(t,"string");return typeof e=="symbol"?e:e+""}function Kge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var J1=Math.PI/180,Xge=t=>t*180/Math.PI,Jr=(t,e,n,r)=>({x:t+Math.cos(-J1*r)*n,y:e+Math.sin(-J1*r)*n}),bq=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},Yge=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Zge=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=Yge({x:n,y:r},{x:i,y:a});if(s<=0)return{radius:s,angle:0};var o=(n-i)/s,c=Math.acos(o);return r>a&&(c=2*Math.PI-c),{radius:s,angle:Xge(c),angleInRadian:c}},Qge=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}},Jge=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),s=Math.min(i,a);return t+s*360},exe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Zge({x:n,y:r},e),{innerRadius:s,outerRadius:o}=e;if(i<s||i>o||i===0)return null;var{startAngle:c,endAngle:u}=Qge(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?sB(sB({},e),{},{radius:i,angle:Jge(d,e)}):null};function yq(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=Jr(e,n,r,i),o=Jr(e,n,r,a);return{points:[s,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function p3(){return p3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p3.apply(null,arguments)}var txe=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Av=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:s,cornerRadius:o,cornerIsExternal:c}=t,u=o*(s?1:-1)+r,d=Math.asin(o/u)/J1,f=c?i:i+a*d,g=Jr(e,n,u,f),m=Jr(e,n,r,f),b=c?i-a*d:i,y=Jr(e,n,u*Math.cos(d*J1),b);return{center:g,circleTangency:m,lineTangency:y,theta:d}},vq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,o=txe(a,s),c=a+o,u=Jr(e,n,i,a),d=Jr(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
  27. A `).concat(i,",").concat(i,`,0,
  28. `).concat(+(Math.abs(o)>180),",").concat(+(a>c),`,
  29. `).concat(d.x,",").concat(d.y,`
  30. `);if(r>0){var g=Jr(e,n,r,a),m=Jr(e,n,r,c);f+="L ".concat(m.x,",").concat(m.y,`
  31. A `).concat(r,",").concat(r,`,0,
  32. `).concat(+(Math.abs(o)>180),",").concat(+(a<=c),`,
  33. `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},nxe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:o,startAngle:c,endAngle:u}=t,d=Li(u-c),{circleTangency:f,lineTangency:g,theta:m}=Av({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:o}),{circleTangency:b,lineTangency:y,theta:v}=Av({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:o}),x=o?Math.abs(c-u):Math.abs(c-u)-m-v;if(x<0)return s?"M ".concat(g.x,",").concat(g.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. `):vq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var M="M ".concat(g.x,",").concat(g.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(+(x>180),",").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
  39. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
  40. `);if(r>0){var{circleTangency:S,lineTangency:A,theta:T}=Av({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),{circleTangency:k,lineTangency:N,theta:I}=Av({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),C=o?Math.abs(c-u):Math.abs(c-u)-T-I;if(C<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(N.x,",").concat(N.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(+(C>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},rxe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},_q=t=>{var e=Sr(t,rxe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var g=Mn("recharts-sector",f),m=a-i,b=pa(s,m,0,!0),y;return b>0&&Math.abs(u-d)<360?y=nxe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,m/2),forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d}):y=vq({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),E.createElement("path",p3({},na(e),{className:g,d:y}))};function ixe(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(QG(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:o}=e,c=Jr(r,i,a,o),u=Jr(r,i,s,o);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return yq(e)}}var UT={},zT={},BT={},oB;function axe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(BT)),BT}var lB;function sxe(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=axe();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})(zT)),zT}var cB;function oxe(){return cB||(cB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hW(),n=sxe();function r(i,a,s){s&&typeof s!="number"&&e.isIterateeCall(i,a,s)&&(a=s=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),s=s===void 0?i<a?1:-1:n.toFinite(s);const o=Math.max(Math.ceil((a-i)/(s||1)),0),c=new Array(o);for(let u=0;u<o;u++)c[u]=i,i+=s;return c}t.range=r})(UT)),UT}var HT,uB;function lxe(){return uB||(uB=1,HT=oxe().range),HT}var cxe=lxe();const wq=fo(cxe);function Xu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function uxe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function SD(t){let e,n,r;t.length!==2?(e=Xu,n=(o,c)=>Xu(t(o),c),r=(o,c)=>t(o)-c):(e=t===Xu||t===uxe?t:dxe,n=t,r=t);function i(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function s(o,c,u=0,d=o.length){const f=i(o,c,u,d-1);return f>u&&r(o[f-1],c)>-r(o[f],c)?f-1:f}return{left:i,center:s,right:a}}function dxe(){return 0}function Sq(t){return t===null?NaN:+t}function*hxe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const fxe=SD(Xu),Tb=fxe.right;SD(Sq).center;class dB extends Map{constructor(e,n=gxe){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(hB(this,e))}has(e){return super.has(hB(this,e))}set(e,n){return super.set(pxe(this,e),n)}delete(e){return super.delete(mxe(this,e))}}function hB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function pxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function mxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function gxe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function xxe(t=Xu){if(t===Xu)return Mq;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 Mq(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const bxe=Math.sqrt(50),yxe=Math.sqrt(10),vxe=Math.sqrt(2);function ew(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),s=a>=bxe?10:a>=yxe?5:a>=vxe?2:1;let o,c,u;return i<0?(u=Math.pow(10,-i)/s,o=Math.round(t*u),c=Math.round(e*u),o/u<t&&++o,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*s,o=Math.round(t/u),c=Math.round(e/u),o*u<t&&++o,c*u>e&&--c),c<o&&.5<=n&&n<2?ew(t,e,n*2):[o,c,u]}function m3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,s]=r?ew(e,t,n):ew(t,e,n);if(!(a>=i))return[];const o=a-i+1,c=new Array(o);if(r)if(s<0)for(let u=0;u<o;++u)c[u]=(a-u)/-s;else for(let u=0;u<o;++u)c[u]=(a-u)*s;else if(s<0)for(let u=0;u<o;++u)c[u]=(i+u)/-s;else for(let u=0;u<o;++u)c[u]=(i+u)*s;return c}function g3(t,e,n){return e=+e,t=+t,n=+n,ew(t,e,n)[2]}function x3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?g3(e,t,n):g3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function fB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function pB(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function Eq(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?Mq:xxe(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*f/c+g)),b=Math.min(r,Math.floor(e+(c-u)*f/c+g));Eq(t,e,m,b,i)}const a=t[e];let s=n,o=r;for(ux(t,n,e),i(t[r],a)>0&&ux(t,n,r);s<o;){for(ux(t,s,o),++s,--o;i(t[s],a)<0;)++s;for(;i(t[o],a)>0;)--o}i(t[n],a)===0?ux(t,n,o):(++o,ux(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function ux(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function _xe(t,e,n){if(t=Float64Array.from(hxe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return pB(t);if(e>=1)return fB(t);var r,i=(r-1)*e,a=Math.floor(i),s=fB(Eq(t,a).subarray(0,a+1)),o=pB(t.subarray(a+1));return s+(o-s)*(i-a)}}function wxe(t,e,n=Sq){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),s=+n(t[a],a,t),o=+n(t[a+1],a+1,t);return s+(o-s)*(i-a)}}function Sxe(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 zc(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 b3=Symbol("implicit");function MD(){var t=new dB,e=[],n=[],r=b3;function i(a){let s=t.get(a);if(s===void 0){if(r!==b3)return r;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new dB;for(const s of a)t.has(s)||t.set(s,e.push(s)-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 MD(e,n).unknown(r)},po.apply(i,arguments),i}function ED(){var t=MD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,s,o=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,m=i<r,b=m?i:r,y=m?r:i;a=(y-b)/Math.max(1,g-c+u*2),o&&(a=Math.floor(a)),b+=(y-b-a*(g-c))*d,s=a*(1-c),o&&(b=Math.round(b),s=Math.round(s));var v=Sxe(g).map(function(x){return b+a*x});return n(m?v.reverse():v)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(g){return arguments.length?(o=!!g,f()):o},t.padding=function(g){return arguments.length?(c=Math.min(1,u=+g),f()):c},t.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),f()):c},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return ED(e(),[r,i]).round(o).paddingInner(c).paddingOuter(u).align(d)},po.apply(f(),arguments)}function Aq(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return Aq(e())},t}function Mxe(){return Aq(ED.apply(null,arguments).paddingInner(1))}function AD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Tq(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Cb(){}var O0=.7,tw=1/O0,tm="\\s*([+-]?\\d+)\\s*",L0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",cl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Exe=/^#([0-9a-f]{3,8})$/,Axe=new RegExp(`^rgb\\(${tm},${tm},${tm}\\)$`),Txe=new RegExp(`^rgb\\(${cl},${cl},${cl}\\)$`),Cxe=new RegExp(`^rgba\\(${tm},${tm},${tm},${L0}\\)$`),Nxe=new RegExp(`^rgba\\(${cl},${cl},${cl},${L0}\\)$`),kxe=new RegExp(`^hsl\\(${L0},${cl},${cl}\\)$`),Pxe=new RegExp(`^hsla\\(${L0},${cl},${cl},${L0}\\)$`),mB={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};AD(Cb,I0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:gB,formatHex:gB,formatHex8:Rxe,formatHsl:Dxe,formatRgb:xB,toString:xB});function gB(){return this.rgb().formatHex()}function Rxe(){return this.rgb().formatHex8()}function Dxe(){return Cq(this).formatHsl()}function xB(){return this.rgb().formatRgb()}function I0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Exe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?bB(e):n===3?new Wa(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Tv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Tv(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=Axe.exec(t))?new Wa(e[1],e[2],e[3],1):(e=Txe.exec(t))?new Wa(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Cxe.exec(t))?Tv(e[1],e[2],e[3],e[4]):(e=Nxe.exec(t))?Tv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=kxe.exec(t))?_B(e[1],e[2]/100,e[3]/100,1):(e=Pxe.exec(t))?_B(e[1],e[2]/100,e[3]/100,e[4]):mB.hasOwnProperty(t)?bB(mB[t]):t==="transparent"?new Wa(NaN,NaN,NaN,0):null}function bB(t){return new Wa(t>>16&255,t>>8&255,t&255,1)}function Tv(t,e,n,r){return r<=0&&(t=e=n=NaN),new Wa(t,e,n,r)}function jxe(t){return t instanceof Cb||(t=I0(t)),t?(t=t.rgb(),new Wa(t.r,t.g,t.b,t.opacity)):new Wa}function y3(t,e,n,r){return arguments.length===1?jxe(t):new Wa(t,e,n,r??1)}function Wa(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}AD(Wa,y3,Tq(Cb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new Wa(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?O0:Math.pow(O0,t),new Wa(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Wa(Ah(this.r),Ah(this.g),Ah(this.b),nw(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:yB,formatHex:yB,formatHex8:Oxe,formatRgb:vB,toString:vB}));function yB(){return`#${ph(this.r)}${ph(this.g)}${ph(this.b)}`}function Oxe(){return`#${ph(this.r)}${ph(this.g)}${ph(this.b)}${ph((isNaN(this.opacity)?1:this.opacity)*255)}`}function vB(){const t=nw(this.opacity);return`${t===1?"rgb(":"rgba("}${Ah(this.r)}, ${Ah(this.g)}, ${Ah(this.b)}${t===1?")":`, ${t})`}`}function nw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ah(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ph(t){return t=Ah(t),(t<16?"0":"")+t.toString(16)}function _B(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new No(t,e,n,r)}function Cq(t){if(t instanceof No)return new No(t.h,t.s,t.l,t.opacity);if(t instanceof Cb||(t=I0(t)),!t)return new No;if(t instanceof No)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),s=NaN,o=a-i,c=(a+i)/2;return o?(e===a?s=(n-r)/o+(n<r)*6:n===a?s=(r-e)/o+2:s=(e-n)/o+4,o/=c<.5?a+i:2-a-i,s*=60):o=c>0&&c<1?0:s,new No(s,o,c,t.opacity)}function Lxe(t,e,n,r){return arguments.length===1?Cq(t):new No(t,e,n,r??1)}function No(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}AD(No,Lxe,Tq(Cb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new No(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?O0:Math.pow(O0,t),new No(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 Wa($T(t>=240?t-240:t+120,i,r),$T(t,i,r),$T(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new No(wB(this.h),Cv(this.s),Cv(this.l),nw(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=nw(this.opacity);return`${t===1?"hsl(":"hsla("}${wB(this.h)}, ${Cv(this.s)*100}%, ${Cv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function wB(t){return t=(t||0)%360,t<0?t+360:t}function Cv(t){return Math.max(0,Math.min(1,t||0))}function $T(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 TD=t=>()=>t;function Ixe(t,e){return function(n){return t+n*e}}function Fxe(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 Uxe(t){return(t=+t)==1?Nq:function(e,n){return n-e?Fxe(e,n,t):TD(isNaN(e)?n:e)}}function Nq(t,e){var n=e-t;return n?Ixe(t,n):TD(isNaN(t)?e:t)}const SB=(function t(e){var n=Uxe(e);function r(i,a){var s=n((i=y3(i)).r,(a=y3(a)).r),o=n(i.g,a.g),c=n(i.b,a.b),u=Nq(i.opacity,a.opacity);return function(d){return i.r=s(d),i.g=o(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function zxe(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 Bxe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Hxe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)i[s]=Qm(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(o){for(s=0;s<r;++s)a[s]=i[s](o);return a}}function $xe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function rw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Vxe(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]=Qm(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var v3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,VT=new RegExp(v3.source,"g");function Gxe(t){return function(){return t}}function Wxe(t){return function(e){return t(e)+""}}function qxe(t,e){var n=v3.lastIndex=VT.lastIndex=0,r,i,a,s=-1,o=[],c=[];for(t=t+"",e=e+"";(r=v3.exec(t))&&(i=VT.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(r=r[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,c.push({i:s,x:rw(r,i)})),n=VT.lastIndex;return n<e.length&&(a=e.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?c[0]?Wxe(c[0].x):Gxe(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)o[(f=c[d]).i]=f.x(u);return o.join("")})}function Qm(t,e){var n=typeof e,r;return e==null||n==="boolean"?TD(e):(n==="number"?rw:n==="string"?(r=I0(e))?(e=r,SB):qxe:e instanceof I0?SB:e instanceof Date?$xe:Bxe(e)?zxe:Array.isArray(e)?Hxe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Vxe:rw)(t,e)}function CD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Kxe(t,e){e===void 0&&(e=t,t=Qm);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(s){var o=Math.max(0,Math.min(r-1,Math.floor(s*=r)));return a[o](s-o)}}function Xxe(t){return function(){return t}}function iw(t){return+t}var MB=[0,1];function Ma(t){return t}function _3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Xxe(isNaN(e)?NaN:.5)}function Yxe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Zxe(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=_3(i,r),a=n(s,a)):(r=_3(r,i),a=n(a,s)),function(o){return a(r(o))}}function Qxe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=_3(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(o){var c=Tb(t,o,1,r)-1;return a[c](i[c](o))}}function Nb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function dM(){var t=MB,e=MB,n=Qm,r,i,a,s=Ma,o,c,u;function d(){var g=Math.min(t.length,e.length);return s!==Ma&&(s=Yxe(t[0],t[g-1])),o=g>2?Qxe:Zxe,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?a:(c||(c=o(t.map(r),e,n)))(r(s(g)))}return f.invert=function(g){return s(i((u||(u=o(e,t.map(r),rw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,iw),d()):t.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),n=CD,d()},f.clamp=function(g){return arguments.length?(s=g?!0:Ma,d()):s!==Ma},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(a=g,f):a},function(g,m){return r=g,i=m,d()}}function ND(){return dM()(Ma,Ma)}function Jxe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function aw(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 Sm(t){return t=aw(Math.abs(t)),t?t[1]:NaN}function e0e(t,e){return function(n,r){for(var i=n.length,a=[],s=0,o=t[0],c=0;i>0&&o>0&&(c+o+1>r&&(o=Math.max(1,r-c)),a.push(n.substring(i-=o,i+o)),!((c+=o+1)>r));)o=t[s=(s+1)%t.length];return a.reverse().join(e)}}function t0e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var n0e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function F0(t){if(!(e=n0e.exec(t)))throw new Error("invalid format: "+t);var e;return new kD({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]})}F0.prototype=kD.prototype;function kD(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+""}kD.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 r0e(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 kq;function i0e(t,e){var n=aw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(kq=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+aw(t,Math.max(0,e+a-1))[0]}function EB(t,e){var n=aw(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 AB={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Jxe,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)=>EB(t*100,e),r:EB,s:i0e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function TB(t){return t}var CB=Array.prototype.map,NB=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function a0e(t){var e=t.grouping===void 0||t.thousands===void 0?TB:e0e(CB.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?TB:t0e(CB.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=F0(f);var g=f.fill,m=f.align,b=f.sign,y=f.symbol,v=f.zero,x=f.width,M=f.comma,S=f.precision,A=f.trim,T=f.type;T==="n"?(M=!0,T="g"):AB[T]||(S===void 0&&(S=12),A=!0,T="g"),(v||g==="0"&&m==="=")&&(v=!0,g="0",m="=");var k=y==="$"?n:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",N=y==="$"?r:/[%p]/.test(T)?s:"",I=AB[T],C=/[defgprs%]/.test(T);S=S===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,S)):Math.max(0,Math.min(20,S));function D(F){var O=k,q=N,R,W,K;if(T==="c")q=I(F)+q,F="";else{F=+F;var G=F<0||1/F<0;if(F=isNaN(F)?c:I(Math.abs(F),S),A&&(F=r0e(F)),G&&+F==0&&b!=="+"&&(G=!1),O=(G?b==="("?b:o:b==="-"||b==="("?"":b)+O,q=(T==="s"?NB[8+kq/3]:"")+q+(G&&b==="("?")":""),C){for(R=-1,W=F.length;++R<W;)if(K=F.charCodeAt(R),48>K||K>57){q=(K===46?i+F.slice(R+1):F.slice(R))+q,F=F.slice(0,R);break}}}M&&!v&&(F=e(F,1/0));var ee=O.length+F.length+q.length,Z=ee<x?new Array(x-ee+1).join(g):"";switch(M&&v&&(F=e(Z+F,Z.length?x-q.length:1/0),Z=""),m){case"<":F=O+F+q+Z;break;case"=":F=O+Z+F+q;break;case"^":F=Z.slice(0,ee=Z.length>>1)+O+F+q+Z.slice(ee);break;default:F=Z+O+F+q;break}return a(F)}return D.toString=function(){return f+""},D}function d(f,g){var m=u((f=F0(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor(Sm(g)/3)))*3,y=Math.pow(10,-b),v=NB[8+b/3];return function(x){return m(y*x)+v}}return{format:u,formatPrefix:d}}var Nv,PD,Pq;s0e({thousands:",",grouping:[3],currency:["$",""]});function s0e(t){return Nv=a0e(t),PD=Nv.format,Pq=Nv.formatPrefix,Nv}function o0e(t){return Math.max(0,-Sm(Math.abs(t)))}function l0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Sm(e)/3)))*3-Sm(Math.abs(t)))}function c0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Sm(e)-Sm(t))+1}function Rq(t,e,n,r){var i=x3(t,e,n),a;switch(r=F0(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=l0e(i,s))&&(r.precision=a),Pq(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=c0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=o0e(i))&&(r.precision=a-(r.type==="%")*2);break}}return PD(r)}function _d(t){var e=t.domain;return t.ticks=function(n){var r=e();return m3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return Rq(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,s=r[i],o=r[a],c,u,d=10;for(o<s&&(u=s,s=o,o=u,u=i,i=a,a=u);d-- >0;){if(u=g3(s,o,n),u===c)return r[i]=s,r[a]=o,e(r);if(u>0)s=Math.floor(s/u)*u,o=Math.ceil(o/u)*u;else if(u<0)s=Math.ceil(s*u)/u,o=Math.floor(o*u)/u;else break;c=u}return t},t}function Dq(){var t=ND();return t.copy=function(){return Nb(t,Dq())},po.apply(t,arguments),_d(t)}function jq(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,iw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return jq(t).unknown(e)},t=arguments.length?Array.from(t,iw):[0,1],_d(n)}function Oq(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],s;return a<i&&(s=n,n=r,r=s,s=i,i=a,a=s),t[n]=e.floor(i),t[r]=e.ceil(a),t}function kB(t){return Math.log(t)}function PB(t){return Math.exp(t)}function u0e(t){return-Math.log(-t)}function d0e(t){return-Math.exp(-t)}function h0e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function f0e(t){return t===10?h0e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function p0e(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 RB(t){return(e,n)=>-t(-e,n)}function RD(t){const e=t(kB,PB),n=e.domain;let r=10,i,a;function s(){return i=p0e(r),a=f0e(r),n()[0]<0?(i=RB(i),a=RB(a),t(u0e,d0e)):t(kB,PB),e}return e.base=function(o){return arguments.length?(r=+o,s()):r},e.domain=function(o){return arguments.length?(n(o),s()):n()},e.ticks=o=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),m=i(d),b,y;const v=o==null?10:+o;let x=[];if(!(r%1)&&m-g<v){if(g=Math.floor(g),m=Math.ceil(m),u>0){for(;g<=m;++g)for(b=1;b<r;++b)if(y=g<0?b/a(-g):b*a(g),!(y<u)){if(y>d)break;x.push(y)}}else for(;g<=m;++g)for(b=r-1;b>=1;--b)if(y=g>0?b/a(-g):b*a(g),!(y<u)){if(y>d)break;x.push(y)}x.length*2<v&&(x=m3(u,d,v))}else x=m3(g,m,Math.min(m-g,v)).map(a);return f?x.reverse():x},e.tickFormat=(o,c)=>{if(o==null&&(o=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=F0(c)).precision==null&&(c.trim=!0),c=PD(c)),o===1/0)return c;const u=Math.max(1,r*o/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(Oq(n(),{floor:o=>a(Math.floor(i(o))),ceil:o=>a(Math.ceil(i(o)))})),e}function Lq(){const t=RD(dM()).domain([1,10]);return t.copy=()=>Nb(t,Lq()).base(t.base()),po.apply(t,arguments),t}function DB(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function jB(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function DD(t){var e=1,n=t(DB(e),jB(e));return n.constant=function(r){return arguments.length?t(DB(e=+r),jB(e)):e},_d(n)}function Iq(){var t=DD(dM());return t.copy=function(){return Nb(t,Iq()).constant(t.constant())},po.apply(t,arguments)}function OB(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function m0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function g0e(t){return t<0?-t*t:t*t}function jD(t){var e=t(Ma,Ma),n=1;function r(){return n===1?t(Ma,Ma):n===.5?t(m0e,g0e):t(OB(n),OB(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},_d(e)}function OD(){var t=jD(dM());return t.copy=function(){return Nb(t,OD()).exponent(t.exponent())},po.apply(t,arguments),t}function x0e(){return OD.apply(null,arguments).exponent(.5)}function LB(t){return Math.sign(t)*t*t}function b0e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Fq(){var t=ND(),e=[0,1],n=!1,r;function i(a){var s=b0e(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(LB(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,iw)).map(LB)),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 Fq(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},po.apply(i,arguments),_d(i)}function Uq(){var t=[],e=[],n=[],r;function i(){var s=0,o=Math.max(1,e.length);for(n=new Array(o-1);++s<o;)n[s-1]=wxe(t,s/o);return a}function a(s){return s==null||isNaN(s=+s)?r:e[Tb(n,s)]}return a.invertExtent=function(s){var o=e.indexOf(s);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let o of s)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(Xu),i()},a.range=function(s){return arguments.length?(e=Array.from(s),i()):e.slice()},a.unknown=function(s){return arguments.length?(r=s,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return Uq().domain(t).range(e).unknown(r)},po.apply(a,arguments)}function zq(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function s(c){return c!=null&&c<=c?i[Tb(r,c,0,n)]:a}function o(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return s}return s.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,o()):[t,e]},s.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,o()):i.slice()},s.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]]},s.unknown=function(c){return arguments.length&&(a=c),s},s.thresholds=function(){return r.slice()},s.copy=function(){return zq().domain([t,e]).range(i).unknown(a)},po.apply(_d(s),arguments)}function Bq(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Tb(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 s=e.indexOf(a);return[t[s-1],t[s]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return Bq().domain(t).range(e).unknown(n)},po.apply(i,arguments)}const GT=new Date,WT=new Date;function vi(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 s=i(a),o=i.ceil(a);return a-s<o-a?s:o},i.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,o)=>{const c=[];if(a=i.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return c;let u;do c.push(u=new Date(+a)),e(a,o),t(a);while(u<a&&a<s);return c},i.filter=a=>vi(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!a(s););else for(;--o>=0;)for(;e(s,1),!a(s););}),n&&(i.count=(a,s)=>(GT.setTime(+a),WT.setTime(+s),t(GT),t(WT),Math.floor(n(GT,WT))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?s=>r(s)%a===0:s=>i.count(0,s)%a===0):i)),i}const sw=vi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);sw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?vi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):sw);sw.range;const fc=1e3,no=fc*60,pc=no*60,Pc=pc*24,LD=Pc*7,IB=Pc*30,qT=Pc*365,mh=vi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*fc)},(t,e)=>(e-t)/fc,t=>t.getUTCSeconds());mh.range;const ID=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fc)},(t,e)=>{t.setTime(+t+e*no)},(t,e)=>(e-t)/no,t=>t.getMinutes());ID.range;const FD=vi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*no)},(t,e)=>(e-t)/no,t=>t.getUTCMinutes());FD.range;const UD=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fc-t.getMinutes()*no)},(t,e)=>{t.setTime(+t+e*pc)},(t,e)=>(e-t)/pc,t=>t.getHours());UD.range;const zD=vi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*pc)},(t,e)=>(e-t)/pc,t=>t.getUTCHours());zD.range;const kb=vi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*no)/Pc,t=>t.getDate()-1);kb.range;const hM=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Pc,t=>t.getUTCDate()-1);hM.range;const Hq=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Pc,t=>Math.floor(t/Pc));Hq.range;function hf(t){return vi(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())*no)/LD)}const fM=hf(0),ow=hf(1),y0e=hf(2),v0e=hf(3),Mm=hf(4),_0e=hf(5),w0e=hf(6);fM.range;ow.range;y0e.range;v0e.range;Mm.range;_0e.range;w0e.range;function ff(t){return vi(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)/LD)}const pM=ff(0),lw=ff(1),S0e=ff(2),M0e=ff(3),Em=ff(4),E0e=ff(5),A0e=ff(6);pM.range;lw.range;S0e.range;M0e.range;Em.range;E0e.range;A0e.range;const BD=vi(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());BD.range;const HD=vi(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());HD.range;const Rc=vi(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());Rc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vi(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)});Rc.range;const Dc=vi(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());Dc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vi(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)});Dc.range;function $q(t,e,n,r,i,a){const s=[[mh,1,fc],[mh,5,5*fc],[mh,15,15*fc],[mh,30,30*fc],[a,1,no],[a,5,5*no],[a,15,15*no],[a,30,30*no],[i,1,pc],[i,3,3*pc],[i,6,6*pc],[i,12,12*pc],[r,1,Pc],[r,2,2*Pc],[n,1,LD],[e,1,IB],[e,3,3*IB],[t,1,qT]];function o(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const m=f&&typeof f.range=="function"?f:c(u,d,f),b=m?m.range(u,+d+1):[];return g?b.reverse():b}function c(u,d,f){const g=Math.abs(d-u)/f,m=SD(([,,v])=>v).right(s,g);if(m===s.length)return t.every(x3(u/qT,d/qT,f));if(m===0)return sw.every(Math.max(x3(u,d,f),1));const[b,y]=s[g/s[m-1][2]<s[m][2]/g?m-1:m];return b.every(y)}return[o,c]}const[T0e,C0e]=$q(Dc,HD,pM,Hq,zD,FD),[N0e,k0e]=$q(Rc,BD,fM,kb,UD,ID);function KT(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 XT(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 dx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function P0e(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,s=t.shortDays,o=t.months,c=t.shortMonths,u=hx(i),d=fx(i),f=hx(a),g=fx(a),m=hx(s),b=fx(s),y=hx(o),v=fx(o),x=hx(c),M=fx(c),S={a:G,A:ee,b:Z,B:Q,c:null,d:$B,e:$B,f:ebe,g:ube,G:hbe,H:Z0e,I:Q0e,j:J0e,L:Vq,m:tbe,M:nbe,p:U,q:$,Q:WB,s:qB,S:rbe,u:ibe,U:abe,V:sbe,w:obe,W:lbe,x:null,X:null,y:cbe,Y:dbe,Z:fbe,"%":GB},A={a:X,A:te,b:fe,B:pe,c:null,d:VB,e:VB,f:xbe,g:Tbe,G:Nbe,H:pbe,I:mbe,j:gbe,L:Wq,m:bbe,M:ybe,p:be,q:Ne,Q:WB,s:qB,S:vbe,u:_be,U:wbe,V:Sbe,w:Mbe,W:Ebe,x:null,X:null,y:Abe,Y:Cbe,Z:kbe,"%":GB},T={a:D,A:F,b:O,B:q,c:R,d:BB,e:BB,f:q0e,g:zB,G:UB,H:HB,I:HB,j:$0e,L:W0e,m:H0e,M:V0e,p:C,q:B0e,Q:X0e,s:Y0e,S:G0e,u:L0e,U:I0e,V:F0e,w:O0e,W:U0e,x:W,X:K,y:zB,Y:UB,Z:z0e,"%":K0e};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(ie,xe){return function(Re){var he=[],ht=-1,H=0,B=ie.length,re,V,J;for(Re instanceof Date||(Re=new Date(+Re));++ht<B;)ie.charCodeAt(ht)===37&&(he.push(ie.slice(H,ht)),(V=FB[re=ie.charAt(++ht)])!=null?re=ie.charAt(++ht):V=re==="e"?" ":"0",(J=xe[re])&&(re=J(Re,V)),he.push(re),H=ht+1);return he.push(ie.slice(H,ht)),he.join("")}}function N(ie,xe){return function(Re){var he=dx(1900,void 0,1),ht=I(he,ie,Re+="",0),H,B;if(ht!=Re.length)return null;if("Q"in he)return new Date(he.Q);if("s"in he)return new Date(he.s*1e3+("L"in he?he.L:0));if(xe&&!("Z"in he)&&(he.Z=0),"p"in he&&(he.H=he.H%12+he.p*12),he.m===void 0&&(he.m="q"in he?he.q:0),"V"in he){if(he.V<1||he.V>53)return null;"w"in he||(he.w=1),"Z"in he?(H=XT(dx(he.y,0,1)),B=H.getUTCDay(),H=B>4||B===0?lw.ceil(H):lw(H),H=hM.offset(H,(he.V-1)*7),he.y=H.getUTCFullYear(),he.m=H.getUTCMonth(),he.d=H.getUTCDate()+(he.w+6)%7):(H=KT(dx(he.y,0,1)),B=H.getDay(),H=B>4||B===0?ow.ceil(H):ow(H),H=kb.offset(H,(he.V-1)*7),he.y=H.getFullYear(),he.m=H.getMonth(),he.d=H.getDate()+(he.w+6)%7)}else("W"in he||"U"in he)&&("w"in he||(he.w="u"in he?he.u%7:"W"in he?1:0),B="Z"in he?XT(dx(he.y,0,1)).getUTCDay():KT(dx(he.y,0,1)).getDay(),he.m=0,he.d="W"in he?(he.w+6)%7+he.W*7-(B+5)%7:he.w+he.U*7-(B+6)%7);return"Z"in he?(he.H+=he.Z/100|0,he.M+=he.Z%100,XT(he)):KT(he)}}function I(ie,xe,Re,he){for(var ht=0,H=xe.length,B=Re.length,re,V;ht<H;){if(he>=B)return-1;if(re=xe.charCodeAt(ht++),re===37){if(re=xe.charAt(ht++),V=T[re in FB?xe.charAt(ht++):re],!V||(he=V(ie,Re,he))<0)return-1}else if(re!=Re.charCodeAt(he++))return-1}return he}function C(ie,xe,Re){var he=u.exec(xe.slice(Re));return he?(ie.p=d.get(he[0].toLowerCase()),Re+he[0].length):-1}function D(ie,xe,Re){var he=m.exec(xe.slice(Re));return he?(ie.w=b.get(he[0].toLowerCase()),Re+he[0].length):-1}function F(ie,xe,Re){var he=f.exec(xe.slice(Re));return he?(ie.w=g.get(he[0].toLowerCase()),Re+he[0].length):-1}function O(ie,xe,Re){var he=x.exec(xe.slice(Re));return he?(ie.m=M.get(he[0].toLowerCase()),Re+he[0].length):-1}function q(ie,xe,Re){var he=y.exec(xe.slice(Re));return he?(ie.m=v.get(he[0].toLowerCase()),Re+he[0].length):-1}function R(ie,xe,Re){return I(ie,e,xe,Re)}function W(ie,xe,Re){return I(ie,n,xe,Re)}function K(ie,xe,Re){return I(ie,r,xe,Re)}function G(ie){return s[ie.getDay()]}function ee(ie){return a[ie.getDay()]}function Z(ie){return c[ie.getMonth()]}function Q(ie){return o[ie.getMonth()]}function U(ie){return i[+(ie.getHours()>=12)]}function $(ie){return 1+~~(ie.getMonth()/3)}function X(ie){return s[ie.getUTCDay()]}function te(ie){return a[ie.getUTCDay()]}function fe(ie){return c[ie.getUTCMonth()]}function pe(ie){return o[ie.getUTCMonth()]}function be(ie){return i[+(ie.getUTCHours()>=12)]}function Ne(ie){return 1+~~(ie.getUTCMonth()/3)}return{format:function(ie){var xe=k(ie+="",S);return xe.toString=function(){return ie},xe},parse:function(ie){var xe=N(ie+="",!1);return xe.toString=function(){return ie},xe},utcFormat:function(ie){var xe=k(ie+="",A);return xe.toString=function(){return ie},xe},utcParse:function(ie){var xe=N(ie+="",!0);return xe.toString=function(){return ie},xe}}}var FB={"-":"",_:" ",0:"0"},Ui=/^\s*\d+/,R0e=/^%/,D0e=/[\\^$*+?|[\]().{}]/g;function Nn(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 j0e(t){return t.replace(D0e,"\\$&")}function hx(t){return new RegExp("^(?:"+t.map(j0e).join("|")+")","i")}function fx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function O0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function L0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function I0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function F0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function U0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function UB(t,e,n){var r=Ui.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function zB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function z0e(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 B0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function H0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function BB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function $0e(t,e,n){var r=Ui.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function HB(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function V0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function G0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function W0e(t,e,n){var r=Ui.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function q0e(t,e,n){var r=Ui.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function K0e(t,e,n){var r=R0e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function X0e(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Y0e(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function $B(t,e){return Nn(t.getDate(),e,2)}function Z0e(t,e){return Nn(t.getHours(),e,2)}function Q0e(t,e){return Nn(t.getHours()%12||12,e,2)}function J0e(t,e){return Nn(1+kb.count(Rc(t),t),e,3)}function Vq(t,e){return Nn(t.getMilliseconds(),e,3)}function ebe(t,e){return Vq(t,e)+"000"}function tbe(t,e){return Nn(t.getMonth()+1,e,2)}function nbe(t,e){return Nn(t.getMinutes(),e,2)}function rbe(t,e){return Nn(t.getSeconds(),e,2)}function ibe(t){var e=t.getDay();return e===0?7:e}function abe(t,e){return Nn(fM.count(Rc(t)-1,t),e,2)}function Gq(t){var e=t.getDay();return e>=4||e===0?Mm(t):Mm.ceil(t)}function sbe(t,e){return t=Gq(t),Nn(Mm.count(Rc(t),t)+(Rc(t).getDay()===4),e,2)}function obe(t){return t.getDay()}function lbe(t,e){return Nn(ow.count(Rc(t)-1,t),e,2)}function cbe(t,e){return Nn(t.getFullYear()%100,e,2)}function ube(t,e){return t=Gq(t),Nn(t.getFullYear()%100,e,2)}function dbe(t,e){return Nn(t.getFullYear()%1e4,e,4)}function hbe(t,e){var n=t.getDay();return t=n>=4||n===0?Mm(t):Mm.ceil(t),Nn(t.getFullYear()%1e4,e,4)}function fbe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Nn(e/60|0,"0",2)+Nn(e%60,"0",2)}function VB(t,e){return Nn(t.getUTCDate(),e,2)}function pbe(t,e){return Nn(t.getUTCHours(),e,2)}function mbe(t,e){return Nn(t.getUTCHours()%12||12,e,2)}function gbe(t,e){return Nn(1+hM.count(Dc(t),t),e,3)}function Wq(t,e){return Nn(t.getUTCMilliseconds(),e,3)}function xbe(t,e){return Wq(t,e)+"000"}function bbe(t,e){return Nn(t.getUTCMonth()+1,e,2)}function ybe(t,e){return Nn(t.getUTCMinutes(),e,2)}function vbe(t,e){return Nn(t.getUTCSeconds(),e,2)}function _be(t){var e=t.getUTCDay();return e===0?7:e}function wbe(t,e){return Nn(pM.count(Dc(t)-1,t),e,2)}function qq(t){var e=t.getUTCDay();return e>=4||e===0?Em(t):Em.ceil(t)}function Sbe(t,e){return t=qq(t),Nn(Em.count(Dc(t),t)+(Dc(t).getUTCDay()===4),e,2)}function Mbe(t){return t.getUTCDay()}function Ebe(t,e){return Nn(lw.count(Dc(t)-1,t),e,2)}function Abe(t,e){return Nn(t.getUTCFullYear()%100,e,2)}function Tbe(t,e){return t=qq(t),Nn(t.getUTCFullYear()%100,e,2)}function Cbe(t,e){return Nn(t.getUTCFullYear()%1e4,e,4)}function Nbe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Em(t):Em.ceil(t),Nn(t.getUTCFullYear()%1e4,e,4)}function kbe(){return"+0000"}function GB(){return"%"}function WB(t){return+t}function qB(t){return Math.floor(+t/1e3)}var Zf,Kq,Xq;Pbe({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 Pbe(t){return Zf=P0e(t),Kq=Zf.format,Zf.parse,Xq=Zf.utcFormat,Zf.utcParse,Zf}function Rbe(t){return new Date(t)}function Dbe(t){return t instanceof Date?+t:+new Date(+t)}function $D(t,e,n,r,i,a,s,o,c,u){var d=ND(),f=d.invert,g=d.domain,m=u(".%L"),b=u(":%S"),y=u("%I:%M"),v=u("%I %p"),x=u("%a %d"),M=u("%b %d"),S=u("%B"),A=u("%Y");function T(k){return(c(k)<k?m:o(k)<k?b:s(k)<k?y:a(k)<k?v:r(k)<k?i(k)<k?x:M:n(k)<k?S:A)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?g(Array.from(k,Dbe)):g().map(Rbe)},d.ticks=function(k){var N=g();return t(N[0],N[N.length-1],k??10)},d.tickFormat=function(k,N){return N==null?T:u(N)},d.nice=function(k){var N=g();return(!k||typeof k.range!="function")&&(k=e(N[0],N[N.length-1],k??10)),k?g(Oq(N,k)):d},d.copy=function(){return Nb(d,$D(t,e,n,r,i,a,s,o,c,u))},d}function jbe(){return po.apply($D(N0e,k0e,Rc,BD,fM,kb,UD,ID,mh,Kq).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Obe(){return po.apply($D(T0e,C0e,Dc,HD,pM,hM,zD,FD,mh,Xq).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function mM(){var t=0,e=1,n,r,i,a,s=Ma,o=!1,c;function u(f){return f==null||isNaN(f=+f)?c:s(i===0?.5:(f=(a(f)-n)*i,o?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?(o=!!f,u):o},u.interpolator=function(f){return arguments.length?(s=f,u):s};function d(f){return function(g){var m,b;return arguments.length?([m,b]=g,s=f(m,b),u):[s(0),s(1)]}}return u.range=d(Qm),u.rangeRound=d(CD),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 wd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function Yq(){var t=_d(mM()(Ma));return t.copy=function(){return wd(t,Yq())},zc.apply(t,arguments)}function Zq(){var t=RD(mM()).domain([1,10]);return t.copy=function(){return wd(t,Zq()).base(t.base())},zc.apply(t,arguments)}function Qq(){var t=DD(mM());return t.copy=function(){return wd(t,Qq()).constant(t.constant())},zc.apply(t,arguments)}function VD(){var t=jD(mM());return t.copy=function(){return wd(t,VD()).exponent(t.exponent())},zc.apply(t,arguments)}function Lbe(){return VD.apply(null,arguments).exponent(.5)}function Jq(){var t=[],e=Ma;function n(r){if(r!=null&&!isNaN(r=+r))return e((Tb(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(Xu),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)=>_xe(t,a/r))},n.copy=function(){return Jq(e).domain(t)},zc.apply(n,arguments)}function gM(){var t=0,e=.5,n=1,r=1,i,a,s,o,c,u=Ma,d,f=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-a)*(r*y<r*a?o:c),u(f?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),a=d(e=+e),s=d(n=+n),o=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(f=!!y,m):f},m.interpolator=function(y){return arguments.length?(u=y,m):u};function b(y){return function(v){var x,M,S;return arguments.length?([x,M,S]=v,u=Kxe(y,[x,M,S]),m):[u(0),u(.5),u(1)]}}return m.range=b(Qm),m.rangeRound=b(CD),m.unknown=function(y){return arguments.length?(g=y,m):g},function(y){return d=y,i=y(t),a=y(e),s=y(n),o=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,m}}function eK(){var t=_d(gM()(Ma));return t.copy=function(){return wd(t,eK())},zc.apply(t,arguments)}function tK(){var t=RD(gM()).domain([.1,1,10]);return t.copy=function(){return wd(t,tK()).base(t.base())},zc.apply(t,arguments)}function nK(){var t=DD(gM());return t.copy=function(){return wd(t,nK()).constant(t.constant())},zc.apply(t,arguments)}function GD(){var t=jD(gM());return t.copy=function(){return wd(t,GD()).exponent(t.exponent())},zc.apply(t,arguments)}function Ibe(){return GD.apply(null,arguments).exponent(.5)}const jx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:ED,scaleDiverging:eK,scaleDivergingLog:tK,scaleDivergingPow:GD,scaleDivergingSqrt:Ibe,scaleDivergingSymlog:nK,scaleIdentity:jq,scaleImplicit:b3,scaleLinear:Dq,scaleLog:Lq,scaleOrdinal:MD,scalePoint:Mxe,scalePow:OD,scaleQuantile:Uq,scaleQuantize:zq,scaleRadial:Fq,scaleSequential:Yq,scaleSequentialLog:Zq,scaleSequentialPow:VD,scaleSequentialQuantile:Jq,scaleSequentialSqrt:Lbe,scaleSequentialSymlog:Qq,scaleSqrt:x0e,scaleSymlog:Iq,scaleThreshold:Bq,scaleTime:jbe,scaleUtc:Obe,tickFormat:Rq},Symbol.toStringTag,{value:"Module"}));var Sd=t=>t.chartData,WD=Ge([Sd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Pb=(t,e,n,r)=>r?WD(t):Sd(t);function od(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Hn(e)&&Hn(n))return!0}return!1}function KB(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function rK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(Hn(n))i=n;else if(typeof n=="function")return;if(Hn(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(od(s))return s}}function Fbe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(od(r))return KB(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,s,o;if(i==="auto")e!=null&&(s=Math.min(...e));else if(Pt(i))s=i;else if(typeof i=="function")try{e!=null&&(s=i(e?.[0]))}catch{}else if(typeof i=="string"&&wz.test(i)){var c=wz.exec(i);if(c==null||e==null)s=void 0;else{var u=+c[1];s=e[0]-u}}else s=e?.[0];if(a==="auto")e!=null&&(o=Math.max(...e));else if(Pt(a))o=a;else if(typeof a=="function")try{e!=null&&(o=a(e?.[1]))}catch{}else if(typeof a=="string"&&Sz.test(a)){var d=Sz.exec(a);if(d==null||e==null)o=void 0;else{var f=+d[1];o=e[1]+f}}else o=e?.[1];var g=[s,o];if(od(g))return e==null?g:KB(g,e,n)}}}var Jm=1e9,Ube={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},KD,gr=!0,ho="[DecimalError] ",Th=ho+"Invalid argument: ",qD=ho+"Exponent out of range: ",eg=Math.floor,ah=Math.pow,zbe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,xs,Di=1e7,ur=7,iK=9007199254740991,cw=eg(iK/ur),Dt={};Dt.absoluteValue=Dt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Dt.comparedTo=Dt.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};Dt.decimalPlaces=Dt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ur;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Dt.dividedBy=Dt.div=function(t){return vc(this,new this.constructor(t))};Dt.dividedToIntegerBy=Dt.idiv=function(t){var e=this,n=e.constructor;return nr(vc(e,new n(t),0,1),n.precision)};Dt.equals=Dt.eq=function(t){return!this.cmp(t)};Dt.exponent=function(){return ni(this)};Dt.greaterThan=Dt.gt=function(t){return this.cmp(t)>0};Dt.greaterThanOrEqualTo=Dt.gte=function(t){return this.cmp(t)>=0};Dt.isInteger=Dt.isint=function(){return this.e>this.d.length-2};Dt.isNegative=Dt.isneg=function(){return this.s<0};Dt.isPositive=Dt.ispos=function(){return this.s>0};Dt.isZero=function(){return this.s===0};Dt.lessThan=Dt.lt=function(t){return this.cmp(t)<0};Dt.lessThanOrEqualTo=Dt.lte=function(t){return this.cmp(t)<1};Dt.logarithm=Dt.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(xs))throw Error(ho+"NaN");if(n.s<1)throw Error(ho+(n.s?"NaN":"-Infinity"));return n.eq(xs)?new r(0):(gr=!1,e=vc(U0(n,a),U0(t,a),a),gr=!0,nr(e,i))};Dt.minus=Dt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?oK(e,t):aK(e,(t.s=-t.s,t))};Dt.modulo=Dt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(ho+"NaN");return n.s?(gr=!1,e=vc(n,t,0,1).times(t),gr=!0,n.minus(e)):nr(new r(n),i)};Dt.naturalExponential=Dt.exp=function(){return sK(this)};Dt.naturalLogarithm=Dt.ln=function(){return U0(this)};Dt.negated=Dt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Dt.plus=Dt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?aK(e,t):oK(e,(t.s=-t.s,t))};Dt.precision=Dt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Th+t);if(e=ni(i)+1,r=i.d.length-1,n=r*ur+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};Dt.squareRoot=Dt.sqrt=function(){var t,e,n,r,i,a,s,o=this,c=o.constructor;if(o.s<1){if(!o.s)return new c(0);throw Error(ho+"NaN")}for(t=ni(o),gr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=sl(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=eg((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=s=n+3;;)if(a=r,r=a.plus(vc(o,a,s+2)).times(.5),sl(a.d).slice(0,s)===(e=sl(r.d)).slice(0,s)){if(e=e.slice(s-3,s+1),i==s&&e=="4999"){if(nr(a,n+1,0),a.times(a).eq(o)){r=a;break}}else if(e!="9999")break;s+=4}return gr=!0,nr(r,n)};Dt.times=Dt.mul=function(t){var e,n,r,i,a,s,o,c,u,d=this,f=d.constructor,g=d.d,m=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=g.length,u=m.length,c<u&&(a=g,g=m,m=a,s=c,c=u,u=s),a=[],s=c+u,r=s;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)o=a[i]+m[r]*g[i-r-1]+e,a[i--]=o%Di|0,e=o/Di|0;a[i]=(a[i]+e)%Di|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,gr?nr(t,f.precision):t};Dt.toDecimalPlaces=Dt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(fl(t,0,Jm),e===void 0?e=r.rounding:fl(e,0,8),nr(n,t+ni(n)+1,e))};Dt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Xh(r,!0):(fl(t,0,Jm),e===void 0?e=i.rounding:fl(e,0,8),r=nr(new i(r),t+1,e),n=Xh(r,!0,t+1)),n};Dt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Xh(i):(fl(t,0,Jm),e===void 0?e=a.rounding:fl(e,0,8),r=nr(new a(i),t+ni(i)+1,e),n=Xh(r.abs(),!1,t+ni(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Dt.toInteger=Dt.toint=function(){var t=this,e=t.constructor;return nr(new e(t),ni(t)+1,e.rounding)};Dt.toNumber=function(){return+this};Dt.toPower=Dt.pow=function(t){var e,n,r,i,a,s,o=this,c=o.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(xs);if(o=new c(o),!o.s){if(t.s<1)throw Error(ho+"Infinity");return o}if(o.eq(xs))return o;if(r=c.precision,t.eq(xs))return nr(o,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=o.s,s){if((n=d<0?-d:d)<=iK){for(i=new c(xs),e=Math.ceil(r/ur+4),gr=!1;n%2&&(i=i.times(o),YB(i.d,e)),n=eg(n/2),n!==0;)o=o.times(o),YB(o.d,e);return gr=!0,t.s<0?new c(xs).div(i):nr(i,r)}}else if(a<0)throw Error(ho+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,gr=!1,i=t.times(U0(o,r+u)),gr=!0,i=sK(i),i.s=a,i};Dt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=ni(i),r=Xh(i,n<=a.toExpNeg||n>=a.toExpPos)):(fl(t,1,Jm),e===void 0?e=a.rounding:fl(e,0,8),i=nr(new a(i),t,e),n=ni(i),r=Xh(i,t<=n||n<=a.toExpNeg,t)),r};Dt.toSignificantDigits=Dt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(fl(t,1,Jm),e===void 0?e=r.rounding:fl(e,0,8)),nr(new r(n),t,e)};Dt.toString=Dt.valueOf=Dt.val=Dt.toJSON=Dt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=ni(t),n=t.constructor;return Xh(t,e<=n.toExpNeg||e>=n.toExpPos)};function aK(t,e){var n,r,i,a,s,o,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),gr?nr(e,f):e;if(c=t.d,u=e.d,s=t.e,i=e.e,c=c.slice(),a=s-i,a){for(a<0?(r=c,a=-a,o=u.length):(r=u,i=s,o=c.length),s=Math.ceil(f/ur),o=s>o?s+1:o+1,a>o&&(a=o,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(o=c.length,a=u.length,o-a<0&&(a=o,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/Di|0,c[a]%=Di;for(n&&(c.unshift(n),++i),o=c.length;c[--o]==0;)c.pop();return e.d=c,e.e=i,gr?nr(e,f):e}function fl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Th+t)}function sl(t){var e,n,r,i=t.length-1,a="",s=t[0];if(i>0){for(a+=s,e=1;e<i;e++)r=t[e]+"",n=ur-r.length,n&&(a+=Cu(n)),a+=r;s=t[e],r=s+"",n=ur-r.length,n&&(a+=Cu(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var vc=(function(){function t(r,i){var a,s=0,o=r.length;for(r=r.slice();o--;)a=r[o]*i+s,r[o]=a%Di|0,s=a/Di|0;return s&&r.unshift(s),r}function e(r,i,a,s){var o,c;if(a!=s)c=a>s?1:-1;else for(o=c=0;o<a;o++)if(r[o]!=i[o]){c=r[o]>i[o]?1:-1;break}return c}function n(r,i,a){for(var s=0;a--;)r[a]-=s,s=r[a]<i[a]?1:0,r[a]=s*Di+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,s){var o,c,u,d,f,g,m,b,y,v,x,M,S,A,T,k,N,I,C=r.constructor,D=r.s==i.s?1:-1,F=r.d,O=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(ho+"Division by zero");for(c=r.e-i.e,N=O.length,T=F.length,m=new C(D),b=m.d=[],u=0;O[u]==(F[u]||0);)++u;if(O[u]>(F[u]||0)&&--c,a==null?M=a=C.precision:s?M=a+(ni(r)-ni(i))+1:M=a,M<0)return new C(0);if(M=M/ur+2|0,u=0,N==1)for(d=0,O=O[0],M++;(u<T||d)&&M--;u++)S=d*Di+(F[u]||0),b[u]=S/O|0,d=S%O|0;else{for(d=Di/(O[0]+1)|0,d>1&&(O=t(O,d),F=t(F,d),N=O.length,T=F.length),A=N,y=F.slice(0,N),v=y.length;v<N;)y[v++]=0;I=O.slice(),I.unshift(0),k=O[0],O[1]>=Di/2&&++k;do d=0,o=e(O,y,N,v),o<0?(x=y[0],N!=v&&(x=x*Di+(y[1]||0)),d=x/k|0,d>1?(d>=Di&&(d=Di-1),f=t(O,d),g=f.length,v=y.length,o=e(f,y,g,v),o==1&&(d--,n(f,N<g?I:O,g))):(d==0&&(o=d=1),f=O.slice()),g=f.length,g<v&&f.unshift(0),n(y,f,v),o==-1&&(v=y.length,o=e(O,y,N,v),o<1&&(d++,n(y,N<v?I:O,v))),v=y.length):o===0&&(d++,y=[0]),b[u++]=d,o&&y[0]?y[v++]=F[A]||0:(y=[F[A]],v=1);while((A++<T||y[0]!==void 0)&&M--)}return b[0]||b.shift(),m.e=c,nr(m,s?a+ni(m)+1:a)}})();function sK(t,e){var n,r,i,a,s,o,c=0,u=0,d=t.constructor,f=d.precision;if(ni(t)>16)throw Error(qD+ni(t));if(!t.s)return new d(xs);for(gr=!1,o=f,s=new d(.03125);t.abs().gte(.1);)t=t.times(s),u+=5;for(r=Math.log(ah(2,u))/Math.LN10*2+5|0,o+=r,n=i=a=new d(xs),d.precision=o;;){if(i=nr(i.times(t),o),n=n.times(++c),s=a.plus(vc(i,n,o)),sl(s.d).slice(0,o)===sl(a.d).slice(0,o)){for(;u--;)a=nr(a.times(a),o);return d.precision=f,e==null?(gr=!0,nr(a,f)):a}a=s}}function ni(t){for(var e=t.e*ur,n=t.d[0];n>=10;n/=10)e++;return e}function YT(t,e,n){if(e>t.LN10.sd())throw gr=!0,n&&(t.precision=n),Error(ho+"LN10 precision limit exceeded");return nr(new t(t.LN10),e)}function Cu(t){for(var e="";t--;)e+="0";return e}function U0(t,e){var n,r,i,a,s,o,c,u,d,f=1,g=10,m=t,b=m.d,y=m.constructor,v=y.precision;if(m.s<1)throw Error(ho+(m.s?"NaN":"-Infinity"));if(m.eq(xs))return new y(0);if(e==null?(gr=!1,u=v):u=e,m.eq(10))return e==null&&(gr=!0),YT(y,u);if(u+=g,y.precision=u,n=sl(b),r=n.charAt(0),a=ni(m),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=sl(m.d),r=n.charAt(0),f++;a=ni(m),r>1?(m=new y("0."+n),a++):m=new y(r+"."+n.slice(1))}else return c=YT(y,u+2,v).times(a+""),m=U0(new y(r+"."+n.slice(1)),u-g).plus(c),y.precision=v,e==null?(gr=!0,nr(m,v)):m;for(o=s=m=vc(m.minus(xs),m.plus(xs),u),d=nr(m.times(m),u),i=3;;){if(s=nr(s.times(d),u),c=o.plus(vc(s,new y(i),u)),sl(c.d).slice(0,u)===sl(o.d).slice(0,u))return o=o.times(2),a!==0&&(o=o.plus(YT(y,u+2,v).times(a+""))),o=vc(o,new y(f),u),y.precision=v,e==null?(gr=!0,nr(o,v)):o;o=c,i+=2}}function XB(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=eg(n/ur),t.d=[],r=(n+1)%ur,n<0&&(r+=ur),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=ur;r<i;)t.d.push(+e.slice(r,r+=ur));e=e.slice(r),r=ur-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),gr&&(t.e>cw||t.e<-cw))throw Error(qD+n)}else t.s=0,t.e=0,t.d=[0];return t}function nr(t,e,n){var r,i,a,s,o,c,u,d,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(r=e-s,r<0)r+=ur,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/ur),a=f.length,d>=a)return t;for(u=a=f[d],s=1;a>=10;a/=10)s++;r%=ur,i=r-ur+s}if(n!==void 0&&(a=ah(10,s-i-1),o=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(o||c)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||c||n==6&&(r>0?i>0?u/ah(10,s-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=ni(t),f.length=1,e=e-a-1,f[0]=ah(10,(ur-e%ur)%ur),t.e=eg(-e/ur)||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=ah(10,ur-r),f[d]=i>0?(u/ah(10,s-i)%ah(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Di&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Di)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(gr&&(t.e>cw||t.e<-cw))throw Error(qD+ni(t));return t}function oK(t,e){var n,r,i,a,s,o,c,u,d,f,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),gr?nr(e,m):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),s=u-r,s){for(d=s<0,d?(n=c,s=-s,o=f.length):(n=f,r=u,o=c.length),i=Math.max(Math.ceil(m/ur),o)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=c.length,o=f.length,d=i<o,d&&(o=i),i=0;i<o;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}s=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),o=c.length,i=f.length-o;i>0;--i)c[o++]=0;for(i=f.length;i>s;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=Di-1;--c[a],c[i]+=Di}c[i]-=f[i]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,gr?nr(e,m):e):new g(0)}function Xh(t,e,n){var r,i=ni(t),a=sl(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Cu(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Cu(-i-1)+a,n&&(r=n-s)>0&&(a+=Cu(r))):i>=s?(a+=Cu(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+Cu(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=Cu(r))),t.s<0?"-"+a:a}function YB(t,e){if(t.length>e)return t.length=e,!0}function lK(t){var e,n,r;function i(a){var s=this;if(!(s instanceof i))return new i(a);if(s.constructor=i,a instanceof i){s.s=a.s,s.e=a.e,s.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Th+a);if(a>0)s.s=1;else if(a<0)a=-a,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(a===~~a&&a<1e7){s.e=0,s.d=[a];return}return XB(s,a.toString())}else if(typeof a!="string")throw Error(Th+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,zbe.test(a))XB(s,a);else throw Error(Th+a)}if(i.prototype=Dt,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=lK,i.config=i.set=Bbe,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 Bbe(t){if(!t||typeof t!="object")throw Error(ho+"Object expected");var e,n,r,i=["precision",1,Jm,"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(eg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Th+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Th+n+": "+r);return this}var KD=lK(Ube);xs=new KD(1);const zn=KD;var Hbe=t=>t,cK={},uK=t=>t===cK,ZB=t=>function e(){return arguments.length===0||arguments.length===1&&uK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},dK=(t,e)=>t===1?e:ZB(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(s=>s!==cK).length;return a>=t?e(...r):dK(t-a,ZB(function(){for(var s=arguments.length,o=new Array(s),c=0;c<s;c++)o[c]=arguments[c];var u=r.map(d=>uK(d)?o.shift():d);return e(...u,...o)}))}),$be=t=>dK(t.length,t),w3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Vbe=$be((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Gbe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Hbe;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((o,c)=>c(o),a(...arguments))}},S3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function hK(t){var e;return t===0?e=1:e=Math.floor(new zn(t).abs().log(10).toNumber())+1,e}function fK(t,e,n){for(var r=new zn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var pK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},mK=(t,e,n)=>{if(t.lte(0))return new zn(0);var r=hK(t.toNumber()),i=new zn(10).pow(r),a=t.div(i),s=r!==1?.05:.1,o=new zn(Math.ceil(a.div(s).toNumber())).add(n).mul(s),c=o.mul(i);return e?new zn(c.toNumber()):new zn(Math.ceil(c.toNumber()))},Wbe=(t,e,n)=>{var r=new zn(1),i=new zn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new zn(10).pow(hK(t)-1),i=new zn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new zn(Math.floor(t)))}else t===0?i=new zn(Math.floor((e-1)/2)):n||(i=new zn(Math.floor(t)));var s=Math.floor((e-1)/2),o=Gbe(Vbe(c=>i.add(new zn(c-s).mul(r)).toNumber()),w3);return o(0,e)},gK=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new zn(0),tickMin:new zn(0),tickMax:new zn(0)};var s=mK(new zn(n).sub(e).div(r-1),i,a),o;e<=0&&n>=0?o=new zn(0):(o=new zn(e).add(n).div(2),o=o.sub(new zn(o).mod(s)));var c=Math.ceil(o.sub(e).div(s).toNumber()),u=Math.ceil(new zn(n).sub(o).div(s).toNumber()),d=c+u+1;return d>r?gK(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:s,tickMin:o.sub(new zn(c).mul(s)),tickMax:o.add(new zn(u).mul(s))})},qbe=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,s=Math.max(i,2),[o,c]=pK([n,r]);if(o===-1/0||c===1/0){var u=c===1/0?[o,...w3(0,i-1).map(()=>1/0)]:[...w3(0,i-1).map(()=>-1/0),c];return n>r?S3(u):u}if(o===c)return Wbe(o,i,a);var{step:d,tickMin:f,tickMax:g}=gK(o,c,s,a,0),m=fK(f,g.add(new zn(.1).mul(d)),d);return n>r?S3(m):m},Kbe=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=pK([r,i]);if(s===-1/0||o===1/0)return[r,i];if(s===o)return[s];var c=Math.max(n,2),u=mK(new zn(o).sub(s).div(c-1),a,0),d=[...fK(new zn(s),new zn(o),u),o];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?S3(d):d},xK=t=>t.rootProps.maxBarSize,Xbe=t=>t.rootProps.barGap,bK=t=>t.rootProps.barCategoryGap,Ybe=t=>t.rootProps.barSize,Rb=t=>t.rootProps.stackOffset,yK=t=>t.rootProps.reverseStackOrder,XD=t=>t.options.chartName,YD=t=>t.rootProps.syncId,vK=t=>t.rootProps.syncMethod,ZD=t=>t.options.eventEmitter,Zbe=t=>t.rootProps.baseValue,Rr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},cc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ps={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},xM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Qbe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:cc.angleAxisId,includeHidden:!1,name:void 0,reversed:cc.reversed,scale:cc.scale,tick:cc.tick,tickCount:void 0,ticks:void 0,type:cc.type,unit:void 0},Jbe={allowDataOverflow:ps.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ps.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ps.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ps.scale,tick:ps.tick,tickCount:ps.tickCount,ticks:void 0,type:ps.type,unit:void 0},eye={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:cc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:cc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:cc.scale,tick:cc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},tye={allowDataOverflow:ps.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ps.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ps.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ps.scale,tick:ps.tick,tickCount:ps.tickCount,ticks:void 0,type:"category",unit:void 0},QD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?eye:Qbe,JD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?tye:Jbe,bM=t=>t.polarOptions,ej=Ge([Fc,Uc,bi],bq),_K=Ge([bM,ej],(t,e)=>{if(t!=null)return pa(t.innerRadius,e,0)}),wK=Ge([bM,ej],(t,e)=>{if(t!=null)return pa(t.outerRadius,e,e*.8)}),nye=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},SK=Ge([bM],nye);Ge([QD,SK],xM);var MK=Ge([ej,_K,wK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ge([JD,MK],xM);var EK=Ge([xn,bM,_K,wK,Fc,Uc],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:s,cy:o,startAngle:c,endAngle:u}=e;return{cx:pa(s,i,i/2),cy:pa(o,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),xr=(t,e)=>e,Db=(t,e,n)=>n;function yM(t){return t?.id}function AK(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,s=new Map;return t.forEach(o=>{var c,u=(c=o.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=yM(o);u.forEach((f,g)=>{var m=a==null||i?g:String(Bn(f,a,null)),b=Bn(f,o.dataKey,0),y;s.has(m)?y=s.get(m):y={},Object.assign(y,{[d]:b}),s.set(m,y)})}}),Array.from(s.values())}function vM(t){return t.stackId!=null&&t.dataKey!=null}var _M=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function wM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function rye(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 _i=t=>{var e=xn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},tg=t=>t.tooltip.settings.axisId;function QB(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 uw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QB(Object(n),!0).forEach(function(r){iye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iye(t,e,n){return(e=aye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aye(t){var e=sye(t,"string");return typeof e=="symbol"?e:e+""}function sye(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var M3=[0,"auto"],Pi={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},TK=(t,e)=>t.cartesianAxis.xAxis[e],Sl=(t,e)=>{var n=TK(t,e);return n??Pi},Ri={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:M3,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:Mb},CK=(t,e)=>t.cartesianAxis.yAxis[e],Ml=(t,e)=>{var n=CK(t,e);return n??Ri},oye={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:""},tj=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??oye},Mr=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return Ml(t,n);case"zAxis":return tj(t,n);case"angleAxis":return QD(t,n);case"radiusAxis":return JD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},lye=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return Ml(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},jb=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return Ml(t,n);case"angleAxis":return QD(t,n);case"radiusAxis":return JD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},NK=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function nj(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 Ob=t=>t.graphicalItems.cartesianItems,cye=Ge([xr,Db],nj),rj=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Lb=Ge([Ob,Mr,cye],rj,{memoizeOptions:{resultEqualityCheck:wM}}),kK=Ge([Lb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(vM)),PK=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),uye=Ge([Lb],PK),ij=t=>t.map(e=>e.data).filter(Boolean).flat(1),dye=Ge([Lb],ij,{memoizeOptions:{resultEqualityCheck:wM}}),aj=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},sj=Ge([dye,Pb],aj),oj=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Bn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Bn(i,r)}))):t.map(r=>({value:r})),SM=Ge([sj,Mr,Lb],oj);function RK(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function r1(t){if(co(t)||t instanceof Date){var e=Number(t);if(Hn(e))return e}}function JB(t){if(Array.isArray(t)){var e=[r1(t[0]),r1(t[1])];return od(e)?e:void 0}var n=r1(t);if(n!=null)return[n,n]}function jc(t){return t.map(r1).filter(lhe)}function hye(t,e,n){return!n||typeof e!="number"||Za(e)?[]:n.length?jc(n.flatMap(r=>{var i=Bn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!Hn(a)||!Hn(s)))return[e-a,e+s]})):[]}var wi=t=>{var e=_i(t),n=tg(t);return jb(t,e,n)},Ib=Ge([wi],t=>t?.dataKey),fye=Ge([kK,Pb,wi],AK),DK=(t,e,n,r)=>{var i={},a=e.reduce((s,o)=>(o.stackId==null||(s[o.stackId]==null&&(s[o.stackId]=[]),s[o.stackId].push(o)),s),i);return Object.fromEntries(Object.entries(a).map(s=>{var[o,c]=s,u=r?[...c].reverse():c,d=u.map(yM);return[o,{stackedData:Rpe(t,d,n),graphicalItems:u}]}))},z0=Ge([fye,kK,Rb,yK],DK),jK=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=Lpe(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},pye=Ge([Mr],t=>t.allowDataOverflow),lj=t=>{var e;if(t==null||!("domain"in t))return M3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=jc(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:M3},cj=Ge([Mr],lj),uj=Ge([cj,pye],rK),mye=Ge([z0,Sd,xr,uj],jK,{memoizeOptions:{resultEqualityCheck:_M}}),MM=t=>t.errorBars,gye=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>RK(n,r)),dw=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(),s=Math.min(...a),o=Math.max(...a);return[s,o]}},dj=(t,e,n,r,i)=>{var a,s;if(n.length>0&&t.forEach(o=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(x=>RK(i,x)),g=Bn(o,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=hye(o,g,f);if(m.length>=2){var b=Math.min(...m),y=Math.max(...m);(a==null||b<a)&&(a=b),(s==null||y>s)&&(s=y)}var v=JB(g);v!=null&&(a=a==null?v[0]:Math.min(a,v[0]),s=s==null?v[1]:Math.max(s,v[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var c=JB(Bn(o,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),s=s==null?c[1]:Math.max(s,c[1]))}),Hn(a)&&Hn(s))return[a,s]},xye=Ge([sj,Mr,uye,MM,xr],dj,{memoizeOptions:{resultEqualityCheck:_M}});function bye(t){var{value:e}=t;if(co(e)||e instanceof Date)return e}var yye=(t,e,n)=>{var r=t.map(bye).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&XG(r))?wq(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},OK=t=>t.referenceElements.dots,ng=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),vye=Ge([OK,xr,Db],ng),LK=t=>t.referenceElements.areas,_ye=Ge([LK,xr,Db],ng),IK=t=>t.referenceElements.lines,wye=Ge([IK,xr,Db],ng),FK=(t,e)=>{var n=jc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Sye=Ge(vye,xr,FK),UK=(t,e)=>{var n=jc(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)]},Mye=Ge([_ye,xr],UK);function Eye(t){var e;if(t.x!=null)return jc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:jc(n)}function Aye(t){var e;if(t.y!=null)return jc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:jc(n)}var zK=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?Eye(r):Aye(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Tye=Ge([wye,xr],zK),Cye=Ge(Sye,Tye,Mye,(t,e,n)=>dw(t,n,e)),hj=(t,e,n,r,i,a,s,o)=>{if(n!=null)return n;var c=s==="vertical"&&o==="xAxis"||s==="horizontal"&&o==="yAxis",u=c?dw(r,a,i):dw(a,i);return Fbe(e,u,t.allowDataOverflow)},Nye=Ge([Mr,cj,uj,mye,xye,Cye,xn,xr],hj,{memoizeOptions:{resultEqualityCheck:_M}}),kye=[0,1],fj=(t,e,n,r,i,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:o,type:c}=t,u=wl(e,a);if(u&&o==null){var d;return wq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?yye(r,t,u):i==="expand"?kye:s}},pj=Ge([Mr,xn,sj,SM,Rb,xr,Nye],fj),BK=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:s}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":s==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":s==="category"?"band":"linear";if(typeof a=="string"){var o="scale".concat(bb(a));return o in jx?o:"point"}}},rg=Ge([Mr,xn,NK,XD,xr],BK);function Pye(t){if(t!=null){if(t in jx)return jx[t]();var e="scale".concat(bb(t));if(e in jx)return jx[e]()}}function mj(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=Pye(e);if(i!=null){var a=i.domain(n).range(r);return Tpe(a),a}}}var gj=(t,e,n)=>{var r=lj(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&od(t))return qbe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&od(t))return Kbe(t,e.tickCount,e.allowDecimals)}},xj=Ge([pj,jb,rg],gj),bj=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&od(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],s=e[1],o=n[n.length-1];return[Math.min(i,a),Math.max(s,o)]}return e},Rye=Ge([Mr,pj,xj,xr],bj),Dye=Ge(SM,Mr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(jc(t.map(o=>o.value))).sort((o,c)=>o-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 s=r[a+1]-r[a];n=Math.min(n,s)}return n/i}}),HK=Ge(Dye,xn,bK,bi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!Hn(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=pa(n,t*a),o=t*a/2;return o-s-(o-s)/a*s}return 0}),jye=(t,e)=>{var n=Sl(t,e);return n==null||typeof n.padding!="string"?0:HK(t,"xAxis",e,n.padding)},Oye=(t,e)=>{var n=Ml(t,e);return n==null||typeof n.padding!="string"?0:HK(t,"yAxis",e,n.padding)},Lye=Ge(Sl,jye,(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}}),Iye=Ge(Ml,Oye,(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}}),Fye=Ge([bi,Lye,sM,aM,(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]}),Uye=Ge([bi,xn,Iye,sM,aM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:s}=i;return a?[r.height-s.bottom,s.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Fb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Fye(t,n,r);case"yAxis":return Uye(t,n,r);case"zAxis":return(i=tj(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return SK(t);case"radiusAxis":return MK(t,n);default:return}},$K=Ge([Mr,Fb],xM),ld=Ge([Mr,rg,Rye,$K],mj);Ge([Lb,MM,xr],gye);function VK(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var EM=(t,e)=>e,AM=(t,e,n)=>n,zye=Ge(rM,EM,AM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(VK)),Bye=Ge(iM,EM,AM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(VK)),GK=(t,e)=>({width:t.width,height:e.height}),Hye=(t,e)=>{var n=typeof e.width=="number"?e.width:Mb;return{width:n,height:t.height}},WK=Ge(bi,Sl,GK),$ye=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Vye=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Gye=Ge(Uc,bi,zye,EM,AM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var c=GK(e,o);s==null&&(s=$ye(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[o.id]=s-Number(u)*c.height,s+=(u?-1:1)*c.height}),a}),Wye=Ge(Fc,bi,Bye,EM,AM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var c=Hye(e,o);s==null&&(s=Vye(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[o.id]=s-Number(u)*c.width,s+=(u?-1:1)*c.width}),a}),qye=(t,e)=>{var n=Sl(t,e);if(n!=null)return Gye(t,n.orientation,n.mirror)},Kye=Ge([bi,Sl,qye,(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}}}),Xye=(t,e)=>{var n=Ml(t,e);if(n!=null)return Wye(t,n.orientation,n.mirror)},Yye=Ge([bi,Ml,Xye,(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}}}),qK=Ge(bi,Ml,(t,e)=>{var n=typeof e.width=="number"?e.width:Mb;return{width:n,height:t.height}}),e8=(t,e,n)=>{switch(e){case"xAxis":return WK(t,n).width;case"yAxis":return qK(t,n).height;default:return}},KK=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:s}=n,o=wl(t,r),c=e.map(u=>u.value);if(s&&o&&a==="category"&&i&&XG(c))return c}},yj=Ge([xn,SM,Mr,xr],KK),XK=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,s=wl(t,r);if(s&&(i==="number"||a!=="auto"))return e.map(o=>o.value)}},vj=Ge([xn,SM,jb,xr],XK),t8=Ge([xn,lye,rg,ld,yj,vj,Fb,xj,xr],(t,e,n,r,i,a,s,o,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:o,range:s,realScaleType:n,scale:r}}}),Zye=(t,e,n,r,i,a,s,o,c)=>{if(!(e==null||r==null)){var u=wl(t,c),{type:d,ticks:f,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=d==="category"&&r.bandwidth?r.bandwidth()/m:0;b=c==="angleAxis"&&a!=null&&a.length>=2?Li(a[0]-a[1])*2*b:b;var y=f||i;if(y){var v=y.map((x,M)=>{var S=s?s.indexOf(x):x;return{index:M,coordinate:r(S)+b,value:x,offset:b}});return v.filter(x=>Hn(x.coordinate))}return u&&o?o.map((x,M)=>({coordinate:r(x)+b,value:x,index:M,offset:b})).filter(x=>Hn(x.coordinate)):r.ticks?r.ticks(g).map(x=>({coordinate:r(x)+b,value:x,offset:b})):r.domain().map((x,M)=>({coordinate:r(x)+b,value:s?s[x]:x,index:M,offset:b}))}},YK=Ge([xn,jb,rg,ld,xj,Fb,yj,vj,xr],Zye),Qye=(t,e,n,r,i,a,s)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=wl(t,s),{tickCount:c}=e,u=0;return u=s==="angleAxis"&&r?.length>=2?Li(r[0]-r[1])*2*u:u,o&&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}))}},pl=Ge([xn,jb,ld,Fb,yj,vj,xr],Qye),ml=Ge(Mr,ld,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})}),Jye=Ge([Mr,rg,pj,$K],mj);Ge((t,e,n)=>tj(t,n),Jye,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})});var eve=Ge([xn,rM,iM],(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}}),ZK=t=>t.options.defaultTooltipEventType,QK=t=>t.options.validateTooltipEventTypes;function JK(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function _j(t,e){var n=ZK(t),r=QK(t);return JK(e,n,r)}function tve(t){return Ct(e=>_j(e,t))}var eX=(t,e)=>{var n,r=Number(e);if(!(Za(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},nve=t=>t.tooltip.settings,Lu={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},rve={itemInteraction:{click:Lu,hover:Lu},axisInteraction:{click:Lu,hover:Lu},keyboardInteraction:Lu,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}},tX=Qa({name:"tooltip",initialState:rve,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:fr()},removeTooltipEntrySettings:{reducer(t,e){var n=Lo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:fr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:ive,replaceTooltipEntrySettings:ave,removeTooltipEntrySettings:sve,setTooltipSettingsState:ove,setActiveMouseOverItemIndex:nX,mouseLeaveItem:lve,mouseLeaveChart:rX,setActiveClickItemIndex:cve,setMouseOverAxisIndex:iX,setMouseClickAxisIndex:uve,setSyncInteraction:E3,setKeyboardInteraction:A3}=tX.actions,dve=tX.reducer;function n8(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 kv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n8(Object(n),!0).forEach(function(r){hve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hve(t,e,n){return(e=fve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fve(t){var e=pve(t,"string");return typeof e=="symbol"?e:e+""}function pve(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 mve(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function gve(t){return t.index!=null}var aX=(t,e,n,r)=>{if(e==null)return Lu;var i=mve(t,e,n);if(i==null)return Lu;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(gve(i)){if(a)return kv(kv({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return kv(kv({},Lu),{},{coordinate:i.coordinate})};function xve(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 bve(t,e){var n=xve(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),s=Math.max(r,i);return n>=a&&n<=s}function yve(t,e,n){if(n==null||e==null)return!0;var r=Bn(t,e);return r==null||!od(n)?!0:bve(r,n)}var wj=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!Hn(a))return i;var s=0,o=1/0;e.length>0&&(o=e.length-1);var c=Math.max(s,Math.min(a,o)),u=e[c];return u==null||yve(u,n,r)?String(c):null},sX=(t,e,n,r,i,a,s,o)=>{if(!(a==null||o==null)){var c=s[0],u=c==null?void 0:o(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}}}},oX=(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 s;return((s=a.settings)===null||s===void 0?void 0:s.dataKey)===i})},Ub=t=>t.options.tooltipPayloadSearcher,ig=t=>t.tooltip;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 i8(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){vve(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 vve(t,e,n){return(e=_ve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _ve(t){var e=wve(t,"string");return typeof e=="symbol"?e:e+""}function wve(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 Sve(t,e){return t??e}var lX=(t,e,n,r,i,a,s)=>{if(!(e==null||a==null)){var{chartData:o,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,m)=>{var b,{dataDefinedOnItem:y,settings:v}=m,x=Sve(y,o),M=Array.isArray(x)?VW(x,u,d):x,S=(b=v?.dataKey)!==null&&b!==void 0?b:r,A=v?.nameKey,T;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&s==="axis"?T=YG(M,r,i):T=a(M,e,c,A),Array.isArray(T))T.forEach(N=>{var I=i8(i8({},v),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(Mz({tooltipEntrySettings:I,dataKey:N.dataKey,payload:N.payload,value:Bn(N.payload,N.dataKey),name:N.name}))});else{var k;g.push(Mz({tooltipEntrySettings:v,dataKey:S,payload:T,value:Bn(T,S),name:(k=Bn(T,A))!==null&&k!==void 0?k:v?.name}))}return g},f)}},Sj=Ge([wi,xn,NK,XD,_i],BK),Mve=Ge([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),Eve=Ge([_i,tg],nj),zb=Ge([Mve,wi,Eve],rj,{memoizeOptions:{resultEqualityCheck:wM}}),Ave=Ge([zb],t=>t.filter(vM)),Tve=Ge([zb],ij,{memoizeOptions:{resultEqualityCheck:wM}}),ag=Ge([Tve,Sd],aj),Cve=Ge([Ave,Sd,wi],AK),Mj=Ge([ag,wi,zb],oj),cX=Ge([wi],lj),Nve=Ge([wi],t=>t.allowDataOverflow),uX=Ge([cX,Nve],rK),kve=Ge([zb],t=>t.filter(vM)),Pve=Ge([Cve,kve,Rb,yK],DK),Rve=Ge([Pve,Sd,_i,uX],jK),Dve=Ge([zb],PK),jve=Ge([ag,wi,Dve,MM,_i],dj,{memoizeOptions:{resultEqualityCheck:_M}}),Ove=Ge([OK,_i,tg],ng),Lve=Ge([Ove,_i],FK),Ive=Ge([LK,_i,tg],ng),Fve=Ge([Ive,_i],UK),Uve=Ge([IK,_i,tg],ng),zve=Ge([Uve,_i],zK),Bve=Ge([Lve,zve,Fve],dw),Hve=Ge([wi,cX,uX,Rve,jve,Bve,xn,_i],hj),Bb=Ge([wi,xn,ag,Mj,Rb,_i,Hve],fj),$ve=Ge([Bb,wi,Sj],gj),Vve=Ge([wi,Bb,$ve,_i],bj),dX=t=>{var e=_i(t),n=tg(t),r=!1;return Fb(t,e,n,r)},hX=Ge([wi,dX],xM),fX=Ge([wi,Sj,Vve,hX],mj),Gve=Ge([xn,Mj,wi,_i],KK),Wve=Ge([xn,Mj,wi,_i],XK),qve=(t,e,n,r,i,a,s,o)=>{if(e){var{type:c}=e,u=wl(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=o==="angleAxis"&&i!=null&&i?.length>=2?Li(i[0]-i[1])*2*f:f,u&&s?s.map((g,m)=>({coordinate:r(g)+f,value:g,index:m,offset:f})):r.domain().map((g,m)=>({coordinate:r(g)+f,value:a?a[g]:g,index:m,offset:f}))}}},Bc=Ge([xn,wi,Sj,fX,dX,Gve,Wve,_i],qve),Ej=Ge([ZK,QK,nve],(t,e,n)=>JK(n.shared,t,e)),pX=t=>t.tooltip.settings.trigger,Aj=t=>t.tooltip.settings.defaultIndex,Hb=Ge([ig,Ej,pX,Aj],aX),cd=Ge([Hb,ag,Ib,Bb],wj),mX=Ge([Bc,cd],eX),Tj=Ge([Hb],t=>{if(t)return t.dataKey}),Kve=Ge([Hb],t=>{if(t)return t.graphicalItemId}),gX=Ge([ig,Ej,pX,Aj],oX),Xve=Ge([Fc,Uc,xn,bi,Bc,Aj,gX,Ub],sX),Yve=Ge([Hb,Xve],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),Zve=Ge([Hb],t=>t.active),Qve=Ge([gX,cd,Sd,Ib,mX,Ub,Ej],lX),Jve=Ge([Qve],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function a8(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 s8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a8(Object(n),!0).forEach(function(r){e_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function e_e(t,e,n){return(e=t_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t_e(t){var e=n_e(t,"string");return typeof e=="symbol"?e:e+""}function n_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 r_e=()=>Ct(wi),i_e=()=>{var t=r_e(),e=Ct(Bc),n=Ct(fX);return sd(!t||!n?void 0:s8(s8({},t),{},{scale:n}),e)};function o8(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 Qf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o8(Object(n),!0).forEach(function(r){a_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function a_e(t,e,n){return(e=s_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s_e(t){var e=o_e(t,"string");return typeof e=="symbol"?e:e+""}function o_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 l_e=(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}},c_e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:s}=r;return Qf(Qf(Qf({},r),Jr(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}var o=i.coordinate,{angle:c}=r;return Qf(Qf(Qf({},r),Jr(r.cx,r.cy,o,c)),{},{angle:c,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function u_e(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 xX=(t,e,n,r,i)=>{var a,s=-1,o=(a=e?.length)!==null&&a!==void 0?a:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<o;c++){var u=c>0?n[c-1].coordinate:n[o-1].coordinate,d=n[c].coordinate,f=c>=o-1?n[0].coordinate:n[c+1].coordinate,g=void 0;if(Li(d-u)!==Li(f-d)){var m=[];if(Li(f-d)===Li(i[1]-i[0])){g=f;var b=d+i[1]-i[0];m[0]=Math.min(b,(b+u)/2),m[1]=Math.max(b,(b+u)/2)}else{g=u;var y=f+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var v=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>v[0]&&t<=v[1]||t>=m[0]&&t<=m[1]){({index:s}=n[c]);break}}else{var x=Math.min(u,f),M=Math.max(u,f);if(t>(x+d)/2&&t<=(M+d)/2){({index:s}=n[c]);break}}}else if(e){for(var S=0;S<o;S++)if(S===0&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S>0&&S<o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S===o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2){({index:s}=e[S]);break}}return s},bX=()=>Ct(XD),Cj=(t,e)=>e,yX=(t,e,n)=>n,Nj=(t,e,n,r)=>r,d_e=Ge(Bc,t=>KS(t,e=>e.coordinate)),kj=Ge([ig,Cj,yX,Nj],aX),Pj=Ge([kj,ag,Ib,Bb],wj),h_e=(t,e,n)=>{if(e!=null){var r=ig(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},vX=Ge([ig,Cj,yX,Nj],oX),hw=Ge([Fc,Uc,xn,bi,Bc,Nj,vX,Ub],sX),f_e=Ge([kj,hw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),_X=Ge([Bc,Pj],eX),p_e=Ge([vX,Pj,Sd,Ib,_X,Ub,Cj],lX),m_e=Ge([kj,Pj],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),g_e=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&u_e(t,s)){var o=Ipe(t,e),c=xX(o,a,i,n,r),u=l_e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},x_e=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var o=exe(t,n);if(o){var c=Fpe(o,e),u=xX(c,s,a,r,i),d=c_e(e,a,u,o);return{activeIndex:String(u),activeCoordinate:d}}}},b_e=(t,e,n,r,i,a,s,o)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?g_e(t,e,r,i,a,s,o):x_e(t,e,n,r,i,a,s)},y_e=Ge(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}}),v_e=Ge(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Rr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:rye}});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 c8(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){__e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function __e(t,e,n){return(e=w_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function w_e(t){var e=S_e(t,"string");return typeof e=="symbol"?e:e+""}function S_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 M_e={},E_e={zIndexMap:Object.values(Rr).reduce((t,e)=>c8(c8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),M_e)},A_e=new Set(Object.values(Rr));function T_e(t){return A_e.has(t)}var wX=Qa({name:"zIndex",initialState:E_e,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:fr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!T_e(n)&&delete t.zIndexMap[n])},prepare:fr()},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:fr()},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:fr()}}}),{registerZIndexPortal:C_e,unregisterZIndexPortal:N_e,registerZIndexPortalId:k_e,unregisterZIndexPortalId:P_e}=wX.actions,R_e=wX.reducer;function ma(t){var{zIndex:e,children:n}=t,r=gme(),i=r&&e!==void 0&&e!==0,a=yi(),s=rr();E.useLayoutEffect(()=>i?(s(C_e({zIndex:e})),()=>{s(N_e({zIndex:e}))}):yb,[s,e,i]);var o=Ct(u=>y_e(u,e,a));if(!i)return n;if(!o)return null;var c=document.getElementById(o);return c?hc.createPortal(n,c):null}function T3(){return T3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},T3.apply(null,arguments)}function u8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Pv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u8(Object(n),!0).forEach(function(r){D_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function D_e(t,e,n){return(e=j_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j_e(t){var e=O_e(t,"string");return typeof e=="symbol"?e:e+""}function O_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function L_e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return E.isValidElement(e)?E.cloneElement(e,r):E.createElement(n,r)}function I_e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:s,layout:o,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,m=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var b,y,v;if(d==="ScatterChart")b=f,y=mge,v=Rr.cursorLine;else if(d==="BarChart")b=gge(o,f,a,s),y=xq,v=Rr.cursorRectangle;else if(o==="radial"&&QG(f)){var{cx:x,cy:M,radius:S,startAngle:A,endAngle:T}=yq(f);b={cx:x,cy:M,startAngle:A,endAngle:T,innerRadius:S,outerRadius:S},y=_q,v=Rr.cursorLine}else b={points:ixe(o,f,a)},y=em,v=Rr.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,N=Pv(Pv(Pv(Pv({stroke:"#ccc",pointerEvents:"none"},a),b),Gh(c)),{},{payload:g,payloadIndex:m,className:Mn("recharts-tooltip-cursor",k)});return E.createElement(ma,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},E.createElement(L_e,{cursor:c,cursorComp:y,cursorProps:N}))}function F_e(t){var e=i_e(),n=tq(),r=df(),i=bX();return e==null||n==null||r==null||i==null?null:E.createElement(I_e,T3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var SX=E.createContext(null),U_e=()=>E.useContext(SX),ZT={exports:{}},d8;function z_e(){return d8||(d8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,f||c,g),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],m]:c._events[b].push(m):(c._events[b]=m,c._eventsCount++),c}function s(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function o(){this._events=new r,this._eventsCount=0}o.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},o.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,m=f.length,b=new Array(m);g<m;g++)b[g]=f[g].fn;return b},o.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,d,f,g,m,b){var y=n?n+u:u;if(!this._events[y])return!1;var v=this._events[y],x=arguments.length,M,S;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),x){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,f),!0;case 4:return v.fn.call(v.context,d,f,g),!0;case 5:return v.fn.call(v.context,d,f,g,m),!0;case 6:return v.fn.call(v.context,d,f,g,m,b),!0}for(S=1,M=new Array(x-1);S<x;S++)M[S-1]=arguments[S];v.fn.apply(v.context,M)}else{var A=v.length,T;for(S=0;S<A;S++)switch(v[S].once&&this.removeListener(u,v[S].fn,void 0,!0),x){case 1:v[S].fn.call(v[S].context);break;case 2:v[S].fn.call(v[S].context,d);break;case 3:v[S].fn.call(v[S].context,d,f);break;case 4:v[S].fn.call(v[S].context,d,f,g);break;default:if(!M)for(T=1,M=new Array(x-1);T<x;T++)M[T-1]=arguments[T];v[S].fn.apply(v[S].context,M)}}return!0},o.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,g){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return s(this,m),this;var b=this._events[m];if(b.fn)b.fn===d&&(!g||b.once)&&(!f||b.context===f)&&s(this,m);else{for(var y=0,v=[],x=b.length;y<x;y++)(b[y].fn!==d||g&&!b[y].once||f&&b[y].context!==f)&&v.push(b[y]);v.length?this._events[m]=v.length===1?v[0]:v:s(this,m)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&s(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(ZT)),ZT.exports}var B_e=z_e();const H_e=fo(B_e);var B0=new H_e,C3="recharts.syncEvent.tooltip",h8="recharts.syncEvent.brush";function TM(t,e){if(e){var n=Number.parseInt(e,10);if(!Za(n))return t?.[n]}}var $_e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},MX=Qa({name:"options",initialState:$_e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),V_e=MX.reducer,{createEventEmitter:G_e}=MX.actions;function W_e(t){return t.tooltip.syncInteraction}var q_e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},EX=Qa({name:"chartData",initialState:q_e,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:f8,setDataStartEndIndexes:K_e,setComputedData:VGe}=EX.actions,X_e=EX.reducer,Y_e=["x","y"];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 Jf(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){Z_e(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 Z_e(t,e,n){return(e=Q_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q_e(t){var e=J_e(t,"string");return typeof e=="symbol"?e:e+""}function J_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function e1e(t,e){if(t==null)return{};var n,r,i=t1e(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 t1e(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 n1e(){var t=Ct(YD),e=Ct(ZD),n=rr(),r=Ct(vK),i=Ct(Bc),a=df(),s=Eb(),o=Ct(c=>c.rootProps.className);E.useEffect(()=>{if(t==null)return yb;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(s&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x:b,y}=m,v=e1e(m,Y_e),{x,y:M,width:S,height:A}=d.payload.sourceViewBox,T=Jf(Jf({},v),{},{x:s.x+(S?(b-x)/S:0)*s.width,y:s.y+(A?(y-M)/A:0)*s.height});n(Jf(Jf({},d),{},{payload:Jf(Jf({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var N={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},I=r(i,N);k=i[I]}else r==="value"&&(k=i.find(K=>String(K.value)===d.payload.label));var{coordinate:C}=d.payload;if(k==null||d.payload.active===!1||C==null||s==null){n(E3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:F}=C,O=Math.min(D,s.x+s.width),q=Math.min(F,s.y+s.height),R={x:a==="horizontal"?k.coordinate:O,y:a==="horizontal"?q:k.coordinate},W=E3({active:d.payload.active,coordinate:R,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return B0.on(C3,c),()=>{B0.off(C3,c)}},[o,n,e,t,r,i,a,s])}function r1e(){var t=Ct(YD),e=Ct(ZD),n=rr();E.useEffect(()=>{if(t==null)return yb;var r=(i,a,s)=>{e!==s&&t===i&&n(K_e(a))};return B0.on(h8,r),()=>{B0.off(h8,r)}},[n,e,t])}function i1e(){var t=rr();E.useEffect(()=>{t(G_e())},[t]),n1e(),r1e()}function a1e(t,e,n,r,i,a){var s=Ct(m=>h_e(m,t,e)),o=Ct(ZD),c=Ct(YD),u=Ct(vK),d=Ct(W_e),f=d?.active,g=Eb();E.useEffect(()=>{if(!f&&c!=null&&o!=null){var m=E3({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});B0.emit(C3,c,m,o)}},[f,n,s,i,r,o,c,u,a,g])}function m8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m8(Object(n),!0).forEach(function(r){s1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function s1e(t,e,n){return(e=o1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o1e(t){var e=l1e(t,"string");return typeof e=="symbol"?e:e+""}function l1e(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 c1e(t){return t.dataKey}function u1e(t,e){return E.isValidElement(t)?E.cloneElement(t,e):typeof t=="function"?E.createElement(t,e):E.createElement(Kme,e)}var x8=[],d1e={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 i1(t){var e,n,r=Sr(t,d1e),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:o,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:m,reverseDirection:b,useTranslate3d:y,wrapperStyle:v,cursor:x,shared:M,trigger:S,defaultIndex:A,portal:T,axisId:k}=r,N=rr(),I=typeof A=="number"?String(A):A;E.useEffect(()=>{N(ove({shared:M,trigger:S,axisId:k,active:i,defaultIndex:I}))},[N,M,S,k,i,I]);var C=Eb(),D=hq(),F=tve(M),{activeIndex:O,isActive:q}=(e=Ct(be=>m_e(be,F,S,I)))!==null&&e!==void 0?e:{},R=Ct(be=>p_e(be,F,S,I)),W=Ct(be=>_X(be,F,S,I)),K=Ct(be=>f_e(be,F,S,I)),G=R,ee=U_e(),Z=(n=i??q)!==null&&n!==void 0?n:!1,[Q,U]=pW([G,Z]),$=F==="axis"?W:void 0;a1e(F,S,K,$,O,Z);var X=T??ee;if(X==null||C==null||F==null)return null;var te=G??x8;Z||(te=x8),u&&te.length&&(te=lW(te.filter(be=>be.value!=null&&(be.hide!==!0||r.includeHidden)),g,c1e));var fe=te.length>0,pe=E.createElement(tge,{allowEscapeViewBox:a,animationDuration:s,animationEasing:o,isAnimationActive:d,active:Z,coordinate:K,hasPayload:fe,offset:f,position:m,reverseDirection:b,useTranslate3d:y,viewBox:C,wrapperStyle:v,lastBoundingBox:Q,innerRef:U,hasPortalFromProps:!!T},u1e(c,g8(g8({},r),{},{payload:te,label:$,active:Z,activeIndex:O,coordinate:K,accessibilityLayer:D})));return E.createElement(E.Fragment,null,hc.createPortal(pe,X),Z&&E.createElement(F_e,{cursor:x,tooltipEventType:F,coordinate:K,payload:te,index:O}))}var $b=t=>null;$b.displayName="Cell";function h1e(t,e,n){return(e=f1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f1e(t){var e=p1e(t,"string");return typeof e=="symbol"?e:e+""}function p1e(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 m1e{constructor(e){h1e(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 b8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g1e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b8(Object(n),!0).forEach(function(r){x1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function x1e(t,e,n){return(e=b1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b1e(t){var e=y1e(t,"string");return typeof e=="symbol"?e:e+""}function y1e(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 v1e={cacheSize:2e3,enableCache:!0},AX=g1e({},v1e),y8=new m1e(AX.cacheSize),_1e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},v8="recharts_measurement_span";function w1e(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(s,"|").concat(o)}var _8=(t,e)=>{try{var n=document.getElementById(v8);n||(n=document.createElement("span"),n.setAttribute("id",v8),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,_1e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},qx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Xm.isSsr)return{width:0,height:0};if(!AX.enableCache)return _8(e,n);var r=w1e(e,n),i=y8.get(r);if(i)return i;var a=_8(e,n);return y8.set(r,a),a},w8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,S8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,S1e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,M1e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,TX={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},E1e=Object.keys(TX),Gp="NaN";function A1e(t,e){return t*TX[e]}class $a{static parse(e){var n,[,r,i]=(n=M1e.exec(e))!==null&&n!==void 0?n:[];return new $a(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Za(e)&&(this.unit=""),n!==""&&!S1e.test(n)&&(this.num=NaN,this.unit=""),E1e.includes(n)&&(this.num=A1e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new $a(NaN,""):new $a(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new $a(NaN,""):new $a(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new $a(NaN,""):new $a(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new $a(NaN,""):new $a(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Za(this.num)}}function CX(t){if(t.includes(Gp))return Gp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=w8.exec(e))!==null&&n!==void 0?n:[],s=$a.parse(r??""),o=$a.parse(a??""),c=i==="*"?s.multiply(o):s.divide(o);if(c.isNaN())return Gp;e=e.replace(w8,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=S8.exec(e))!==null&&u!==void 0?u:[],m=$a.parse(d??""),b=$a.parse(g??""),y=f==="+"?m.add(b):m.subtract(b);if(y.isNaN())return Gp;e=e.replace(S8,y.toString())}return e}var M8=/\(([^()]*)\)/;function T1e(t){for(var e=t,n;(n=M8.exec(e))!=null;){var[,r]=n;e=e.replace(M8,CX(r))}return e}function C1e(t){var e=t.replace(/\s+/g,"");return e=T1e(e),e=CX(e),e}function N1e(t){try{return C1e(t)}catch{return Gp}}function QT(t){var e=N1e(t.slice(5,-1));return e===Gp?"":e}var k1e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],P1e=["dx","dy","angle","className","breakAll"];function N3(){return N3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},N3.apply(null,arguments)}function E8(t,e){if(t==null)return{};var n,r,i=R1e(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 R1e(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 NX=/[ \f\n\r\t\v\u2028\u2029]+/,kX=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];dr(e)||(n?i=e.toString().split(""):i=e.toString().split(NX));var a=i.map(o=>({word:o,width:qx(o,r).width})),s=n?0:qx(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function D1e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var PX=(t,e,n,r)=>t.reduce((i,a)=>{var{word:s,width:o}=a,c=i[i.length-1];if(c&&o!=null&&(e==null||r||c.width+o+n<Number(e)))c.words.push(s),c.width+=o+n;else{var u={words:[s],width:o};i.push(u)}return i},[]),RX=t=>t.reduce((e,n)=>e.width>n.width?e:n),j1e="…",A8=(t,e,n,r,i,a,s,o)=>{var c=t.slice(0,e),u=kX({breakAll:n,style:r,children:c+j1e});if(!u)return[!1,[]];var d=PX(u.wordsWithComputedWidth,a,s,o),f=d.length>i||RX(d).width>Number(a);return[f,d]},O1e=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:o,breakAll:c}=t,u=Pt(a),d=String(s),f=PX(e,r,n,i);if(!u||i)return f;var g=f.length>a||RX(f).width>Number(r);if(!g)return f;for(var m=0,b=d.length-1,y=0,v;m<=b&&y<=d.length-1;){var x=Math.floor((m+b)/2),M=x-1,[S,A]=A8(d,M,c,o,a,r,n,i),[T]=A8(d,x,c,o,a,r,n,i);if(!S&&!T&&(m=x+1),S&&T&&(b=x-1),!S&&T){v=A;break}y++}return v||f},T8=t=>{var e=dr(t)?[]:t.toString().split(NX);return[{words:e,width:void 0}]},L1e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!Xm.isSsr){var o,c,u=kX({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;o=d,c=f}else return T8(r);return O1e({breakAll:a,children:r,maxLines:s,style:i},o,c,e,!!n)}return T8(r)},DX="#808080",I1e={angle:0,breakAll:!1,capHeight:"0.71em",fill:DX,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},CM=E.forwardRef((t,e)=>{var n=Sr(t,I1e),{x:r,y:i,lineHeight:a,capHeight:s,fill:o,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=E8(n,k1e),g=E.useMemo(()=>L1e({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:m,dy:b,angle:y,className:v,breakAll:x}=f,M=E8(f,P1e);if(!co(r)||!co(i)||g.length===0)return null;var S=Number(r)+(Pt(m)?m:0),A=Number(i)+(Pt(b)?b:0);if(!Hn(S)||!Hn(A))return null;var T;switch(d){case"start":T=QT("calc(".concat(s,")"));break;case"middle":T=QT("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=QT("calc(".concat(g.length-1," * -").concat(a,")"));break}var k=[];if(c){var N=g[0].width,{width:I}=f;k.push("scale(".concat(Pt(I)&&Pt(N)?I/N:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(S,", ").concat(A,")")),k.length&&(M.transform=k.join(" ")),E.createElement("text",N3({},na(M),{ref:e,x:S,y:A,className:Mn("recharts-text",v),textAnchor:u,fill:o.includes("url")?DX:o}),g.map((C,D)=>{var F=C.words.join(x?"":" ");return E.createElement("tspan",{x:S,dy:D===0?T:a,key:"".concat(F,"-").concat(D)},F)}))});CM.displayName="Text";var F1e=["labelRef"];function U1e(t,e){if(t==null)return{};var n,r,i=z1e(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 z1e(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 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 Ur(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){B1e(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 B1e(t,e,n){return(e=H1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H1e(t){var e=$1e(t,"string");return typeof e=="symbol"?e:e+""}function $1e(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 uc(){return uc=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},uc.apply(null,arguments)}var jX=E.createContext(null),OX=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s,children:o}=t,c=E.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s}),[e,n,r,i,a,s]);return E.createElement(jX.Provider,{value:c},o)},LX=()=>{var t=E.useContext(jX),e=Eb();return t||eq(e)},V1e=E.createContext(null),G1e=()=>{var t=E.useContext(V1e),e=Ct(EK);return t||e},W1e=t=>{var{value:e,formatter:n}=t,r=dr(t.children)?e:t.children;return typeof n=="function"?n(r):r},Rj=t=>t!=null&&typeof t=="function",q1e=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r},K1e=(t,e,n,r,i)=>{var{offset:a,className:s}=t,{cx:o,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:m}=i,b=(u+d)/2,y=q1e(f,g),v=y>=0?1:-1,x,M;switch(e){case"insideStart":x=f+v*a,M=m;break;case"insideEnd":x=g-v*a,M=!m;break;case"end":x=g+v*a,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=y<=0?M:!M;var S=Jr(o,c,b,x),A=Jr(o,c,b,x+(M?1:-1)*359),T="M".concat(S.x,",").concat(S.y,`
  44. A`).concat(b,",").concat(b,",0,1,").concat(M?0:1,`,
  45. `).concat(A.x,",").concat(A.y),k=dr(t.id)?T0("recharts-radial-line-"):t.id;return E.createElement("text",uc({},r,{dominantBaseline:"central",className:Mn("recharts-radial-bar-label",s)}),E.createElement("defs",null,E.createElement("path",{id:k,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(k)},n))},X1e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:s,startAngle:o,endAngle:c}=t,u=(o+c)/2;if(n==="outside"){var{x:d,y:f}=Jr(r,i,s+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(a+s)/2,{x:m,y:b}=Jr(r,i,g,u);return{x:m,y:b,textAnchor:"middle",verticalAnchor:"middle"}},k3=t=>"cx"in t&&Pt(t.cx),Y1e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!k3(n)&&(a=n);var{x:s,y:o,upperWidth:c,lowerWidth:u,height:d}=e,f=s,g=s+(c-u)/2,m=(f+g)/2,b=(c+u)/2,y=f+c/2,v=d>=0?1:-1,x=v*r,M=v>0?"end":"start",S=v>0?"start":"end",A=c>=0?1:-1,T=A*r,k=A>0?"end":"start",N=A>0?"start":"end";if(i==="top"){var I={x:f+c/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return Ur(Ur({},I),a?{height:Math.max(o-a.y,0),width:c}:{})}if(i==="bottom"){var C={x:g+u/2,y:o+d+x,textAnchor:"middle",verticalAnchor:S};return Ur(Ur({},C),a?{height:Math.max(a.y+a.height-(o+d),0),width:u}:{})}if(i==="left"){var D={x:m-T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"};return Ur(Ur({},D),a?{width:Math.max(D.x-a.x,0),height:d}:{})}if(i==="right"){var F={x:m+b+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"};return Ur(Ur({},F),a?{width:Math.max(a.x+a.width-F.x,0),height:d}:{})}var O=a?{width:b,height:d}:{};return i==="insideLeft"?Ur({x:m+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"},O):i==="insideRight"?Ur({x:m+b-T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"},O):i==="insideTop"?Ur({x:f+c/2,y:o+x,textAnchor:"middle",verticalAnchor:S},O):i==="insideBottom"?Ur({x:g+u/2,y:o+d-x,textAnchor:"middle",verticalAnchor:M},O):i==="insideTopLeft"?Ur({x:f+T,y:o+x,textAnchor:N,verticalAnchor:S},O):i==="insideTopRight"?Ur({x:f+c-T,y:o+x,textAnchor:k,verticalAnchor:S},O):i==="insideBottomLeft"?Ur({x:g+T,y:o+d-x,textAnchor:N,verticalAnchor:M},O):i==="insideBottomRight"?Ur({x:g+u-T,y:o+d-x,textAnchor:k,verticalAnchor:M},O):i&&typeof i=="object"&&(Pt(i.x)||Nc(i.x))&&(Pt(i.y)||Nc(i.y))?Ur({x:s+pa(i.x,b),y:o+pa(i.y,d),textAnchor:"end",verticalAnchor:"end"},O):Ur({x:y,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},O)},Z1e={angle:0,offset:5,zIndex:Rr.label,position:"middle",textBreakAll:!1};function Nu(t){var e=Sr(t,Z1e),{viewBox:n,position:r,value:i,children:a,content:s,className:o="",textBreakAll:c,labelRef:u}=e,d=G1e(),f=LX(),g=r==="center"?f:d??f,m,b,y;if(n==null?m=g:k3(n)?m=n:m=eq(n),!m||dr(i)&&dr(a)&&!E.isValidElement(s)&&typeof s!="function")return null;var v=Ur(Ur({},e),{},{viewBox:m});if(E.isValidElement(s)){var{labelRef:x}=v,M=U1e(v,F1e);return E.cloneElement(s,M)}if(typeof s=="function"){if(b=E.createElement(s,v),E.isValidElement(b))return b}else b=W1e(e);var S=na(e);if(k3(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return K1e(e,r,b,S,m);y=X1e(m,e.offset,e.position)}else y=Y1e(e,m);return E.createElement(ma,{zIndex:e.zIndex},E.createElement(CM,uc({ref:u,className:Mn("recharts-label",o)},S,y,{textAnchor:D1e(S.textAnchor)?S.textAnchor:y.textAnchor,breakAll:c}),b))}Nu.displayName="Label";var Q1e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Nu,uc({key:"label-implicit"},r)):co(t)?E.createElement(Nu,uc({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Nu?E.cloneElement(t,Ur({key:"label-implicit"},r)):E.createElement(Nu,uc({key:"label-implicit",content:t},r)):Rj(t)?E.createElement(Nu,uc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Nu,uc({},t,{key:"label-implicit"},r)):null};function IX(t){var{label:e,labelRef:n}=t,r=LX();return Q1e(e,r,n)||null}var JT={},eC={},N8;function J1e(){return N8||(N8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(eC)),eC}var tC={},k8;function ewe(){return k8||(k8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(tC)),tC}var P8;function twe(){return P8||(P8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=J1e(),n=ewe(),r=sD();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(JT)),JT}var nC,R8;function nwe(){return R8||(R8=1,nC=twe().last),nC}var rwe=nwe();const iwe=fo(rwe);var awe=["valueAccessor"],swe=["dataKey","clockWise","id","textBreakAll","zIndex"];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 D8(t,e){if(t==null)return{};var n,r,i=owe(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 owe(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 lwe=t=>Array.isArray(t.value)?iwe(t.value):t.value,FX=E.createContext(void 0),Dj=FX.Provider,UX=E.createContext(void 0),cwe=UX.Provider;function uwe(){return E.useContext(FX)}function dwe(){return E.useContext(UX)}function a1(t){var{valueAccessor:e=lwe}=t,n=D8(t,awe),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:o}=n,c=D8(n,swe),u=uwe(),d=dwe(),f=u||d;return!f||!f.length?null:E.createElement(ma,{zIndex:o??Rr.label},E.createElement(wr,{className:"recharts-label-list"},f.map((g,m)=>{var b,y=dr(r)?e(g,m):Bn(g&&g.payload,r),v=dr(a)?{}:{id:"".concat(a,"-").concat(m)};return E.createElement(Nu,fw({key:"label-".concat(m)},na(g),c,v,{fill:(b=n.fill)!==null&&b!==void 0?b:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:s,viewBox:g.viewBox,index:m,zIndex:0}))})))}a1.displayName="LabelList";function NM(t){var{label:e}=t;return e?e===!0?E.createElement(a1,{key:"labelList-implicit"}):E.isValidElement(e)||Rj(e)?E.createElement(a1,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(a1,fw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function P3(){return P3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P3.apply(null,arguments)}var zX=t=>{var{cx:e,cy:n,r,className:i}=t,a=Mn("recharts-dot",i);return Pt(e)&&Pt(n)&&Pt(r)?E.createElement("circle",P3({},Ca(t),aD(t),{className:a,cx:e,cy:n,r})):null},BX=t=>t.graphicalItems.polarItems,hwe=Ge([xr,Db],nj),kM=Ge([BX,Mr,hwe],rj),fwe=Ge([kM],ij),PM=Ge([fwe,WD],aj),pwe=Ge([PM,Mr,kM],oj);Ge([PM,Mr,kM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Bn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Bn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var j8=()=>{},mwe=Ge([PM,Mr,kM,MM,xr],dj),gwe=Ge([Mr,cj,uj,j8,mwe,j8,xn,xr],hj),HX=Ge([Mr,xn,PM,pwe,Rb,xr,gwe],fj),xwe=Ge([HX,Mr,rg],gj);Ge([Mr,HX,xwe,xr],bj);var bwe={radiusAxis:{},angleAxis:{}},$X=Qa({name:"polarAxis",initialState:bwe,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:GGe,removeRadiusAxis:WGe,addAngleAxis:qGe,removeAngleAxis:KGe}=$X.actions,ywe=$X.reducer;function O8(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 L8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O8(Object(n),!0).forEach(function(r){vwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vwe(t,e,n){return(e=_we(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _we(t){var e=wwe(t,"string");return typeof e=="symbol"?e:e+""}function wwe(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 Swe=(t,e)=>e,jj=Ge([BX,Swe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),Mwe=[],Oj=(t,e,n)=>n?.length===0?Mwe:n,VX=Ge([WD,jj,Oj],(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=>L8(L8({},e.presentationProps),a.props))),i!=null)return i}}),Ewe=Ge([VX,jj,Oj],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Bn(r,e.nameKey,e.name),o;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:vd(s,e.dataKey),color:o,payload:r,type:e.legendType}})}),Awe=Ge([VX,jj,Oj,bi],(t,e,n,r)=>{if(!(e==null||t==null))return TSe({offset:r,pieSettings:e,displayedData:t,cells:n})}),rC={exports:{}},Wn={};var I8;function Twe(){if(I8)return Wn;I8=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"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function b(y){if(typeof y=="object"&&y!==null){var v=y.$$typeof;switch(v){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case g:return y;default:switch(y=y&&y.$$typeof,y){case s:case o:case f:case d:return y;case a:return y;default:return v}}case e:return v}}}return Wn.ContextConsumer=a,Wn.ContextProvider=s,Wn.Element=t,Wn.ForwardRef=o,Wn.Fragment=n,Wn.Lazy=f,Wn.Memo=d,Wn.Portal=e,Wn.Profiler=i,Wn.StrictMode=r,Wn.Suspense=c,Wn.SuspenseList=u,Wn.isContextConsumer=function(y){return b(y)===a},Wn.isContextProvider=function(y){return b(y)===s},Wn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Wn.isForwardRef=function(y){return b(y)===o},Wn.isFragment=function(y){return b(y)===n},Wn.isLazy=function(y){return b(y)===f},Wn.isMemo=function(y){return b(y)===d},Wn.isPortal=function(y){return b(y)===e},Wn.isProfiler=function(y){return b(y)===i},Wn.isStrictMode=function(y){return b(y)===r},Wn.isSuspense=function(y){return b(y)===c},Wn.isSuspenseList=function(y){return b(y)===u},Wn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===s||y.$$typeof===a||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},Wn.typeOf=b,Wn}var F8;function Cwe(){return F8||(F8=1,rC.exports=Twe()),rC.exports}var Nwe=Cwe(),U8=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",z8=null,iC=null,GX=t=>{if(t===z8&&Array.isArray(iC))return iC;var e=[];return E.Children.forEach(t,n=>{dr(n)||(Nwe.isFragment(n)?e=e.concat(GX(n.props.children)):e.push(n))}),iC=e,z8=t,e};function Lj(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>U8(i)):r=[U8(e)],GX(t).forEach(i=>{var a=Wh(i,"type.displayName")||Wh(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var Ij=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,aC={},B8;function kwe(){return B8||(B8=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})(aC)),aC}var sC,H8;function Pwe(){return H8||(H8=1,sC=kwe().isPlainObject),sC}var Rwe=Pwe();const Dwe=fo(Rwe);function $8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function V8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$8(Object(n),!0).forEach(function(r){jwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jwe(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)}function pw(){return pw=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},pw.apply(null,arguments)}var G8=(t,e,n,r,i)=>{var a=n-r,s;return s="M ".concat(t,",").concat(e),s+="L ".concat(t+n,",").concat(e),s+="L ".concat(t+n-a/2,",").concat(e+i),s+="L ".concat(t+n-a/2-r,",").concat(e+i),s+="L ".concat(t,",").concat(e," Z"),s},Iwe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Fwe=t=>{var e=Sr(t,Iwe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:s,className:o}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=E.useRef(null),[m,b]=E.useState(-1),y=E.useRef(i),v=E.useRef(a),x=E.useRef(s),M=E.useRef(n),S=E.useRef(r),A=Zm(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&b(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var T=Mn("recharts-trapezoid",o);if(!f)return E.createElement("g",null,E.createElement("path",pw({},na(e),{className:T,d:G8(n,r,i,a,s)})));var k=y.current,N=v.current,I=x.current,C=M.current,D=S.current,F="0px ".concat(m===-1?1:m,"px"),O="".concat(m,"px 0px"),q=fq(["strokeDasharray"],u,c);return E.createElement(Ym,{animationId:A,key:A,canBegin:m>0,duration:u,easing:c,isActive:f,begin:d},R=>{var W=jn(k,i,R),K=jn(N,a,R),G=jn(I,s,R),ee=jn(C,n,R),Z=jn(D,r,R);g.current&&(y.current=W,v.current=K,x.current=G,M.current=ee,S.current=Z);var Q=R>0?{transition:q,strokeDasharray:O}:{strokeDasharray:F};return E.createElement("path",pw({},na(e),{className:T,d:G8(ee,Z,W,K,G),ref:g,style:V8(V8({},Q),e.style)}))})},Uwe=["option","shapeType","propTransformer","activeClassName"];function zwe(t,e){if(t==null)return{};var n,r,i=Bwe(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 Bwe(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 W8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function mw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W8(Object(n),!0).forEach(function(r){Hwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hwe(t,e,n){return(e=$we(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $we(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)}function Gwe(t,e){return mw(mw({},e),t)}function Wwe(t,e){return t==="symbols"}function q8(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return E.createElement(xq,n);case"trapezoid":return E.createElement(Fwe,n);case"sector":return E.createElement(_q,n);case"symbols":if(Wwe(e))return E.createElement(iD,n);break;case"curve":return E.createElement(em,n);default:return null}}function qwe(t){return E.isValidElement(t)?t.props:t}function Fj(t){var{option:e,shapeType:n,propTransformer:r=Gwe,activeClassName:i="recharts-active-shape"}=t,a=zwe(t,Uwe),s;if(E.isValidElement(e))s=E.cloneElement(e,mw(mw({},a),qwe(e)));else if(typeof e=="function")s=e(a,a.index);else if(Dwe(e)&&typeof e!="boolean"){var o=r(e,a);s=E.createElement(q8,{shapeType:n,elementProps:o})}else{var c=a;s=E.createElement(q8,{shapeType:n,elementProps:c})}return a.isActive?E.createElement(wr,{className:i},s):s}var Uj=(t,e,n)=>{var r=rr();return(i,a)=>s=>{t?.(i,a,s),r(nX({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},zj=t=>{var e=rr();return(n,r)=>i=>{t?.(n,r,i),e(lve())}},Bj=(t,e,n)=>{var r=rr();return(i,a)=>s=>{t?.(i,a,s),r(cve({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function RM(t){var{tooltipEntrySettings:e}=t,n=rr(),r=yi(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(ive(e)):i.current!==e&&n(ave({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(sve(i.current)),i.current=null)},[n]),null}function Hj(t){var{legendPayload:e}=t,n=rr(),r=yi(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(cq(e)):i.current!==e&&n(uq({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(dq(i.current)),i.current=null)},[n]),null}function Kwe(t){var{legendPayload:e}=t,n=rr(),r=Ct(xn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(cq(e)):i.current!==e&&n(uq({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(dq(i.current)),i.current=null)},[n]),null}var oC,Xwe=()=>{var[t]=E.useState(()=>T0("uid-"));return t},Ywe=(oC=Nre.useId)!==null&&oC!==void 0?oC:Xwe;function WX(t,e){var n=Ywe();return e||(t?"".concat(t,"-").concat(n):n)}var Zwe=E.createContext(void 0),DM=t=>{var{id:e,type:n,children:r}=t,i=WX("recharts-".concat(n),e);return E.createElement(Zwe.Provider,{value:i},r(i))},Qwe={cartesianItems:[],polarItems:[]},qX=Qa({name:"graphicalItems",initialState:Qwe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Lo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:fr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:fr()},removePolarGraphicalItem:{reducer(t,e){var n=Lo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:fr()}}}),{addCartesianGraphicalItem:Jwe,replaceCartesianGraphicalItem:eSe,removeCartesianGraphicalItem:tSe,addPolarGraphicalItem:nSe,removePolarGraphicalItem:rSe}=qX.actions,iSe=qX.reducer,aSe=t=>{var e=rr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(Jwe(t)):n.current!==t&&e(eSe({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(tSe(n.current)),n.current=null)},[e]),null},$j=E.memo(aSe);function sSe(t){var e=rr();return E.useLayoutEffect(()=>(e(nSe(t)),()=>{e(rSe(t))}),[e,t]),null}var oSe=["key"],lSe=["onMouseEnter","onClick","onMouseLeave"],cSe=["id"],uSe=["id"];function K8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K8(Object(n),!0).forEach(function(r){dSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dSe(t,e,n){return(e=hSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hSe(t){var e=fSe(t,"string");return typeof e=="symbol"?e:e+""}function fSe(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 ud(){return ud=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},ud.apply(null,arguments)}function jM(t,e){if(t==null)return{};var n,r,i=pSe(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 pSe(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 mSe(t){var e=E.useMemo(()=>Lj(t.children,$b),[t.children]),n=Ct(r=>Ewe(r,t.id,e));return n==null?null:E.createElement(Kwe,{legendPayload:n})}var gSe=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:s,name:o,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:vd(o,e),hide:c,type:u,color:s,unit:""}};return E.createElement(RM,{tooltipEntrySettings:d})}),xSe=(t,e)=>t>e?"start":t<e?"end":"middle",bSe=(t,e,n)=>pa(typeof e=="function"?e(t):e,n,n*.8),ySe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,o=bq(a,s),c=i+pa(t.cx,a,a/2),u=r+pa(t.cy,s,s/2),d=pa(t.innerRadius,o,0),f=bSe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},vSe=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function _Se(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var wSe=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Mn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=jM(e,oSe);return E.createElement(em,ud({},i,{type:"linear",className:n}))},SSe=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),E.isValidElement(r)))return r;var i=Mn("recharts-pie-label-text",_Se(t));return E.createElement(CM,ud({},e,{alignmentBaseline:"middle",className:i}),r)};function MSe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var o=Ca(n),c=Gh(i),u=Gh(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,m)=>{var b=(g.startAngle+g.endAngle)/2,y=Jr(g.cx,g.cy,g.outerRadius+d,b),v=kr(kr(kr(kr({},o),g),{},{stroke:"none"},c),{},{index:m,textAnchor:xSe(y.x,g.cx)},y),x=kr(kr(kr(kr({},o),g),{},{fill:"none",stroke:g.fill},u),{},{index:m,points:[Jr(g.cx,g.cy,g.outerRadius,b),y],key:"line"});return E.createElement(ma,{zIndex:Rr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(wr,null,a&&wSe(a,x),SSe(i,v,Bn(g,s))))});return E.createElement(wr,{className:"recharts-pie-labels"},f)}function ESe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(NM,{label:i}):E.createElement(MSe,{sectors:e,props:n,showLabels:r})}function ASe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,o=Ct(cd),c=Ct(Tj),u=Ct(Kve),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,m=jM(i,lSe),b=Uj(d,i.dataKey,s),y=zj(g),v=Bj(f,i.dataKey,s);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var S=u==null||u===s,A=String(M)===o&&(c==null||i.dataKey===c)&&S,T=o?r:null,k=n&&A?n:T,N=kr(kr({},x),{},{stroke:x.stroke,tabIndex:-1,[XW]:M,[YW]:i.dataKey});return E.createElement(wr,ud({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},vb(m,x,M),{onMouseEnter:b(x,M),onMouseLeave:y(x,M),onClick:v(x,M)}),E.createElement(Fj,ud({option:a??k,index:M,shapeType:"sector",isActive:A},N)))}))}function TSe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:s,startAngle:o,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),m=vSe(o,c),b=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(k=>Bn(k,u,0)!==0).length,x=(b>=360?v:v-1)*y,M=b-v*g-x,S=r.reduce((k,N)=>{var I=Bn(N,u,0);return k+(Pt(I)?I:0)},0),A;if(S>0){var T;A=r.map((k,N)=>{var I=Bn(k,u,0),C=Bn(k,d,N),D=ySe(n,a,k),F=(Pt(I)?I:0)/S,O,q=kr(kr({},k),i&&i[N]&&i[N].props);N?O=T.endAngle+Li(m)*y*(I!==0?1:0):O=o;var R=O+Li(m)*((I!==0?g:0)+F*M),W=(O+R)/2,K=(D.innerRadius+D.outerRadius)/2,G=[{name:C,value:I,payload:q,dataKey:u,type:f}],ee=Jr(D.cx,D.cy,K,W);return T=kr(kr(kr(kr({},n.presentationProps),{},{percent:F,cornerRadius:typeof s=="string"?parseFloat(s):s,name:C,tooltipPayload:G,midAngle:W,middleRadius:K,tooltipPosition:ee},q),D),{},{value:I,dataKey:u,startAngle:O,endAngle:R,payload:q,paddingAngle:Li(m)*y}),T})}return A}function CSe(t){var{showLabels:e,sectors:n,children:r}=t,i=E.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 E.createElement(cwe,{value:e?i:void 0},r)}function NSe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,m=Zm(e,"recharts-pie-"),b=n.current,[y,v]=E.useState(!1),x=E.useCallback(()=>{typeof g=="function"&&g(),v(!1)},[g]),M=E.useCallback(()=>{typeof f=="function"&&f(),v(!0)},[f]);return E.createElement(CSe,{showLabels:!y,sectors:i},E.createElement(Ym,{animationId:m,begin:s,duration:o,isActive:a,easing:c,onAnimationStart:M,onAnimationEnd:x,key:m},S=>{var A=[],T=i&&i[0],k=T?.startAngle;return i?.forEach((N,I)=>{var C=b&&b[I],D=I>0?Wh(N,"paddingAngle",0):0;if(C){var F=jn(C.endAngle-C.startAngle,N.endAngle-N.startAngle,S),O=kr(kr({},N),{},{startAngle:k+D,endAngle:k+F+D});A.push(O),k=O.endAngle}else{var{endAngle:q,startAngle:R}=N,W=jn(0,q-R,S),K=kr(kr({},N),{},{startAngle:k+D,endAngle:k+W+D});A.push(K),k=K.endAngle}}),n.current=A,E.createElement(wr,null,E.createElement(ASe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(ESe,{showLabels:!y,sectors:i,props:e}),e.children)}var kSe={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:Rr.area};function PSe(t){var{id:e}=t,n=jM(t,cSe),{hide:r,className:i,rootTabIndex:a}=t,s=E.useMemo(()=>Lj(t.children,$b),[t.children]),o=Ct(d=>Awe(d,e,s)),c=E.useRef(null),u=Mn("recharts-pie",i);return r||o==null?(c.current=null,E.createElement(wr,{tabIndex:a,className:u})):E.createElement(ma,{zIndex:t.zIndex},E.createElement(gSe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),E.createElement(wr,{tabIndex:a,className:u},E.createElement(NSe,{props:kr(kr({},n),{},{sectors:o}),previousSectorsRef:c,id:e})))}function KX(t){var e=Sr(t,kSe),{id:n}=e,r=jM(e,uSe),i=Ca(r);return E.createElement(DM,{id:n,type:"pie"},a=>E.createElement(E.Fragment,null,E.createElement(sSe,{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}),E.createElement(mSe,ud({},r,{id:a})),E.createElement(PSe,ud({},r,{id:a}))))}KX.displayName="Pie";var RSe=["points"];function X8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X8(Object(n),!0).forEach(function(r){DSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DSe(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=OSe(t,"string");return typeof e=="symbol"?e:e+""}function OSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gw(){return gw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},gw.apply(null,arguments)}function LSe(t,e){if(t==null)return{};var n,r,i=ISe(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 ISe(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 FSe(t){var{option:e,dotProps:n,className:r}=t;if(E.isValidElement(e))return E.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Mn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,o=LSe(a,RSe);return E.createElement(zX,gw({},o,{className:i}))}function USe(t,e){return t==null?!1:e?!0:t.length===1}function XX(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:o,clipPathId:c,zIndex:u=Rr.scatter}=t;if(!USe(e,n))return null;var d=Ij(n),f=gde(n),g=e.map((b,y)=>{var v,x,M=lC(lC(lC({r:3},s),f),{},{index:y,cx:(v=b.x)!==null&&v!==void 0?v:void 0,cy:(x=b.y)!==null&&x!==void 0?x:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return E.createElement(FSe,{key:"dot-".concat(y),option:n,dotProps:M,className:i})}),m={};return o&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),E.createElement(ma,{zIndex:u},E.createElement(wr,gw({className:r},m),g))}function Y8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Z8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y8(Object(n),!0).forEach(function(r){zSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zSe(t,e,n){return(e=BSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BSe(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)}var $Se={xAxis:{},yAxis:{},zAxis:{}},YX=Qa({name:"cartesianAxis",initialState:$Se,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:fr()},replaceXAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.xAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.xAxis[n.id],t.xAxis[r.id]=r)},prepare:fr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:fr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:fr()},replaceYAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.yAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.yAxis[n.id],t.yAxis[r.id]=r)},prepare:fr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:fr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:fr()},replaceZAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.zAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.zAxis[n.id],t.zAxis[r.id]=r)},prepare:fr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:fr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var s=[...a,r].slice(-3);t.yAxis[n]=Z8(Z8({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:VSe,replaceXAxis:GSe,removeXAxis:WSe,addYAxis:qSe,replaceYAxis:KSe,removeYAxis:XSe,addZAxis:XGe,replaceZAxis:YGe,removeZAxis:ZGe,updateYAxisWidth:YSe}=YX.actions,ZSe=YX.reducer,QSe=Ge([bi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),JSe=Ge([QSe,Fc,Uc],(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)}}),OM=()=>Ct(JSe),eMe=()=>Ct(Jve);function Q8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function cC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q8(Object(n),!0).forEach(function(r){tMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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)}var iMe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:s}=t;if(i===!1||e.x==null||e.y==null)return null;var o={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=cC(cC(cC({},o),Gh(i)),aD(i)),u;return E.isValidElement(i)?u=E.cloneElement(i,c):typeof i=="function"?u=i(c):u=E.createElement(zX,c),E.createElement(wr,{className:"recharts-active-dot",clipPath:s},u)};function R3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=Rr.activeDot}=t,o=Ct(cd),c=eMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return dr(u)?null:E.createElement(ma,{zIndex:s},E.createElement(iMe,{point:u,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var aMe="Invariant failed";function sMe(t,e){throw new Error(aMe)}var oMe=["x","y"];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 J8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function px(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J8(Object(n),!0).forEach(function(r){lMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lMe(t,e,n){return(e=cMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cMe(t){var e=uMe(t,"string");return typeof e=="symbol"?e:e+""}function uMe(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 dMe(t,e){if(t==null)return{};var n,r,i=hMe(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 hMe(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 fMe(t,e){var{x:n,y:r}=t,i=dMe(t,oMe),a="".concat(n),s=parseInt(a,10),o="".concat(r),c=parseInt(o,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return px(px(px(px(px({},e),i),s?{x:s}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function xw(t){return E.createElement(Fj,D3({shapeType:"rectangle",propTransformer:fMe,activeClassName:"recharts-active-bar"},t))}var pMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Pt(e))return e;var a=Pt(r)||dr(r);return a?e(r,i):(a||sMe(),n)}},mMe={},ZX=Qa({name:"errorBars",initialState:mMe,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:QGe,replaceErrorBar:JGe,removeErrorBar:eWe}=ZX.actions,gMe=ZX.reducer,xMe=["children"];function bMe(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}var vMe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},_Me=E.createContext(vMe);function QX(t){var{children:e}=t,n=bMe(t,xMe);return E.createElement(_Me.Provider,{value:n},e)}function LM(t,e){var n,r,i=Ct(u=>Sl(u,t)),a=Ct(u=>Ml(u,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Pi.allowDataOverflow,o=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Ri.allowDataOverflow,c=s||o;return{needClip:c,needClipX:s,needClipY:o}}function Vj(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=OM(),{needClipX:a,needClipY:s,needClip:o}=LM(e,n);if(!o||!i)return null;var{x:c,y:u,width:d,height:f}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:a?c:c-d/2,y:s?u:u-f/2,width:a?d:d*2,height:s?f:f*2}))}function wMe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Hn(t.zIndex)?t.zIndex:e}var uC={exports:{}},dC={};var e6;function SMe(){if(e6)return dC;e6=1;var t=$m();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,s=t.useMemo,o=t.useDebugValue;return dC.useSyncExternalStoreWithSelector=function(c,u,d,f,g){var m=i(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=s(function(){function v(T){if(!x){if(x=!0,M=T,T=f(T),g!==void 0&&b.hasValue){var k=b.value;if(g(k,T))return S=k}return S=T}if(k=S,n(M,T))return k;var N=f(T);return g!==void 0&&g(k,N)?(M=T,k):(M=T,S=N)}var x=!1,M,S,A=d===void 0?null:d;return[function(){return v(u())},A===null?void 0:function(){return v(A())}]},[u,d,f,g]);var y=r(c,m[0],m[1]);return a(function(){b.hasValue=!0,b.value=y},[y]),o(y),y},dC}var t6;function MMe(){return t6||(t6=1,uC.exports=SMe()),uC.exports}MMe();function EMe(t){t()}function AMe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){EMe(()=>{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 n6={notify(){},get:()=>[]};function TMe(t,e){let n,r=n6,i=0,a=!1;function s(y){d();const v=r.subscribe(y);let x=!1;return()=>{x||(x=!0,v(),f())}}function o(){r.notify()}function c(){b.onStateChange&&b.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=AMe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=n6)}function g(){a||(a=!0,d())}function m(){a&&(a=!1,f())}const b={addNestedSub:s,notifyNestedSubs:o,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return b}var CMe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",NMe=CMe(),kMe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",PMe=kMe(),RMe=()=>NMe||PMe?E.useLayoutEffect:E.useEffect,DMe=RMe();function r6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function jMe(t,e){if(r6(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])||!r6(t[n[i]],e[n[i]]))return!1;return!0}var OMe=Symbol.for("react-redux-context"),LMe=typeof globalThis<"u"?globalThis:{};function IMe(){if(!E.createContext)return{};const t=LMe[OMe]??=new Map;let e=t.get(E.createContext);return e||(e=E.createContext(null),t.set(E.createContext,e)),e}var FMe=IMe();function UMe(t){const{children:e,context:n,serverState:r,store:i}=t,a=E.useMemo(()=>{const c=TMe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),s=E.useMemo(()=>i.getState(),[i]);DMe(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),s!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,s]);const o=n||FMe;return E.createElement(o.Provider,{value:a},e)}var zMe=UMe,BMe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function HMe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Vb(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(BMe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!jMe(t[r],e[r]))return!1}else if(!HMe(t[r],e[r]))return!1;return!0}var $Me=["onMouseEnter","onMouseLeave","onClick"],VMe=["value","background","tooltipPosition"],GMe=["id"],WMe=["onMouseEnter","onClick","onMouseLeave"];function Oc(){return Oc=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},Oc.apply(null,arguments)}function i6(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 Sa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i6(Object(n),!0).forEach(function(r){qMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qMe(t,e,n){return(e=KMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KMe(t){var e=XMe(t,"string");return typeof e=="symbol"?e:e+""}function XMe(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 bw(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}var ZMe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:vd(n,e),payload:t}]},QMe=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:o,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:vd(a,e),hide:s,type:c,color:i,unit:o}};return E.createElement(RM,{tooltipEntrySettings:u})});function JMe(t){var e=Ct(cd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:o,onClick:c}=a,u=bw(a,$Me),d=Uj(s,r),f=zj(o),g=Bj(c,r);if(!i||n==null)return null;var m=Gh(i);return E.createElement(ma,{zIndex:wMe(i,Rr.barBackground)},n.map((b,y)=>{var{value:v,background:x,tooltipPosition:M}=b,S=bw(b,VMe);if(!x)return null;var A=d(b,y),T=f(b,y),k=g(b,y),N=Sa(Sa(Sa(Sa(Sa({option:i,isActive:String(y)===e},S),{},{fill:"#eee"},x),m),vb(u,b,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return E.createElement(xw,Oc({key:"background-bar-".concat(y)},N))}))}function eEe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var s={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Sa(Sa({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return E.createElement(Dj,{value:e?i:void 0},n)}function tEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,o=Ct(cd),c=Ct(Tj),u=n&&String(a)===o&&(c==null||s===c),d=u?n:e;return u?E.createElement(ma,{zIndex:Rr.activeBar},E.createElement(xw,Oc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))):E.createElement(xw,Oc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))}function nEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return E.createElement(xw,Oc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function rEe(t){var e,{data:n,props:r}=t,i=(e=Ca(r))!==null&&e!==void 0?e:{},{id:a}=i,s=bw(i,GMe),{shape:o,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,m=bw(r,WMe),b=Uj(d,c),y=zj(g),v=Bj(f,c);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(wr,Oc({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},vb(m,x,M),{onMouseEnter:b(x,M),onMouseLeave:y(x,M),onClick:v(x,M)}),u?E.createElement(tEe,{shape:o,activeBar:u,baseProps:s,entry:x,index:M,dataKey:c}):E.createElement(nEe,{shape:o,baseProps:s,entry:x,index:M,dataKey:c})))):null}function iEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=Zm(e,"recharts-bar-"),[m,b]=E.useState(!1),y=!m,v=E.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),x=E.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return E.createElement(eEe,{showLabels:y,rects:r},E.createElement(Ym,{animationId:g,begin:s,duration:o,isActive:a,easing:c,onAnimationEnd:v,onAnimationStart:x,key:g},M=>{var S=M===1?r:r?.map((A,T)=>{var k=f&&f[T];if(k)return Sa(Sa({},A),{},{x:jn(k.x,A.x,M),y:jn(k.y,A.y,M),width:jn(k.width,A.width,M),height:jn(k.height,A.height,M)});if(i==="horizontal"){var N=jn(0,A.height,M),I=jn(A.stackedBarStart,A.y,M);return Sa(Sa({},A),{},{y:I,height:N})}var C=jn(0,A.width,M),D=jn(A.stackedBarStart,A.x,M);return Sa(Sa({},A),{},{width:C,x:D})});return M>0&&(n.current=S??null),S==null?null:E.createElement(wr,null,E.createElement(rEe,{props:e,data:S}))}),E.createElement(NM,{label:e.label}),e.children)}function aEe(t){var e=E.useRef(null);return E.createElement(iEe,{previousRectanglesRef:e,props:t})}var JX=0,sEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Bn(t,e)}};class oEe extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:s,needClip:o,background:c,id:u}=this.props;if(e||n==null)return null;var d=Mn("recharts-bar",i),f=u;return E.createElement(wr,{className:d,id:u},o&&E.createElement("defs",null,E.createElement(Vj,{clipPathId:f,xAxisId:a,yAxisId:s})),E.createElement(wr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},E.createElement(JMe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),E.createElement(aEe,this.props)))}}var lEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:JX,xAxisId:0,yAxisId:0,zIndex:Rr.bar};function cEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=LM(e,n),g=df(),m=yi(),b=Lj(t.children,$b),y=Ct(M=>IEe(M,e,n,m,t.id,b));if(g!=="vertical"&&g!=="horizontal")return null;var v,x=y?.[0];return x==null||x.height==null||x.width==null?v=0:v=g==="vertical"?x.height/2:x.width/2,E.createElement(QX,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:sEe,errorBarOffset:v},E.createElement(oEe,Oc({},t,{layout:g,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function uEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:s,yAxis:o,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:m,parentViewBox:b,dataStartIndex:y}=t,v=e==="horizontal"?o:s,x=d?v.scale.domain():null,M=Dpe({numericAxis:v}),S=v.scale(M);return f.map((A,T)=>{var k,N,I,C,D,F;d?k=Cpe(d[T+y],x):(k=Bn(A,n),Array.isArray(k)||(k=[M,k]));var O=pMe(r,JX)(k[1],T);if(e==="horizontal"){var q,[R,W]=[o.scale(k[0]),o.scale(k[1])];N=_z({axis:s,ticks:c,bandSize:a,offset:i.offset,entry:A,index:T}),I=(q=W??R)!==null&&q!==void 0?q:void 0,C=i.size;var K=R-W;if(D=Za(K)?0:K,F={x:N,y:g.top,width:C,height:g.height},Math.abs(O)>0&&Math.abs(D)<Math.abs(O)){var G=Li(D||O)*(Math.abs(O)-Math.abs(D));I-=G,D+=G}}else{var[ee,Z]=[s.scale(k[0]),s.scale(k[1])];if(N=ee,I=_z({axis:o,ticks:u,bandSize:a,offset:i.offset,entry:A,index:T}),C=Z-ee,D=i.size,F={x:g.left,y:I,width:g.width,height:D},Math.abs(O)>0&&Math.abs(C)<Math.abs(O)){var Q=Li(C||O)*(Math.abs(O)-Math.abs(C));C+=Q}}if(N==null||I==null||C==null||D==null)return null;var U=Sa(Sa({},A),{},{stackedBarStart:S,x:N,y:I,width:C,height:D,value:d?k:k[1],payload:A,background:F,tooltipPosition:{x:N+C/2,y:I+D/2},parentViewBox:b},m&&m[T]&&m[T].props);return U}).filter(Boolean)}function dEe(t){var e=Sr(t,lEe),n=yi();return E.createElement(DM,{id:e.id,type:"bar"},r=>E.createElement(E.Fragment,null,E.createElement(Hj,{legendPayload:ZMe(e)}),E.createElement(QMe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement($j,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:qW(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(ma,{zIndex:e.zIndex},E.createElement(cEe,Oc({},e,{id:r})))))}var eY=E.memo(dEe,Vb);eY.displayName="Bar";function a6(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 Rv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a6(Object(n),!0).forEach(function(r){hEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hEe(t,e,n){return(e=fEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fEe(t){var e=pEe(t,"string");return typeof e=="symbol"?e:e+""}function pEe(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 mEe=(t,e)=>e,gEe=(t,e,n)=>n,xEe=(t,e,n,r)=>r,bEe=(t,e,n,r,i)=>i,Gb=Ge([Ob,bEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),yEe=Ge([Gb],t=>t?.maxBarSize),vEe=(t,e,n,r,i,a)=>a,s6=(t,e,n)=>{var r=n??t;if(!dr(r))return pa(r,e,0)},_Ee=Ge([xn,Ob,mEe,gEe,xEe],(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")),wEe=(t,e,n,r)=>{var i=xn(t);return i==="horizontal"?z0(t,"yAxis",n,r):z0(t,"xAxis",e,r)},SEe=(t,e,n)=>{var r=xn(t);return r==="horizontal"?e8(t,"xAxis",e):e8(t,"yAxis",n)},MEe=(t,e,n)=>{var r={},i=t.filter(vM),a=t.filter(u=>u.stackId==null),s=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),o=Object.entries(s).map(u=>{var[d,f]=u,g=f.map(b=>b.dataKey),m=s6(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),c=a.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=s6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...o,...c]},EEe=Ge([_Ee,Ybe,SEe],MEe),AEe=(t,e,n,r,i)=>{var a,s,o=Gb(t,e,n,r,i);if(o!=null){var c=xn(t),u=xK(t),{maxBarSize:d}=o,f=dr(d)?u:d,g,m;return c==="horizontal"?(g=ml(t,"xAxis",e,r),m=pl(t,"xAxis",e,r)):(g=ml(t,"yAxis",n,r),m=pl(t,"yAxis",n,r)),(a=(s=sd(g,m,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},tY=(t,e,n,r)=>{var i=xn(t),a,s;return i==="horizontal"?(a=ml(t,"xAxis",e,r),s=pl(t,"xAxis",e,r)):(a=ml(t,"yAxis",n,r),s=pl(t,"yAxis",n,r)),sd(a,s)};function TEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=pa(t,n,0,!0),o,c=[];if(Hn(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((x,M)=>x+(M.barSize||0),0);f+=(a-1)*s,f>=n&&(f-=(a-1)*s,s=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var g=(n-f)/2>>0,m={offset:g-s,size:0};o=r.reduce((x,M)=>{var S,A={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+s,size:u?d:(S=M.barSize)!==null&&S!==void 0?S:0}},T=[...x,A];return m=T[T.length-1].position,T},c)}else{var b=pa(e,n,0,!0);n-2*b-(a-1)*s<=0&&(s=0);var y=(n-2*b-(a-1)*s)/a;y>1&&(y>>=0);var v=Hn(i)?Math.min(y,i):y;o=r.reduce((x,M,S)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:b+(y+s)*S+(y-v)/2,size:v}}],c)}return o}}var CEe=(t,e,n,r,i,a,s)=>{var o=dr(s)?e:s,c=TEe(n,r,i!==a?i:a,t,o);return i!==a&&c!=null&&(c=c.map(u=>Rv(Rv({},u),{},{position:Rv(Rv({},u.position),{},{offset:u.position.offset-i/2})}))),c},NEe=Ge([EEe,xK,Xbe,bK,AEe,tY,yEe],CEe),kEe=(t,e,n,r)=>ml(t,"xAxis",e,r),PEe=(t,e,n,r)=>ml(t,"yAxis",n,r),REe=(t,e,n,r)=>pl(t,"xAxis",e,r),DEe=(t,e,n,r)=>pl(t,"yAxis",n,r),jEe=Ge([NEe,Gb],(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}}),OEe=(t,e)=>{var n=yM(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(s=>s.key===n)}}}},LEe=Ge([wEe,Gb],OEe),IEe=Ge([bi,gD,kEe,PEe,REe,DEe,jEe,xn,Pb,tY,LEe,Gb,vEe],(t,e,n,r,i,a,s,o,c,u,d,f,g)=>{var{chartData:m,dataStartIndex:b,dataEndIndex:y}=c;if(!(f==null||s==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:v}=f,x;if(v!=null&&v.length>0?x=v:x=m?.slice(b,y+1),x!=null)return uEe({layout:o,barSettings:f,pos:s,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:x,offset:t,cells:g,dataStartIndex:b})}}),nY=t=>{var{chartData:e}=t,n=rr(),r=yi();return E.useEffect(()=>r?()=>{}:(n(f8(e)),()=>{n(f8(void 0))}),[e,n,r]),null},o6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},rY=Qa({name:"brush",initialState:o6,reducers:{setBrushSettings(t,e){return e.payload==null?o6:e.payload}}}),{setBrushSettings:tWe}=rY.actions,FEe=rY.reducer;function l6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Dv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l6(Object(n),!0).forEach(function(r){iY(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iY(t,e,n){return(e=UEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UEe(t){var e=zEe(t,"string");return typeof e=="symbol"?e:e+""}function zEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var BEe=(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)}},HEe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return BEe({x:e,y:n},{x:r,y:i})};class IM{static create(e){return new IM(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 s=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+s}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}}iY(IM,"EPS",1e-4);var $Ee=t=>{var e=Object.keys(t).reduce((n,r)=>Dv(Dv({},n),{},{[r]:IM.create(t[r])}),{});return Dv(Dv({},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[s,o]=a;return[s,e[s].apply(o,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function VEe(t){return(t%180+180)%180}var GEe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=VEe(i),s=a*Math.PI/180,o=Math.atan(r/n),c=s>o&&s<Math.PI-o?r/Math.sin(s):n/Math.cos(s);return Math.abs(c)},WEe={dots:[],areas:[],lines:[]},aY=Qa({name:"referenceElements",initialState:WEe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Lo(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=Lo(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=Lo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:nWe,removeDot:rWe,addArea:iWe,removeArea:aWe,addLine:qEe,removeLine:KEe}=aY.actions,XEe=aY.reducer,sY=E.createContext(void 0),YEe=t=>{var{children:e}=t,[n]=E.useState("".concat(T0("recharts"),"-clip")),r=OM();if(r==null)return null;var{x:i,y:a,width:s,height:o}=r;return E.createElement(sY.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:a,height:o,width:s}))),e)},ZEe=()=>E.useContext(sY);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 u6(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){QEe(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 QEe(t,e,n){return(e=JEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JEe(t){var e=e2e(t,"string");return typeof e=="symbol"?e:e+""}function e2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yw(){return yw=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},yw.apply(null,arguments)}var t2e=(t,e)=>{var n;if(E.isValidElement(t))n=E.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Hn(e.x1)||!Hn(e.y1)||!Hn(e.x2)||!Hn(e.y2))return null;n=E.createElement("line",yw({},e,{className:"recharts-reference-line-line"}))}return n},n2e=(t,e,n,r,i,a)=>{var{x:s,width:o}=a,c=i.y.apply(t,{position:n});if(Za(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:s+o,y:c},{x:s,y:c}];return r==="left"?u.reverse():u},r2e=(t,e,n,r,i,a)=>{var{y:s,height:o}=a,c=i.x.apply(t,{position:n});if(Za(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:s+o},{x:c,y:s}];return r==="top"?u.reverse():u},i2e=(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},a2e=(t,e,n,r,i,a)=>{var{x:s,y:o,segment:c,ifOverflow:u}=a,d=co(s),f=co(o);return f?n2e(o,u,n,i,t,e):d?r2e(s,u,n,r,t,e):c!=null&&c.length===2?i2e(c,u,n,t):null};function s2e(t){var e=rr();return E.useEffect(()=>(e(qEe(t)),()=>{e(KEe(t))})),null}function o2e(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,s=yi(),o=ZEe(),c=Ct(k=>Sl(k,e)),u=Ct(k=>Ml(k,n)),d=Ct(k=>ld(k,"xAxis",e,s)),f=Ct(k=>ld(k,"yAxis",n,s)),g=Eb();if(!o||!g||c==null||u==null||d==null||f==null)return null;var m=$Ee({x:d,y:f}),b=a2e(m,g,t.position,c.orientation,u.orientation,t);if(!b)return null;var[{x:y,y:v},{x,y:M}]=b,S=a==="hidden"?"url(#".concat(o,")"):void 0,A=u6(u6({clipPath:S},na(t)),{},{x1:y,y1:v,x2:x,y2:M}),T=HEe({x1:y,y1:v,x2:x,y2:M});return E.createElement(ma,{zIndex:t.zIndex},E.createElement(wr,{className:Mn("recharts-reference-line",i)},t2e(r,A),E.createElement(OX,yw({},T,{lowerWidth:T.width,upperWidth:T.width}),E.createElement(IX,{label:t.label}),t.children)))}var l2e={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Rr.line};function Ox(t){var e=Sr(t,l2e);return E.createElement(E.Fragment,null,E.createElement(s2e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),E.createElement(o2e,e))}Ox.displayName="ReferenceLine";function oY(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 c2e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return GEe(r,n)}function u2e(t,e,n){var r=n==="width",{x:i,y:a,width:s,height:o}=t;return e===1?{start:r?i:a,end:r?i+s:a+o}:{start:r?i+s:a+o,end:r?i:a}}function vw(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 d2e(t,e){return oY(t,e+1)}function h2e(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:o}=e,c=0,u=1,d=s,f=function(){var b=r?.[c];if(b===void 0)return{v:oY(r,u)};var y=c,v,x=()=>(v===void 0&&(v=n(b,y)),v),M=b.coordinate,S=c===0||vw(t,M,x,d,o);S||(c=0,d=s,u+=1),S&&(d=M+t*(x()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}function d6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ua(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d6(Object(n),!0).forEach(function(r){f2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function f2e(t,e,n){return(e=p2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p2e(t){var e=m2e(t,"string");return typeof e=="symbol"?e:e+""}function m2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function g2e(t,e,n,r,i){for(var a=(r||[]).slice(),s=a.length,{start:o}=e,{end:c}=e,u=function(g){var m=a[g],b,y=()=>(b===void 0&&(b=n(m,g)),b);if(g===s-1){var v=t*(m.coordinate+t*y()/2-c);a[g]=m=ua(ua({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else a[g]=m=ua(ua({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=vw(t,m.tickCoord,y,o,c);x&&(c=m.tickCoord-t*(y()/2+i),a[g]=ua(ua({},m),{},{isShow:!0}))}},d=s-1;d>=0;d--)u(d);return a}function x2e(t,e,n,r,i,a){var s=(r||[]).slice(),o=s.length,{start:c,end:u}=e;if(a){var d=r[o-1],f=n(d,o-1),g=t*(d.coordinate+t*f/2-u);if(s[o-1]=d=ua(ua({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=vw(t,d.tickCoord,()=>f,c,u);m&&(u=d.tickCoord-t*(f/2+i),s[o-1]=ua(ua({},d),{},{isShow:!0}))}}for(var b=a?o-1:o,y=function(M){var S=s[M],A,T=()=>(A===void 0&&(A=n(S,M)),A);if(M===0){var k=t*(S.coordinate-t*T()/2-c);s[M]=S=ua(ua({},S),{},{tickCoord:k<0?S.coordinate-k*t:S.coordinate})}else s[M]=S=ua(ua({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var N=vw(t,S.tickCoord,T,c,u);N&&(c=S.tickCoord+t*(T()/2+i),s[M]=ua(ua({},S),{},{isShow:!0}))}},v=0;v<b;v++)y(v);return s}function Gj(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:s,orientation:o,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Pt(c)||Xm.isSsr){var g;return(g=d2e(i,Pt(c)?c:0))!==null&&g!==void 0?g:[]}var m=[],b=o==="top"||o==="bottom"?"width":"height",y=d&&b==="width"?qx(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(S,A)=>{var T=typeof u=="function"?u(S.value,A):S.value;return b==="width"?c2e(qx(T,{fontSize:e,letterSpacing:n}),y,f):qx(T,{fontSize:e,letterSpacing:n})[b]},x=i.length>=2?Li(i[1].coordinate-i[0].coordinate):1,M=u2e(a,x,b);return c==="equidistantPreserveStart"?h2e(x,M,v,i,s):(c==="preserveStart"||c==="preserveStartEnd"?m=x2e(x,M,v,i,s,c==="preserveStartEnd"):m=g2e(x,M,v,i,s),m.filter(S=>S.isShow))}var b2e=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>s&&(s=f.width)}});var o=n?n.getBoundingClientRect().width:0,c=i+a,u=s+c+o+(n?r:0);return Math.round(u)}return 0},y2e=["axisLine","width","height","className","hide","ticks","axisType"];function v2e(t,e){if(t==null)return{};var n,r,i=_2e(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 _2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Yh(){return Yh=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},Yh.apply(null,arguments)}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 Xr(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){w2e(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 w2e(t,e,n){return(e=S2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function S2e(t){var e=M2e(t,"string");return typeof e=="symbol"?e:e+""}function M2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var _c={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:Rr.axis};function E2e(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:s,axisLine:o,otherSvgProps:c}=t;if(!o)return null;var u=Xr(Xr(Xr({},c),Ca(o)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!s||a==="bottom"&&s);u=Xr(Xr({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!s||a==="right"&&s);u=Xr(Xr({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return E.createElement("line",Yh({},u,{className:Mn("recharts-cartesian-axis-line",Wh(o,"className"))}))}function A2e(t,e,n,r,i,a,s,o,c){var u,d,f,g,m,b,y=o?-1:1,v=t.tickSize||s,x=Pt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!o*i,f=g-y*v,b=f-y*c,m=x;break;case"left":f=g=t.coordinate,d=e+ +!o*r,u=d-y*v,m=u-y*c,b=x;break;case"right":f=g=t.coordinate,d=e+ +o*r,u=d+y*v,m=u+y*c,b=x;break;default:u=d=t.coordinate,g=n+ +o*i,f=g+y*v,b=f+y*c,m=x;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:m,y:b}}}function T2e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function C2e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function N2e(t){var{option:e,tickProps:n,value:r}=t,i,a=Mn(n.className,"recharts-cartesian-axis-tick-value");if(E.isValidElement(e))i=E.cloneElement(e,Xr(Xr({},n),{},{className:a}));else if(typeof e=="function")i=e(Xr(Xr({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=Mn(s,e?.className)),i=E.createElement(CM,Yh({},n,{className:s}),r)}return i}var k2e=E.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:s,unit:o,padding:c,tickTextProps:u,orientation:d,mirror:f,x:g,y:m,width:b,height:y,tickSize:v,tickMargin:x,fontSize:M,letterSpacing:S,getTicksConfig:A,events:T,axisType:k}=t,N=Gj(Xr(Xr({},A),{},{ticks:n}),M,S),I=T2e(d,f),C=C2e(d,f),D=Ca(A),F=Gh(r),O={};typeof i=="object"&&(O=i);var q=Xr(Xr({},D),{},{fill:"none"},O),R=N.map(G=>Xr({entry:G},A2e(G,g,m,b,y,d,v,f,x))),W=R.map(G=>{var{entry:ee,line:Z}=G;return E.createElement(wr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(ee.value,"-").concat(ee.coordinate,"-").concat(ee.tickCoord)},i&&E.createElement("line",Yh({},q,Z,{className:Mn("recharts-cartesian-axis-tick-line",Wh(i,"className"))})))}),K=R.map((G,ee)=>{var{entry:Z,tick:Q}=G,U=Xr(Xr(Xr(Xr({textAnchor:I,verticalAnchor:C},D),{},{stroke:"none",fill:a},F),Q),{},{index:ee,payload:Z,visibleTicksCount:N.length,tickFormatter:s,padding:c},u);return E.createElement(wr,Yh({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},vb(T,Z,ee)),r&&E.createElement(N2e,{option:r,tickProps:U,value:"".concat(typeof s=="function"?s(Z.value,ee):Z.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&E.createElement(ma,{zIndex:Rr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},K)),W.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},W))}),P2e=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:o,axisType:c}=t,u=v2e(t,y2e),[d,f]=E.useState(""),[g,m]=E.useState(""),b=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return b2e({ticks:b.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=E.useCallback(v=>{if(v){var x=v.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=x;var M=x[0];if(M){var S=window.getComputedStyle(M),A=S.fontSize,T=S.letterSpacing;(A!==d||T!==g)&&(f(A),m(T))}}},[d,g]);return s||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(ma,{zIndex:t.zIndex},E.createElement(wr,{className:Mn("recharts-cartesian-axis",a)},E.createElement(E2e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ca(t)}),E.createElement(k2e,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),E.createElement(OX,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(IX,{label:t.label,labelRef:t.labelRef}),t.children)))}),Wj=E.forwardRef((t,e)=>{var n=Sr(t,_c);return E.createElement(P2e,Yh({},n,{ref:e}))});Wj.displayName="CartesianAxis";var R2e=["x1","y1","x2","y2","key"],D2e=["offset"],j2e=["xAxisId","yAxisId"],O2e=["xAxisId","yAxisId"];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 ha(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){L2e(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 L2e(t,e,n){return(e=I2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I2e(t){var e=F2e(t,"string");return typeof e=="symbol"?e:e+""}function F2e(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 gh(){return gh=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},gh.apply(null,arguments)}function _w(t,e){if(t==null)return{};var n,r,i=U2e(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 U2e(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 z2e=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:s,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function lY(t){var{option:e,lineItemProps:n}=t,r;if(E.isValidElement(e))r=E.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:s,x2:o,y2:c,key:u}=n,d=_w(n,R2e),f=(i=Ca(d))!==null&&i!==void 0?i:{},{offset:g}=f,m=_w(f,D2e);r=E.createElement("line",gh({},m,{x1:a,y1:s,x2:o,y2:c,fill:"none",key:u}))}return r}function B2e(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=_w(t,j2e),c=i.map((u,d)=>{var f=ha(ha({},o),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return E.createElement(lY,{key:"line-".concat(d),option:r,lineItemProps:f})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function H2e(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=_w(t,O2e),c=i.map((u,d)=>{var f=ha(ha({},o),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return E.createElement(lY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function $2e(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:s,horizontalPoints:o,horizontal:c=!0}=t;if(!c||!e||!e.length||o==null)return null;var u=o.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],b=m?i+s-f:u[g+1]-f;if(b<=0)return null;var y=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:b,width:a,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function V2e(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:s,height:o,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],b=m?i+s-f:u[g+1]-f;if(b<=0)return null;var y=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:b,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var G2e=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return GW(Gj(ha(ha(ha({},_c),n),{},{ticks:WW(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},W2e=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return GW(Gj(ha(ha(ha({},_c),n),{},{ticks:WW(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},q2e={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Rr.grid};function ww(t){var e=bD(),n=yD(),r=tq(),i=ha(ha({},Sr(t,q2e)),{},{x:Pt(t.x)?t.x:r.left,y:Pt(t.y)?t.y:r.top,width:Pt(t.width)?t.width:r.width,height:Pt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:s,x:o,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:m}=i,b=yi(),y=Ct(C=>t8(C,"xAxis",a,b)),v=Ct(C=>t8(C,"yAxis",s,b));if(!hl(u)||!hl(d)||!Pt(o)||!Pt(c))return null;var x=i.verticalCoordinatesGenerator||G2e,M=i.horizontalCoordinatesGenerator||W2e,{horizontalPoints:S,verticalPoints:A}=i;if((!S||!S.length)&&typeof M=="function"){var T=g&&g.length,k=M({yAxis:v?ha(ha({},v),{},{ticks:T?g:v.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);G1(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(S=k)}if((!A||!A.length)&&typeof x=="function"){var N=m&&m.length,I=x({xAxis:y?ha(ha({},y),{},{ticks:N?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);G1(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(A=I)}return E.createElement(ma,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(z2e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement($2e,gh({},i,{horizontalPoints:S})),E.createElement(V2e,gh({},i,{verticalPoints:A})),E.createElement(B2e,gh({},i,{offset:r,horizontalPoints:S,xAxis:y,yAxis:v})),E.createElement(H2e,gh({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:v}))))}ww.displayName="CartesianGrid";var cY=(t,e,n,r)=>ml(t,"xAxis",e,r),uY=(t,e,n,r)=>pl(t,"xAxis",e,r),dY=(t,e,n,r)=>ml(t,"yAxis",n,r),hY=(t,e,n,r)=>pl(t,"yAxis",n,r),K2e=Ge([xn,cY,dY,uY,hY],(t,e,n,r,i)=>wl(t,"xAxis")?sd(e,r,!1):sd(n,i,!1)),X2e=(t,e,n,r,i)=>i;function Y2e(t){return t.type==="line"}var Z2e=Ge([Ob,X2e],(t,e)=>t.filter(Y2e).find(n=>n.id===e)),Q2e=Ge([xn,cY,dY,uY,hY,Z2e,K2e,Pb],(t,e,n,r,i,a,s,o)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=o;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:g}=a,m;if(g!=null&&g.length>0?m=g:m=c?.slice(u,d+1),m!=null)return bAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:s,displayedData:m})}});function fY(t){var e=Gh(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,s=Number(i),o=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(o)||o<0)&&(o=r),{r:s,strokeWidth:o}}return{r:n,strokeWidth:r}}var J2e=["id"],eAe=["type","layout","connectNulls","needClip","shape"],tAe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function H0(){return H0=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},H0.apply(null,arguments)}function p6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p6(Object(n),!0).forEach(function(r){nAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nAe(t,e,n){return(e=rAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rAe(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)}function qj(t,e){if(t==null)return{};var n,r,i=aAe(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 aAe(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 sAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:vd(n,e),payload:t}]},oAe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:vd(s,e),hide:o,type:u,color:r,unit:c}};return E.createElement(RM,{tooltipEntrySettings:d})}),pY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function lAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var cAe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return pY(e,t);for(var i=Math.floor(t/r),a=t%r,s=e-t,o=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){o=[...n.slice(0,c),a-u];break}var d=o.length%2===0?[0,s]:[s];return[...lAe(n,i),...o,...d].map(f=>"".concat(f,"px")).join(", ")};function uAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:s}=r,{id:o}=r,c=qj(r,J2e),u=Ca(c);return E.createElement(XX,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:s,clipPathId:e})}function dAe(t){var{showLabels:e,children:n,points:r}=t,i=E.useMemo(()=>r?.map(a=>{var s,o,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return tl(tl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return E.createElement(Dj,{value:e?i:void 0},n)}function m6(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:s,layout:o,connectNulls:c,needClip:u,shape:d}=a,f=qj(a,eAe),g=tl(tl({},na(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:s,layout:o,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return E.createElement(E.Fragment,null,r?.length>1&&E.createElement(Fj,H0({shapeType:"curve",option:d},g,{pathRef:n})),E.createElement(uAe,{points:r,clipPathId:e,props:a}))}function hAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function fAe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:s,strokeDasharray:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:m,height:b,onAnimationEnd:y,onAnimationStart:v}=n,x=i.current,M=Zm(s,"recharts-line-"),S=E.useRef(M),[A,T]=E.useState(!1),k=!A,N=E.useCallback(()=>{typeof y=="function"&&y(),T(!1)},[y]),I=E.useCallback(()=>{typeof v=="function"&&v(),T(!0)},[v]),C=hAe(r.current),D=E.useRef(0);S.current!==M&&(D.current=a.current,S.current=M);var F=D.current;return E.createElement(dAe,{points:s,showLabels:k},n.children,E.createElement(Ym,{animationId:M,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:I,key:M},O=>{var q=jn(F,C+F,O),R=Math.min(q,C),W;if(c)if(o){var K="".concat(o).split(/[,\s]+/gim).map(Z=>parseFloat(Z));W=cAe(R,C,K)}else W=pY(C,R);else W=o==null?void 0:String(o);if(O>0&&C>0&&(i.current=s,a.current=Math.max(a.current,R)),x){var G=x.length/s.length,ee=O===1?s:s.map((Z,Q)=>{var U=Math.floor(Q*G);if(x[U]){var $=x[U];return tl(tl({},Z),{},{x:jn($.x,Z.x,O),y:jn($.y,Z.y,O)})}return g?tl(tl({},Z),{},{x:jn(m*2,Z.x,O),y:jn(b/2,Z.y,O)}):tl(tl({},Z),{},{x:Z.x,y:Z.y})});return i.current=ee,E.createElement(m6,{props:n,points:ee,clipPathId:e,pathRef:r,strokeDasharray:W})}return E.createElement(m6,{props:n,points:s,clipPathId:e,pathRef:r,strokeDasharray:W})}),E.createElement(NM,{label:n.label}))}function pAe(t){var{clipPathId:e,props:n}=t,r=E.useRef(null),i=E.useRef(0),a=E.useRef(null);return E.createElement(fAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var mAe=(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:Bn(t.payload,e)}};class gAe extends E.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:s,top:o,left:c,width:u,height:d,id:f,needClip:g,zIndex:m}=this.props;if(e)return null;var b=Mn("recharts-line",i),y=f,{r:v,strokeWidth:x}=fY(n),M=Ij(n),S=v*2+x,A=g?"url(#clipPath-".concat(M?"":"dots-").concat(y,")"):void 0;return E.createElement(ma,{zIndex:m},E.createElement(wr,{className:b},g&&E.createElement("defs",null,E.createElement(Vj,{clipPathId:y,xAxisId:a,yAxisId:s}),!M&&E.createElement("clipPath",{id:"clipPath-dots-".concat(y)},E.createElement("rect",{x:c-S/2,y:o-S/2,width:u+S,height:d+S}))),E.createElement(QX,{xAxisId:a,yAxisId:s,data:r,dataPointFormatter:mAe,errorBarOffset:0},E.createElement(pAe,{props:this.props,clipPathId:y}))),E.createElement(R3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var mY={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:Rr.line,type:"linear"};function xAe(t){var e=Sr(t,mY),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:m,yAxisId:b,id:y}=e,v=qj(e,tAe),{needClip:x}=LM(m,b),M=OM(),S=df(),A=yi(),T=Ct(D=>Q2e(D,m,b,A,y));if(S!=="horizontal"&&S!=="vertical"||T==null||M==null)return null;var{height:k,width:N,x:I,y:C}=M;return E.createElement(gAe,H0({},v,{id:y,connectNulls:o,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:m,yAxisId:b,points:T,layout:S,height:k,width:N,left:I,top:C,needClip:x}))}function bAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:s,bandSize:o,displayedData:c}=t;return c.map((u,d)=>{var f=Bn(u,s);if(e==="horizontal"){var g=V1({axis:n,ticks:i,bandSize:o,entry:u,index:d}),m=dr(f)?null:r.scale(f);return{x:g,y:m,value:f,payload:u}}var b=dr(f)?null:n.scale(f),y=V1({axis:r,ticks:a,bandSize:o,entry:u,index:d});return b==null||y==null?null:{x:b,y,value:f,payload:u}}).filter(Boolean)}function yAe(t){var e=Sr(t,mY),n=yi();return E.createElement(DM,{id:e.id,type:"line"},r=>E.createElement(E.Fragment,null,E.createElement(Hj,{legendPayload:sAe(e)}),E.createElement(oAe,{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}),E.createElement($j,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),E.createElement(xAe,H0({},e,{id:r}))))}var gY=E.memo(yAe,Vb);gY.displayName="Line";var xY=(t,e,n,r)=>ml(t,"xAxis",e,r),bY=(t,e,n,r)=>pl(t,"xAxis",e,r),yY=(t,e,n,r)=>ml(t,"yAxis",n,r),vY=(t,e,n,r)=>pl(t,"yAxis",n,r),vAe=Ge([xn,xY,yY,bY,vY],(t,e,n,r,i)=>wl(t,"xAxis")?sd(e,r,!1):sd(n,i,!1)),_Ae=(t,e,n,r,i)=>i,_Y=Ge([Ob,_Ae],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),wAe=(t,e,n,r,i)=>{var a,s=_Y(t,e,n,r,i);if(s!=null){var o=xn(t),c=wl(o,"xAxis"),u;if(c?u=z0(t,"yAxis",n,r):u=z0(t,"xAxis",e,r),u!=null){var{stackId:d}=s,f=yM(s);if(!(d==null||f==null)){var g=(a=u[d])===null||a===void 0?void 0:a.stackedData;return g?.find(m=>m.key===f)}}}},SAe=Ge([xn,xY,yY,bY,vY,wAe,Pb,vAe,_Y,Zbe],(t,e,n,r,i,a,s,o,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=s;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=c,b;if(m&&m.length>0?b=m:b=d?.slice(f,g+1),b!=null)return HAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:b,chartBaseValue:u,bandSize:o})}}),MAe=["id"],EAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Ch(){return Ch=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},Ch.apply(null,arguments)}function wY(t,e){if(t==null)return{};var n,r,i=AAe(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 AAe(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 g6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g6(Object(n),!0).forEach(function(r){TAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function TAe(t,e,n){return(e=CAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CAe(t){var e=NAe(t,"string");return typeof e=="symbol"?e:e+""}function NAe(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 Sw(t,e){return t&&t!=="none"?t:e}var kAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:Sw(r,i),value:vd(n,e),payload:t}]},PAe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:vd(s,e),hide:o,type:u,color:Sw(r,a),unit:c}};return E.createElement(RM,{tooltipEntrySettings:d})});function RAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,o=Ca(r);return E.createElement(XX,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:o,needClip:i,clipPathId:e})}function DAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var s,o,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Wp(Wp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return E.createElement(Dj,{value:e?i:void 0},n)}function x6(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:s,type:o,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,g=wY(a,MAe),m=Ca(g),b=na(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(wr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(em,Ch({},b,{id:f,points:e,connectNulls:u,type:o,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),c!=="none"&&E.createElement(em,Ch({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&E.createElement(em,Ch({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:u,fill:"none",points:n}))),E.createElement(RAe,{points:e,props:g,clipPathId:i}))}function jAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!Hn(a)||!Hn(s))return null;var o=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.x||0));return Pt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Pt(c)?E.createElement("rect",{x:0,y:a<s?a:a-o,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function OAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!Hn(a)||!Hn(s))return null;var o=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.y||0));return Pt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Pt(c)?E.createElement("rect",{x:a<s?a:a-o,y:0,width:o,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function LAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?E.createElement(jAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):E.createElement(OAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function IAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:s,baseLine:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:m}=r,b=E.useMemo(()=>({points:s,baseLine:o}),[s,o]),y=Zm(b,"recharts-area-"),v=mme(),[x,M]=E.useState(!1),S=!x,A=E.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),T=E.useCallback(()=>{typeof g=="function"&&g(),M(!0)},[g]);if(v==null)return null;var k=i.current,N=a.current;return E.createElement(DAe,{showLabels:S,points:s},r.children,E.createElement(Ym,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:T,key:y},I=>{if(k){var C=k.length/s.length,D=I===1?s:s.map((O,q)=>{var R=Math.floor(q*C);if(k[R]){var W=k[R];return Wp(Wp({},O),{},{x:jn(W.x,O.x,I),y:jn(W.y,O.y,I)})}return O}),F;return Pt(o)?F=jn(N,o,I):dr(o)||Za(o)?F=jn(N,0,I):F=o.map((O,q)=>{var R=Math.floor(q*C);if(Array.isArray(N)&&N[R]){var W=N[R];return Wp(Wp({},O),{},{x:jn(W.x,O.x,I),y:jn(W.y,O.y,I)})}return O}),I>0&&(i.current=D,a.current=F),E.createElement(x6,{points:D,baseLine:F,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=s,a.current=o),E.createElement(wr,null,c&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(LAe,{alpha:I,points:s,baseLine:o,layout:v,strokeWidth:r.strokeWidth}))),E.createElement(wr,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(x6,{points:s,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(NM,{label:r.label}))}function FAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),a=E.useRef();return E.createElement(IAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class UAe extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:s,needClip:o,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:m,zIndex:b}=this.props;if(e)return null;var y=Mn("recharts-area",i),v=g,{r:x,strokeWidth:M}=fY(n),S=Ij(n),A=x*2+M,T=o?"url(#clipPath-".concat(S?"":"dots-").concat(v,")"):void 0;return E.createElement(ma,{zIndex:b},E.createElement(wr,{className:y},o&&E.createElement("defs",null,E.createElement(Vj,{clipPathId:v,xAxisId:c,yAxisId:u}),!S&&E.createElement("clipPath",{id:"clipPath-dots-".concat(v)},E.createElement("rect",{x:s-A/2,y:a-A/2,width:d+A,height:f+A}))),E.createElement(FAe,{needClip:o,clipPathId:v,props:this.props})),E.createElement(R3,{points:r,mainColor:Sw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&E.createElement(R3,{points:m,mainColor:Sw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var SY={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:Rr.area};function zAe(t){var e,n=Sr(t,SY),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:m,stroke:b,xAxisId:y,yAxisId:v}=n,x=wY(n,EAe),M=df(),S=bX(),{needClip:A}=LM(y,v),T=yi(),{points:k,isRange:N,baseLine:I}=(e=Ct(R=>SAe(R,y,v,T,t.id)))!==null&&e!==void 0?e:{},C=OM();if(M!=="horizontal"&&M!=="vertical"||C==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:D,width:F,x:O,y:q}=C;return!k||!k.length?null:E.createElement(UAe,Ch({},x,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,baseLine:I,connectNulls:o,dot:c,fill:u,fillOpacity:d,height:D,hide:f,layout:M,isAnimationActive:g==="auto"?!Xm.isSsr:g,isRange:N,legendType:m,needClip:A,points:k,stroke:b,width:F,left:O,top:q,xAxisId:y,yAxisId:v}))}var BAe=(t,e,n,r,i)=>{var a=n??e;if(Pt(a))return a;var s=t==="horizontal"?i:r,o=s.scale.domain();if(s.type==="number"){var c=Math.max(o[0],o[1]),u=Math.min(o[0],o[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(o[0],o[1]),0)}return a==="dataMin"?o[0]:a==="dataMax"?o[1]:o[0]};function HAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:o,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:m}=t,b=i&&i.length,y=BAe(a,s,n,o,c),v=a==="horizontal",x=!1,M=u.map((A,T)=>{var k;b?k=i[d+T]:(k=Bn(A,r),Array.isArray(k)?x=!0:k=[y,k]);var N=k[1]==null||b&&!e&&Bn(A,r)==null;return v?{x:V1({axis:o,ticks:f,bandSize:m,entry:A,index:T}),y:N?null:c.scale(k[1]),value:k,payload:A}:{x:N?null:o.scale(k[1]),y:V1({axis:c,ticks:g,bandSize:m,entry:A,index:T}),value:k,payload:A}}),S;return b||x?S=M.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return v?{x:A.x,y:T!=null&&A.y!=null?c.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):S=v?c.scale(y):o.scale(y),{points:M,baseLine:S,isRange:x}}function $Ae(t){var e=Sr(t,SY),n=yi();return E.createElement(DM,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(Hj,{legendPayload:kAe(e)}),E.createElement(PAe,{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}),E.createElement($j,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:qW(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(zAe,Ch({},e,{id:r}))))}var MY=E.memo($Ae,Vb);MY.displayName="Area";var VAe=["domain","range"],GAe=["domain","range"];function b6(t,e){if(t==null)return{};var n,r,i=WAe(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 WAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function y6(t,e){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 EY(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=b6(t,VAe),{domain:a,range:s}=e,o=b6(e,GAe);return!y6(n,a)||!y6(r,s)?!1:Vb(i,o)}var qAe=["dangerouslySetInnerHTML","ticks"],KAe=["id"];function j3(){return j3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},j3.apply(null,arguments)}function v6(t,e){if(t==null)return{};var n,r,i=XAe(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 XAe(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 YAe(t){var e=rr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(VSe(t)):n.current!==t&&e(GSe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(WSe(n.current)),n.current=null)},[e]),null}var ZAe=t=>{var{xAxisId:e,className:n}=t,r=Ct(gD),i=yi(),a="xAxis",s=Ct(v=>ld(v,a,e,i)),o=Ct(v=>YK(v,a,e,i)),c=Ct(v=>WK(v,e)),u=Ct(v=>Kye(v,e)),d=Ct(v=>TK(v,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,m=v6(t,qAe),{id:b}=d,y=v6(d,KAe);return E.createElement(Wj,j3({},m,y,{scale:s,x:u.x,y:u.y,width:c.width,height:c.height,className:Mn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},QAe={allowDataOverflow:Pi.allowDataOverflow,allowDecimals:Pi.allowDecimals,allowDuplicatedCategory:Pi.allowDuplicatedCategory,angle:Pi.angle,axisLine:_c.axisLine,height:Pi.height,hide:!1,includeHidden:Pi.includeHidden,interval:Pi.interval,minTickGap:Pi.minTickGap,mirror:Pi.mirror,orientation:Pi.orientation,padding:Pi.padding,reversed:Pi.reversed,scale:Pi.scale,tick:Pi.tick,tickCount:Pi.tickCount,tickLine:_c.tickLine,tickSize:_c.tickSize,type:Pi.type,xAxisId:0},JAe=t=>{var e=Sr(t,QAe);return E.createElement(E.Fragment,null,E.createElement(YAe,{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}),E.createElement(ZAe,e))},Mw=E.memo(JAe,EY);Mw.displayName="XAxis";var eTe=["dangerouslySetInnerHTML","ticks"],tTe=["id"];function O3(){return O3=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},O3.apply(null,arguments)}function _6(t,e){if(t==null)return{};var n,r,i=nTe(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 nTe(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 rTe(t){var e=rr(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(qSe(t)):n.current!==t&&e(KSe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(XSe(n.current)),n.current=null)},[e]),null}var iTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=E.useRef(null),s=E.useRef(null),o=Ct(gD),c=yi(),u=rr(),d="yAxis",f=Ct(T=>ld(T,d,e,c)),g=Ct(T=>qK(T,e)),m=Ct(T=>Yye(T,e)),b=Ct(T=>YK(T,d,e,c)),y=Ct(T=>CK(T,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||Rj(i)||E.isValidElement(i)||y==null)){var T=a.current;if(T){var k=T.getCalculatedWidth();Math.round(g.width)!==Math.round(k)&&u(YSe({id:e,width:k}))}}},[b,g,u,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:v,ticks:x}=t,M=_6(t,eTe),{id:S}=y,A=_6(y,tTe);return E.createElement(Wj,O3({},M,A,{ref:a,labelRef:s,scale:f,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:Mn("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:b,axisType:d}))},aTe={allowDataOverflow:Ri.allowDataOverflow,allowDecimals:Ri.allowDecimals,allowDuplicatedCategory:Ri.allowDuplicatedCategory,angle:Ri.angle,axisLine:_c.axisLine,hide:!1,includeHidden:Ri.includeHidden,interval:Ri.interval,minTickGap:Ri.minTickGap,mirror:Ri.mirror,orientation:Ri.orientation,padding:Ri.padding,reversed:Ri.reversed,scale:Ri.scale,tick:Ri.tick,tickCount:Ri.tickCount,tickLine:_c.tickLine,tickSize:_c.tickSize,type:Ri.type,width:Ri.width,yAxisId:0},sTe=t=>{var e=Sr(t,aTe);return E.createElement(E.Fragment,null,E.createElement(rTe,{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}),E.createElement(iTe,e))},Ew=E.memo(sTe,EY);Ew.displayName="YAxis";var oTe=(t,e)=>e,Kj=Ge([oTe,xn,EK,_i,hX,Bc,d_e,bi],b_e),Xj=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)}},AY=uo("mouseClick"),TY=Sb();TY.startListening({actionCreator:AY,effect:(t,e)=>{var n=t.payload,r=Kj(e.getState(),Xj(n));r?.activeIndex!=null&&e.dispatch(uve({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var L3=uo("mouseMove"),CY=Sb(),jv=null;CY.startListening({actionCreator:L3,effect:(t,e)=>{var n=t.payload;jv!==null&&cancelAnimationFrame(jv);var r=Xj(n);jv=requestAnimationFrame(()=>{var i=e.getState(),a=_j(i,i.tooltip.settings.shared);if(a==="axis"){var s=Kj(i,r);s?.activeIndex!=null?e.dispatch(iX({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(rX())}jv=null})}});var w6={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},NY=Qa({name:"rootProps",initialState:w6,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:w6.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}}}),lTe=NY.reducer,{updateOptions:cTe}=NY.actions,kY=Qa({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:uTe}=kY.actions,dTe=kY.reducer,PY=uo("keyDown"),RY=uo("focus"),Yj=Sb();Yj.startListening({actionCreator:PY,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 s=wj(i,ag(n),Ib(n),Bb(n)),o=s==null?-1:Number(s);if(!(!Number.isFinite(o)||o<0)){var c=Bc(n);if(a==="Enter"){var u=hw(n,"axis","hover",String(i.index));e.dispatch(A3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=eve(n),f=d==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,m=o+g*f;if(!(c==null||m>=c.length||m<0)){var b=hw(n,"axis","hover",String(m));e.dispatch(A3({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:b}))}}}}}});Yj.startListening({actionCreator:RY,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",s=hw(n,"axis","hover",String(a));e.dispatch(A3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var $s=uo("externalEvent"),DY=Sb(),hC=new Map;DY.startListening({actionCreator:$s,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=hC.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var o=e.getState(),c={activeCoordinate:Yve(o),activeDataKey:Tj(o),activeIndex:cd(o),activeLabel:mX(o),activeTooltipIndex:cd(o),isTooltipActive:Zve(o)};n(c,r)}finally{hC.delete(i)}});hC.set(i,s)}}});var hTe=Ge([ig],t=>t.tooltipItemPayloads),fTe=Ge([hTe,Ub,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var s=e(a,n);return s}}}),jY=uo("touchMove"),OY=Sb();OY.startListening({actionCreator:jY,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=_j(r,r.tooltip.settings.shared);if(i==="axis"){var a=Kj(r,Xj({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(iX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var s,o=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(o.clientX,o.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(XW),d=(s=c.getAttribute(YW))!==null&&s!==void 0?s:void 0,f=fTe(e.getState(),u,d);e.dispatch(nX({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var pTe=gW({brush:FEe,cartesianAxis:ZSe,chartData:X_e,errorBars:gMe,graphicalItems:iSe,layout:wpe,legend:kme,options:V_e,polarAxis:ywe,polarOptions:dTe,referenceElements:XEe,rootProps:lTe,tooltip:dve,zIndex:R_e}),mTe=function(e){return qfe({reducer:pTe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([TY.middleware,CY.middleware,Yj.middleware,DY.middleware,OY.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(PW({type:"raf"}))},devTools:Xm.devToolsEnabled})};function LY(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=yi(),a=E.useRef(null);if(i)return n;a.current==null&&(a.current=mTe(e));var s=oD;return E.createElement(zMe,{context:s,store:a.current},n)}function gTe(t){var{layout:e,margin:n}=t,r=rr(),i=yi();return E.useEffect(()=>{i||(r(ype(e)),r(bpe(n)))},[r,i,e,n]),null}var IY=E.memo(gTe,Vb);function FY(t){var e=rr();return E.useEffect(()=>{e(cTe(t))},[e,t]),null}function S6(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=WX("".concat(r).concat(e)),a=rr();return E.useLayoutEffect(()=>(a(k_e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(P_e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function M6(t){var{children:e,isPanorama:n}=t,r=Ct(v_e);if(!r||r.length===0)return e;var i=r.filter(s=>s<0),a=r.filter(s=>s>0);return E.createElement(E.Fragment,null,i.map(s=>E.createElement(S6,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>E.createElement(S6,{key:s,zIndex:s,isPanorama:n})))}var xTe=["children"];function bTe(t,e){if(t==null)return{};var n,r,i=yTe(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 yTe(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 Aw(){return Aw=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},Aw.apply(null,arguments)}var vTe={width:"100%",height:"100%",display:"block"},_Te=E.forwardRef((t,e)=>{var n=bD(),r=yD(),i=hq();if(!hl(n)||!hl(r))return null;var{children:a,otherAttributes:s,title:o,desc:c}=t,u,d;return s!=null&&(typeof s.tabIndex=="number"?u=s.tabIndex:u=i?0:void 0,typeof s.role=="string"?d=s.role:d=i?"application":void 0),E.createElement(ZR,Aw({},s,{title:o,desc:c,role:d,tabIndex:u,width:n,height:r,style:vTe,ref:e}),a)}),wTe=t=>{var{children:e}=t,n=Ct(sM);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return E.createElement(ZR,{width:r,height:i,x:s,y:a},e)},E6=E.forwardRef((t,e)=>{var{children:n}=t,r=bTe(t,xTe),i=yi();return i?E.createElement(wTe,null,E.createElement(M6,{isPanorama:!0},n)):E.createElement(_Te,Aw({ref:e},r),E.createElement(M6,{isPanorama:!1},n))});function STe(){var t=rr(),[e,n]=E.useState(null),r=Ct(Upe);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;Hn(a)&&a!==r&&t(_pe(a))}},[e,t,r]),n}function A6(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 MTe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A6(Object(n),!0).forEach(function(r){ETe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ETe(t,e,n){return(e=ATe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ATe(t){var e=TTe(t,"string");return typeof e=="symbol"?e:e+""}function TTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Zh(){return Zh=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},Zh.apply(null,arguments)}var CTe=()=>(i1e(),null);function Tw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var NTe=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[a,s]=E.useState({containerWidth:Tw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:Tw((r=t.style)===null||r===void 0?void 0:r.height)}),o=E.useCallback((u,d)=>{s(f=>{var g=Math.round(u),m=Math.round(d);return f.containerWidth===g&&f.containerHeight===m?f:{containerWidth:g,containerHeight:m}})},[]),c=E.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();o(d,f);var g=b=>{var{width:y,height:v}=b[0].contentRect;o(y,v)},m=new ResizeObserver(g);m.observe(u),i.current=m}},[e,o]);return E.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(oM,{width:a.containerWidth,height:a.containerHeight}),E.createElement("div",Zh({ref:c},t)))}),kTe=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=E.useState({containerWidth:Tw(n),containerHeight:Tw(r)}),s=E.useCallback((c,u)=>{a(d=>{var f=Math.round(c),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),o=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();s(u,d)}},[e,s]);return E.createElement(E.Fragment,null,E.createElement(oM,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Zh({ref:o},t)))}),PTe=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(oM,{width:n,height:r}),E.createElement("div",Zh({ref:e},t)))}),RTe=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return Nc(n)||Nc(r)?E.createElement(kTe,Zh({},t,{ref:e})):E.createElement(PTe,Zh({},t,{ref:e}))});function DTe(t){return t===!0?NTe:RTe}var jTe=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:s,onDoubleClick:o,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:m,onTouchMove:b,onTouchStart:y,style:v,width:x,responsive:M,dispatchTouchEvents:S=!0}=t,A=E.useRef(null),T=rr(),[k,N]=E.useState(null),[I,C]=E.useState(null),D=STe(),F=xD(),O=F?.width>0?F.width:x,q=F?.height>0?F.height:i,R=E.useCallback(ie=>{D(ie),typeof e=="function"&&e(ie),N(ie),C(ie),ie!=null&&(A.current=ie)},[D,e,N,C]),W=E.useCallback(ie=>{T(AY(ie)),T($s({handler:a,reactEvent:ie}))},[T,a]),K=E.useCallback(ie=>{T(L3(ie)),T($s({handler:u,reactEvent:ie}))},[T,u]),G=E.useCallback(ie=>{T(rX()),T($s({handler:d,reactEvent:ie}))},[T,d]),ee=E.useCallback(ie=>{T(L3(ie)),T($s({handler:f,reactEvent:ie}))},[T,f]),Z=E.useCallback(()=>{T(RY())},[T]),Q=E.useCallback(ie=>{T(PY(ie.key))},[T]),U=E.useCallback(ie=>{T($s({handler:s,reactEvent:ie}))},[T,s]),$=E.useCallback(ie=>{T($s({handler:o,reactEvent:ie}))},[T,o]),X=E.useCallback(ie=>{T($s({handler:c,reactEvent:ie}))},[T,c]),te=E.useCallback(ie=>{T($s({handler:g,reactEvent:ie}))},[T,g]),fe=E.useCallback(ie=>{T($s({handler:y,reactEvent:ie}))},[T,y]),pe=E.useCallback(ie=>{S&&T(jY(ie)),T($s({handler:b,reactEvent:ie}))},[T,S,b]),be=E.useCallback(ie=>{T($s({handler:m,reactEvent:ie}))},[T,m]),Ne=DTe(M);return E.createElement(SX.Provider,{value:k},E.createElement(PG.Provider,{value:I},E.createElement(Ne,{width:O??v?.width,height:q??v?.height,className:Mn("recharts-wrapper",r),style:MTe({position:"relative",cursor:"default",width:O,height:q},v),onClick:W,onContextMenu:U,onDoubleClick:$,onFocus:Z,onKeyDown:Q,onMouseDown:X,onMouseEnter:K,onMouseLeave:G,onMouseMove:ee,onMouseUp:te,onTouchEnd:be,onTouchMove:pe,onTouchStart:fe,ref:R},E.createElement(CTe,null),n)))}),OTe=["width","height","responsive","children","className","style","compact","title","desc"];function LTe(t,e){if(t==null)return{};var n,r,i=ITe(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 ITe(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 UY=E.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:s,style:o,compact:c,title:u,desc:d}=t,f=LTe(t,OTe),g=Ca(f);return c?E.createElement(E.Fragment,null,E.createElement(oM,{width:n,height:r}),E.createElement(E6,{otherAttributes:g,title:u,desc:d},a)):E.createElement(jTe,{className:s,style:o,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},E.createElement(E6,{otherAttributes:g,title:u,desc:d,ref:e},E.createElement(YEe,null,a)))});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)}var FTe={top:5,right:5,bottom:5,left:5},UTe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:FTe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},Zj=E.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,UTe),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,eventEmitter:void 0};return E.createElement(LY,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},E.createElement(nY,{chartData:u.data}),E.createElement(IY,{layout:i.layout,margin:i.margin}),E.createElement(FY,{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}),E.createElement(UY,I3({},i,{ref:n})))}),zTe=["axis"],BTe=E.forwardRef((t,e)=>E.createElement(Zj,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:zTe,tooltipPayloadSearcher:TM,categoricalChartProps:t,ref:e})),HTe=["axis","item"],$Te=E.forwardRef((t,e)=>E.createElement(Zj,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:HTe,tooltipPayloadSearcher:TM,categoricalChartProps:t,ref:e}));function VTe(t){var e=rr();return E.useEffect(()=>{e(uTe(t))},[e,t]),null}var GTe=["layout"];function F3(){return F3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},F3.apply(null,arguments)}function WTe(t,e){if(t==null)return{};var n,r,i=qTe(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 qTe(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 KTe={top:5,right:5,bottom:5,left:5},zY={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:KTe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},XTe=E.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,zY),{layout:a}=i,s=WTe(i,GTe),{chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return E.createElement(LY,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},E.createElement(nY,{chartData:i.data}),E.createElement(IY,{layout:a,margin:i.margin}),E.createElement(FY,{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}),E.createElement(VTe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),E.createElement(UY,F3({},s,{ref:n})))});function T6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function C6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T6(Object(n),!0).forEach(function(r){YTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YTe(t,e,n){return(e=ZTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ZTe(t){var e=QTe(t,"string");return typeof e=="symbol"?e:e+""}function QTe(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 JTe=["item"],eCe=C6(C6({},zY),{},{layout:"centric",startAngle:0,endAngle:360}),tCe=E.forwardRef((t,e)=>{var n=Sr(t,eCe);return E.createElement(XTe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:JTe,tooltipPayloadSearcher:TM,categoricalChartProps:n,ref:e})}),nCe=["axis"],rCe=E.forwardRef((t,e)=>E.createElement(Zj,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:nCe,tooltipPayloadSearcher:TM,categoricalChartProps:t,ref:e}));const N6=[{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 iCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:s="humidity",thresholds:o}){const{t:c}=Vm(),{theme:u}=xb(),[d,f]=E.useState("24h"),[g,m]=E.useState(s),b=u==="dark";E.useEffect(()=>{if(!t)return;const $=X=>{X.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,e]);const y=N6.find($=>$.value===d)?.hours||24,{data:v,isLoading:x,error:M}=vt({queryKey:["ams-history",n,i,y],queryFn:()=>ke.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const S=v?.data.map($=>({time:new Date($.recorded_at).getTime(),humidity:$.humidity,temperature:$.temperature,timeLabel:new Date($.recorded_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",...y>24?{day:"numeric",month:"short"}:{}})}))||[],A=o?.humidityGood||40,T=o?.humidityFair||60,k=o?.tempGood||30,N=o?.tempFair||35,I=S[S.length-1],C=I?.humidity,D=I?.temperature,F=$=>{const X=$.filter(ie=>ie!=null);if(X.length<4)return"stable";const te=X.slice(0,Math.floor(X.length/4)),fe=X.slice(-Math.floor(X.length/4)),pe=te.reduce((ie,xe)=>ie+xe,0)/te.length,Ne=fe.reduce((ie,xe)=>ie+xe,0)/fe.length-pe;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},O=F(S.map($=>$.humidity)),q=F(S.map($=>$.temperature)),R=({trend:$})=>$==="up"?l.jsx(yG,{className:"w-4 h-4 text-red-400"}):$==="down"?l.jsx(bG,{className:"w-4 h-4 text-green-400"}):l.jsx(jk,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),W=$=>$==null?"#9ca3af":$<=A?"#22a352":$<=T?"#d4a017":"#c62828",K=$=>$==null?"#9ca3af":$<=k?"#22a352":$<=N?"#d4a017":"#c62828",G=b?"#2d2d2d":"#ffffff",ee=b?"#1d1d1d":"#f3f4f6",Z=b?"#3d3d3d":"#e5e7eb",Q=b?"#ffffff":"#111827",U=b?"#9ca3af":"#4b5563";return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:G},onClick:$=>$.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:Z},children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold",style:{color:Q},children:[a," ",c("common.history","History")]}),l.jsx("p",{className:"text-sm",style:{color:U},children:r})]}),l.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:U},children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ee},children:[l.jsxs("button",{onClick:()=>m("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="humidity"?"bg-blue-600 text-white":""}`,style:g!=="humidity"?{color:U}:void 0,children:[l.jsx(lG,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),l.jsxs("button",{onClick:()=>m("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="temperature"?"bg-orange-600 text-white":""}`,style:g!=="temperature"?{color:U}:void 0,children:[l.jsx($S,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),l.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ee},children:N6.map($=>l.jsx("button",{onClick:()=>f($.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===$.value?"bg-bambu-green text-white":""}`,style:d!==$.value?{color:U}:void 0,children:$.label},$.value))})]}),l.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:W(C)},children:C!=null?`${C}%`:"—"}),l.jsx(R,{trend:O})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:v?.avg_humidity!=null?`${v.avg_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-green-500",children:v?.min_humidity!=null?`${v.min_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_humidity!=null?`${v.max_humidity}%`:"—"})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:K(D)},children:D!=null?`${D}°C`:"—"}),l.jsx(R,{trend:q})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:v?.avg_temperature!=null?`${v.avg_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-blue-500",children:v?.min_temperature!=null?`${v.min_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_temperature!=null?`${v.max_temperature}°C`:"—"})]})]})}),l.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:x?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.loading","Loading...")}):M?l.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):S.length===0?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.noData","No data available for this time range")}):l.jsx(n1,{width:"100%",height:300,children:l.jsxs(BTe,{data:S,children:[l.jsx(ww,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),l.jsx(Mw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:$=>{const X=new Date($);return y>24?X.toLocaleDateString([],{day:"numeric",month:"short"}):X.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),l.jsx(Ew,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:$=>g==="humidity"?`${$}%`:`${$}°C`}),l.jsx(i1,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:$=>new Date($).toLocaleString(),formatter:$=>[g==="humidity"?`${$}%`:`${$}°C`,g==="humidity"?"Humidity":"Temperature"]}),l.jsx(wD,{}),g==="humidity"?l.jsxs(l.Fragment,{children:[l.jsx(Ox,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(Ox,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):l.jsxs(l.Fragment,{children:[l.jsx(Ox,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(Ox,{y:N,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),l.jsx(gY,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),l.jsx("div",{className:"text-xs text-center",style:{color:U},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function aCe({side:t}){const{theme:e}=xb(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return l.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 sCe({colors:t,className:e}){const n=[{x:9.5,cx:12.5},{x:18.5,cx:21.5},{x:27.5,cx:30.5},{x:36.5,cx:39.5}];return l.jsxs("svg",{className:e,width:"56",height:"34",viewBox:"0 0 52 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0C1.79086 0 0 1.79086 0 4V28C0 30.2091 1.79086 32 4 32H48C50.2091 32 52 30.2091 52 28V4C52 1.79086 50.2091 0 48 0H4ZM44 8H8V24H44V8Z",fill:"#2F2E33"}),n.map((r,i)=>t[i]?l.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:t[i]},i):l.jsxs("g",{children:[l.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:"#ffffff"}),l.jsx("line",{x1:r.x,y1:"8",x2:r.x+6,y2:"24",stroke:"#555555",strokeWidth:"1.5"})]},i)),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M36.5 16H33.5V18.2617C33.5 19.9186 32.1569 21.2617 30.5 21.2617C28.8431 21.2617 27.5 19.9186 27.5 18.2617V16H24.5V18.2617C24.5 19.9186 23.1569 21.2617 21.5 21.2617C19.8431 21.2617 18.5 19.9186 18.5 18.2617V16H15.5V18.2617C15.5 19.9186 14.1569 21.2617 12.5 21.2617C10.8432 21.2617 9.5 19.9186 9.5 18.2617V16H4V28H48V16H42.5V18.2617C42.5 19.9186 41.1569 21.2617 39.5 21.2617C37.8431 21.2617 36.5 19.9186 36.5 18.2617V16Z",fill:"#767676"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 9.18382C6 6.32088 8.32088 4 11.1838 4H40.8162C43.6791 4 46 6.32088 46 9.18382V16H42.5V12.2617C42.5 10.6049 41.1569 9.26172 39.5 9.26172C37.8431 9.26172 36.5 10.6049 36.5 12.2617V16H33.5V12.2617C33.5 10.6049 32.1569 9.26172 30.5 9.26172C28.8431 9.26172 27.5 10.6049 27.5 12.2617V16H24.5V12.2617C24.5 10.6049 23.1569 9.26172 21.5 9.26172C19.8431 9.26172 18.5 10.6049 18.5 12.2617V16H15.5V12.2617C15.5 10.6049 14.1569 9.26172 12.5 9.26172C10.8432 9.26172 9.5 10.6049 9.5 12.2617V16H6V9.18382Z",fill:"#BFBFBF"})]})}function oCe({color:t,className:e}){return l.jsxs("svg",{className:e,width:"56",height:"56",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t?l.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:t,rx:"0.3"}):l.jsxs("g",{children:[l.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:"#ffffff",rx:"0.3"}),l.jsx("line",{x1:"8.3",y1:"5.2",x2:"12.1",y2:"10.3",stroke:"#555555",strokeWidth:"0.8"})]}),l.jsx("path",{d:"M5.88312 4.68555C5.88312 4.13326 6.33083 3.68555 6.88312 3.68555H13.5059C14.0582 3.68555 14.5059 4.13326 14.5059 4.68555V10.3887H5.88312V4.68555Z",stroke:"#6B6B6B"}),l.jsx("rect",{x:"3.8725",y:"10.3887",width:"12.7037",height:"7.55371",rx:"1.2",stroke:"#6B6B6B"}),l.jsx("path",{d:"M8.21991 5.65234C8.21991 5.3762 8.44377 5.15234 8.71991 5.15234H11.7288C12.005 5.15234 12.2288 5.3762 12.2288 5.65234V10.3887H8.21991V5.65234Z",stroke:"#6B6B6B"})]})}function k6({className:t}){return l.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:l.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 lCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.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 cCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.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 uCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function dCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),l.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 hCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),l.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 fC({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?l.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),l.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"})]}):l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function fCe({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r}){const i=typeof t=="string"?parseInt(t,10):t,a=typeof e=="number"?e:40,s=typeof n=="number"?n:60;let o,c;isNaN(i)?(o="#C3C2C1",c="Unknown"):i<=a?(o="#22a352",c="Good"):i<=s?(o="#d4a017",c="Fair"):(o="#c62828",c="Bad");let u;return isNaN(i)||i<=a?u=k6:i<=s?u=lCe:u=cCe,l.jsxs("button",{type:"button",onClick:r,className:`flex items-center justify-end gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${i}% - ${c}${r?" (click for history)":""}`,children:[l.jsx(u,{className:"w-3 h-4"}),l.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:o},children:[i,"%"]})]})}function pCe({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r}){const i=typeof e=="number"?e:28,a=typeof n=="number"?n:35;let s,o,c;return t<=i?(s="#22a352",o="Good",c=uCe):t<=a?(s="#d4a017",o="Fair",c=dCe):(s="#c62828",o="Bad",c=hCe),l.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${o}${r?" (click for history)":""}`,children:[l.jsx(c,{className:"w-3 h-4"}),l.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:s},children:[t,"°C"]})]})}function pC(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,s=String.fromCharCode(65+a);return i?`HT-${s}`:`AMS-${s}`}function mCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function gCe(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),r=new Date;r.setHours(0,0,0,0);const i=new Date(n);i.setHours(0,0,0,0);const a=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),s=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return s===0?a:s===1?`Tomorrow ${a}`:n.toLocaleDateString([],{weekday:"short"})+" "+a}function xCe(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 bCe(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 yCe({url:t,printName:e}){const[n,r]=E.useState(!1),[i,a]=E.useState(!1),[s,o]=E.useState(!1);return l.jsxs(l.Fragment,{children:[l.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&&o(!0),children:t&&!i?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&l.jsx(hm,{className:"w-8 h-8 text-bambu-gray"})]}):l.jsx(hm,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:l.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[l.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&l.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function vCe({printers:t}){const e=En(),n=E.useMemo(()=>{let i=0,a=0,s=0,o=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?o++:u.connected?u.state==="RUNNING"?i++:a++:s++}),{printing:i,idle:a,offline:s,loading:o,total:t?.length||0}},[t,e]),[,r]=E.useState(0);return E.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(s=>s+1),i=!1}))});return()=>a()},[e]),t?.length?l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function P6(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 R6({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const a=En(),s=kR(),[o,c]=E.useState(!1),[u,d]=E.useState(!1),[f,g]=E.useState(!1),[m,b]=E.useState(!1),[y,v]=E.useState(!1),[x,M]=E.useState(!1),[S,A]=E.useState(!1),[T,k]=E.useState(!1),[N,I]=E.useState(null),{data:C}=vt({queryKey:["printerStatus",t.id],queryFn:()=>ke.getPrinterStatus(t.id),refetchInterval:3e4}),[D,F]=E.useState(null);E.useEffect(()=>{C?.wifi_signal!=null&&F(C.wifi_signal)},[C?.wifi_signal]);const O=C?.wifi_signal??D,q=E.useRef(void 0);E.useEffect(()=>{C?.connected!==void 0&&(q.current=C.connected)},[C?.connected]);const R=C?.connected??q.current,W=E.useRef({});E.useEffect(()=>{C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0&&(W.current=C.ams_extruder_map)},[C?.ams_extruder_map]);const K=C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0?C.ams_extruder_map:W.current,G=E.useRef([]);E.useEffect(()=>{C?.ams&&C.ams.length>0&&(G.current=C.ams)},[C?.ams]);const ee=C?.ams&&C.ams.length>0?C.ams:G.current,{data:Z}=vt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ke.getSmartPlugByPrinter(t.id)}),{data:Q}=vt({queryKey:["smartPlugStatus",Z?.id],queryFn:()=>Z?ke.getSmartPlugStatus(Z.id):null,enabled:!!Z,refetchInterval:1e4}),{data:U}=vt({queryKey:["queue",t.id,"pending"],queryFn:()=>ke.getQueue(t.id,"pending")}),$=U?.length||0,{data:X}=vt({queryKey:["archives",t.id,"last"],queryFn:()=>ke.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),te=X?.[0],fe=e&&R===!1,pe=wt({mutationFn:()=>ke.deletePrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printers"]})}}),be=wt({mutationFn:()=>ke.connectPrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Ne=wt({mutationFn:xe=>Z?ke.controlSmartPlug(Z.id,xe):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugStatus",Z?.id]})}}),ie=wt({mutationFn:xe=>Z?ke.updateSmartPlug(Z.id,{auto_off:xe}):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),a.invalidateQueries({queryKey:["smart-plugs"]})}});return fe?null:l.jsxs(Nt,{className:"relative",children:[l.jsxs(Rt,{children:[l.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx("img",{src:xCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${r==="compact"?"w-10 h-10":"w-14 h-14"}`}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&l.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${C?.connected?"bg-bambu-green":"bg-red-500"}`,title:C?.connected?"Connected":"Offline"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&C?.nozzles&&C.nozzles[0]?.nozzle_diameter&&l.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:C.nozzles[0].nozzle_type||"Nozzle",children:["• ",C.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&l.jsxs("span",{className:"ml-2 text-bambu-gray",children:[l.jsx(_r,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),l.jsxs("div",{className:"relative flex-shrink-0",children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>c(!o),children:l.jsx(cG,{className:"w-4 h-4"})}),o&&l.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:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{g(!0),c(!1)},children:[l.jsx(id,{className:"w-4 h-4"}),"Edit"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{be.mutate(),c(!1)},children:[l.jsx(Ta,{className:"w-4 h-4"}),"Reconnect"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{v(!0),c(!1)},children:[l.jsx(xG,{className:"w-4 h-4"}),"MQTT Debug"]}),l.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:()=>{d(!0),c(!1)},children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[l.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${C?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[C?.connected?l.jsx(zS,{className:"w-3 h-3"}):l.jsx(vG,{className:"w-3 h-3"}),C?.connected?"Connected":"Offline"]}),C?.connected&&O!=null&&l.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${O>=-50||O>=-60?"bg-bambu-green/20 text-bambu-green":O>=-70?"bg-amber-500/20 text-amber-600":O>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${O} dBm - ${bCe(O).label}`,children:[l.jsx(tue,{className:"w-3 h-3"}),O,"dBm"]}),C?.connected&&(()=>{const xe=C.hms_errors?lde(C.hms_errors):[];return l.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 ${xe.length>0?xe.some(Re=>Re.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:[l.jsx(ti,{className:"w-3 h-3"}),xe.length>0?xe.length:"OK"]})})(),n&&l.jsxs("button",{onClick:()=>s("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-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:[l.jsx(ad,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),$>0&&l.jsxs("button",{onClick:()=>s("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${$} print${$>1?"s":""} in queue`,children:[l.jsx($h,{className:"w-3 h-3"}),$]})]})]}),u&&l.jsx(Qr,{title:"Delete Printer",message:`Are you sure you want to delete "${t.name}"? This will also remove all connection settings.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{pe.mutate(),d(!1)},onCancel:()=>d(!1)}),C?.connected&&l.jsxs(l.Fragment,{children:[r==="compact"?l.jsx("div",{className:"mt-2",children:C.state==="RUNNING"?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:l.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),l.jsxs("span",{className:"text-xs text-white",children:[Math.round(C.progress||0),"%"]})]}):l.jsx("p",{className:"text-xs text-bambu-gray",children:P6(C.state,C.stg_cur_name)})}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex gap-3",children:[l.jsx(yCe,{url:C.state==="RUNNING"?C.cover_url:null,printName:C.state==="RUNNING"&&(C.subtask_name||C.current_print)||void 0}),l.jsx("div",{className:"flex-1 min-w-0",children:C.current_print&&C.state==="RUNNING"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:C.stg_cur_name||"Printing"}),l.jsx("p",{className:"text-white text-sm mb-2 truncate",children:C.subtask_name||C.current_print}),l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:l.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),l.jsxs("span",{className:"text-white",children:[Math.round(C.progress||0),"%"]})]}),l.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[C.remaining_time!=null&&C.remaining_time>0&&l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx(_r,{className:"w-3 h-3"}),mCe(C.remaining_time*60)]}),l.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",gCe(C.remaining_time)]})]}),C.layer_num!=null&&C.total_layers!=null&&C.total_layers>0&&l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx($h,{className:"w-3 h-3"}),C.layer_num,"/",C.total_layers]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),l.jsx("p",{className:"text-white text-sm mb-2",children:P6(C.state,C.stg_cur_name)}),l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:l.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),l.jsx("span",{className:"text-bambu-gray",children:"—"})]}),te?l.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:te.print_name||te.filename,children:["Last: ",te.print_name||te.filename,te.completed_at&&l.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(te.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):l.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),C.state!=="RUNNING"&&l.jsx(hde,{printerId:t.id})]}),C.temperatures&&r==="expanded"&&(()=>{const xe=(C.temperatures.nozzle_target||0)>30||(C.temperatures.nozzle_2_target||0)>30,Re=(C.temperatures.bed_target||0)>30,he=(C.temperatures.chamber_target||0)>30;return l.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(fC,{className:"w-4 h-4 mx-auto mb-1",color:"text-orange-400",isHeating:xe}),C.temperatures.nozzle_2!==void 0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C / ",Math.round(C.temperatures.nozzle_2||0),"°C"]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C"]})]})]}),l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(fC,{className:"w-4 h-4 mx-auto mb-1",color:"text-blue-400",isHeating:Re}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.bed||0),"°C"]})]}),C.temperatures.chamber!==void 0&&l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(fC,{className:"w-4 h-4 mx-auto mb-1",color:"text-green-400",isHeating:he}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.chamber||0),"°C"]})]})]})})(),ee&&ee.length>0&&r==="expanded"&&l.jsxs("div",{className:"mt-3 space-y-2",children:[ee.map(xe=>{const Re=K[String(xe.id)],he=xe.id>=128?xe.id-128:xe.id,ht=Re!==void 0?Re:he,H=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,B=ht===1,re=ht===0,V=xe.tray.map(se=>se.tray_color?`#${se.tray_color}`:se.tray_type?"#333":null),J=xe.tray.length===1;return l.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[H&&(B||re)&&l.jsx(aCe,{side:B?"L":"R"}),J?l.jsx(oCe,{color:V[0],className:"flex-shrink-0"}):l.jsx(sCe,{colors:V,className:"flex-shrink-0"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:pC(xe.id,xe.tray.length)}),l.jsx("div",{className:"mt-0.5 text-[10px] flex items-start",children:xe.tray.map((se,Ae)=>l.jsxs("div",{className:"flex items-start",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-bambu-gray/70 truncate",children:se.tray_type?se.tray_sub_brands||se.tray_type:"—"}),l.jsx("span",{className:"text-bambu-gray/50 truncate",children:se.tray_type&&se.remain>=0?`${se.remain}%`:"—"})]}),Ae<xe.tray.length-1&&l.jsxs("span",{className:"text-bambu-gray/50 mx-1 flex flex-col",children:[l.jsx("span",{children:"·"}),l.jsx("span",{children:"·"})]})]},Ae))})]}),(xe.humidity!=null||xe.temp!=null)&&l.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[xe.humidity!=null&&l.jsx(fCe,{humidity:xe.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>I({amsId:xe.id,amsLabel:pC(xe.id,xe.tray.length),mode:"humidity"})}),xe.temp!=null&&l.jsx(pCe,{temp:xe.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>I({amsId:xe.id,amsLabel:pC(xe.id,xe.tray.length),mode:"temperature"})})]})]})},xe.id)}),C.vt_tray&&C.vt_tray.tray_type&&l.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-white/20 flex-shrink-0",style:{backgroundColor:C.vt_tray.tray_color?`#${C.vt_tray.tray_color}`:"#333"}}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:"External"}),l.jsx("p",{className:"text-[10px] text-bambu-gray/70",children:C.vt_tray.tray_sub_brands||C.vt_tray.tray_type||"Spool"})]})]})})]})]}),Z&&r==="expanded"&&l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(xm,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"text-sm text-white truncate",children:Z.name}),Q&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Q.state==="ON"?"bg-bambu-green/20 text-bambu-green":Q.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:Q.state||"?"}),Q?.energy?.power!=null&&Q.state==="ON"&&l.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[Q.energy.power,"W"]})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:()=>M(!0),disabled:Ne.isPending||Q?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Q?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[l.jsx(yd,{className:"w-3 h-3"}),"On"]}),l.jsxs("button",{onClick:()=>A(!0),disabled:Ne.isPending||Q?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Q?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[l.jsx(WR,{className:"w-3 h-3"}),"Off"]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx("span",{className:`text-xs hidden sm:inline ${Z.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:Z.auto_off_executed?"Auto-off done":"Auto-off"}),l.jsx("button",{onClick:()=>ie.mutate(!Z.auto_off),disabled:ie.isPending||Z.auto_off_executed,title:Z.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 ${Z.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":Z.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:l.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${Z.auto_off||Z.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&l.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs text-bambu-gray",children:[l.jsx("p",{children:t.ip_address}),l.jsx("p",{className:"truncate",children:t.serial_number})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!C?.connected,title:"Open camera in new window",children:l.jsx(_G,{className:"w-4 h-4"})}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>b(!0),title:"Browse printer files",children:[l.jsx($R,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&l.jsx(ade,{printerId:t.id,printerName:t.name,onClose:()=>b(!1)}),y&&l.jsx(sde,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),x&&Z&&l.jsx(Qr,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{Ne.mutate("on"),M(!1)},onCancel:()=>M(!1)}),S&&Z&&l.jsx(Qr,{title:"Power Off Printer",message:C?.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:()=>{Ne.mutate("off"),A(!1)},onCancel:()=>A(!1)}),T&&l.jsx(ude,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>k(!1)}),N&&l.jsx(iCe,{isOpen:!!N,onClose:()=>I(null),printerId:t.id,printerName:t.name,amsId:N.amsId,amsLabel:N.amsLabel,initialMode:N.mode,thresholds:i}),f&&l.jsx(wCe,{printer:t,onClose:()=>g(!1)})]})}function _Ce({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=E.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,s]=E.useState(!1),[o,c]=E.useState([]),[u,d]=E.useState(""),[f,g]=E.useState(!1),m=o.filter(x=>!n.includes(x.serial)),b=async()=>{d(""),c([]),s(!0),g(!1);try{await sx.startDiscovery(10);const x=setInterval(async()=>{try{const M=await sx.getDiscoveredPrinters();c(M)}catch(M){console.error("Failed to get discovered printers:",M)}},1e3);setTimeout(async()=>{clearInterval(x);try{await sx.stopDiscovery()}catch{}s(!1),g(!0);try{const M=await sx.getDiscoveredPrinters();c(M)}catch(M){console.error("Failed to get final discovered printers:",M)}},1e4)}catch(x){console.error("Failed to start discovery:",x),d(x instanceof Error?x.message:"Failed to start discovery"),s(!1),g(!0)}},y=x=>x?{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"}[x]||x:"",v=x=>{i({...r,name:x.name||"",serial_number:x.serial,ip_address:x.ip_address,model:y(x.model)}),c([])};return E.useEffect(()=>()=>{sx.stopDiscovery().catch(()=>{})},[]),E.useEffect(()=>{const x=M=>{M.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:x=>x.stopPropagation(),children:l.jsxs(Rt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),l.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:b,disabled:a,className:"w-full",children:a?l.jsxs(l.Fragment,{children:[l.jsx(Et,{className:"w-4 h-4 animate-spin"}),"Scanning..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Cc,{className:"w-4 h-4"}),"Discover Printers on Network"]})}),u&&l.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),m.length>0&&l.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:m.map(x=>l.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:()=>v(x),children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"font-medium text-white text-sm truncate",children:x.name||x.serial}),l.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[x.model||"Unknown"," • ",x.ip_address]})]}),l.jsx(bd,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},x.serial))}),a&&l.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"Scanning network..."}),f&&!a&&o.length===0&&l.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"No printers found on the network."}),f&&!a&&o.length>0&&m.length===0&&l.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),l.jsxs("form",{onSubmit:x=>{x.preventDefault(),e(r)},className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.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:x=>i({...r,name:x.target.value}),placeholder:"My Printer"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.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:x=>i({...r,ip_address:x.target.value}),placeholder:"192.168.1.100"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.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:x=>i({...r,serial_number:x.target.value}),placeholder:"01P00A000000000"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.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:x=>i({...r,access_code:x.target.value}),placeholder:"From printer settings"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),l.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:x=>i({...r,model:x.target.value}),children:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:x=>i({...r,auto_archive:x.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function wCe({printer:t,onClose:e}){const n=En(),[r,i]=E.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=wt({mutationFn:o=>ke.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});E.useEffect(()=>{const o=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const s=o=>{o.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 l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:l.jsxs(Rt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),l.jsxs("form",{onSubmit:s,className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.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:o=>i({...r,name:o.target.value}),placeholder:"My Printer"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.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:o=>i({...r,ip_address:o.target.value}),placeholder:"192.168.1.100"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.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}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.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:o=>i({...r,access_code:o.target.value}),placeholder:"Leave empty to keep current"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),l.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:o=>i({...r,model:o.target.value}),children:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),l.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:o=>i({...r,location:o.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:o=>i({...r,auto_archive:o.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function SCe(t){const{data:e}=vt({queryKey:["printerStatus",t],queryFn:()=>ke.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function MCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=SCe(t.id),{data:a}=vt({queryKey:["smartPlugStatus",e.id],queryFn:()=>ke.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&l.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||"?"})]}),l.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:[l.jsx(yd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function ECe(){const[t,e]=E.useState(!1),[n,r]=E.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=E.useState(!1),[s,o]=E.useState(null),[c,u]=E.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=E.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=E.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),b=En(),{data:y,isLoading:v}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:x}=vt({queryKey:["settings"],queryFn:ke.getSettings}),{data:M}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:S}=vt({queryKey:["maintenanceOverview"],queryFn:ke.getMaintenanceOverview,staleTime:60*1e3}),A=S?.reduce((R,W)=>(R[W.printer_id]={due_count:W.due_count,warning_count:W.warning_count,total_print_hours:W.total_print_hours},R),{})||{},T=M?.reduce((R,W)=>(W.printer_id&&(R[W.printer_id]=W),R),{})||{},k=wt({mutationFn:ke.createPrinter,onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),e(!1)}}),N=wt({mutationFn:R=>ke.controlSmartPlug(R,"on"),onSuccess:()=>{b.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),I=()=>{const R=!n;r(R),localStorage.setItem("hideDisconnectedPrinters",String(R))},C=R=>{u(R),localStorage.setItem("printerSortBy",R)},D=()=>{const R=!d;f(R),localStorage.setItem("printerSortAsc",String(R))},F=()=>{const R=g==="expanded"?"compact":"expanded";m(R),localStorage.setItem("printerViewMode",R)},O=E.useMemo(()=>{if(!y)return[];const R=[...y];switch(c){case"name":R.sort((W,K)=>W.name.localeCompare(K.name));break;case"model":R.sort((W,K)=>(W.model||"").localeCompare(K.model||""));break;case"location":R.sort((W,K)=>{const G=W.location||"",ee=K.location||"";return!G&&ee?1:G&&!ee?-1:G.localeCompare(ee)||W.name.localeCompare(K.name)});break;case"status":R.sort((W,K)=>{const G=b.getQueryData(["printerStatus",W.id]),ee=b.getQueryData(["printerStatus",K.id]),Z=Q=>Q?.connected?Q.state==="RUNNING"?0:1:2;return Z(G)-Z(ee)});break}return d||R.reverse(),R},[y,c,d,b]),q=E.useMemo(()=>{if(c!=="location")return null;const R={};return O.forEach(W=>{const K=W.location||"Ungrouped";R[K]||(R[K]=[]),R[K].push(W)}),R},[c,O]);return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),l.jsx(vCe,{printers:y})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("select",{value:c,onChange:R=>C(R.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:[l.jsx("option",{value:"name",children:"Name"}),l.jsx("option",{value:"status",children:"Status"}),l.jsx("option",{value:"model",children:"Model"}),l.jsx("option",{value:"location",children:"Location"})]}),l.jsx("button",{onClick:D,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?l.jsx(dm,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(x0,{className:"w-4 h-4 text-bambu-gray"})})]}),l.jsx("button",{onClick:F,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:g==="expanded"?"Switch to compact view":"Switch to expanded view",children:g==="expanded"?l.jsx(Hle,{className:"w-5 h-5 text-bambu-gray"}):l.jsx(hG,{className:"w-5 h-5 text-bambu-gray"})}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:n,onChange:I,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(T).length>0&&l.jsxs("div",{className:"relative",children:[l.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:[l.jsx(yd,{className:"w-4 h-4"}),"Power On",l.jsx(bd,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),l.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:[l.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"}),y?.filter(R=>T[R.id]).map(R=>l.jsx(MCe,{printer:R,plug:T[R.id],onPowerOn:W=>{o(W),N.mutate(W)},isPowering:s===T[R.id]?.id},R.id)),y?.filter(R=>T[R.id]).length===0&&l.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),l.jsxs(Le,{onClick:()=>e(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):y?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),l.jsxs(Le,{onClick:()=>e(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?l.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([R,W])=>l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),R,l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.length,")"]})]}),l.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:W.map(K=>l.jsx(R6,{printer:K,hideIfDisconnected:n,maintenanceInfo:A[K.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},K.id))})]},R))}):l.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:O.map(R=>l.jsx(R6,{printer:R,hideIfDisconnected:n,maintenanceInfo:A[R.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},R.id))}),t&&l.jsx(_Ce,{onClose:()=>e(!1),onAdd:R=>k.mutate(R),existingSerials:y?.map(R=>R.serial_number)||[]})]})}const Qj="181",nm={ROTATE:0,DOLLY:1,PAN:2},qp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ACe=0,D6=1,TCe=2,BY=1,CCe=2,ic=3,dd=0,qa=1,rl=2,wc=0,rm=1,j6=2,O6=3,L6=4,NCe=5,oh=100,kCe=101,PCe=102,RCe=103,DCe=104,jCe=200,OCe=201,LCe=202,ICe=203,U3=204,z3=205,FCe=206,UCe=207,zCe=208,BCe=209,HCe=210,$Ce=211,VCe=212,GCe=213,WCe=214,B3=0,H3=1,$3=2,Am=3,V3=4,G3=5,W3=6,q3=7,Jj=0,qCe=1,KCe=2,Yu=0,XCe=1,YCe=2,ZCe=3,QCe=4,JCe=5,eNe=6,tNe=7,HY=300,Tm=301,Cm=302,K3=303,X3=304,FM=306,Y3=1e3,mc=1001,Z3=1002,ws=1003,nNe=1004,Ov=1005,ro=1006,mC=1007,xh=1008,gl=1009,$Y=1010,VY=1011,$0=1012,eO=1013,Qh=1014,gc=1015,sg=1016,tO=1017,nO=1018,V0=1020,GY=35902,WY=35899,qY=1021,KY=1022,Do=1023,G0=1026,W0=1027,XY=1028,rO=1029,iO=1030,aO=1031,sO=1033,s1=33776,o1=33777,l1=33778,c1=33779,Q3=35840,J3=35841,eP=35842,tP=35843,nP=36196,rP=37492,iP=37496,aP=37808,sP=37809,oP=37810,lP=37811,cP=37812,uP=37813,dP=37814,hP=37815,fP=37816,pP=37817,mP=37818,gP=37819,xP=37820,bP=37821,yP=36492,vP=36494,_P=36495,wP=36283,SP=36284,MP=36285,EP=36286,rNe=3200,iNe=3201,YY=0,aNe=1,Iu="",qs="srgb",Nm="srgb-linear",Cw="linear",qn="srgb",ep=7680,I6=519,sNe=512,oNe=513,lNe=514,ZY=515,cNe=516,uNe=517,dNe=518,hNe=519,F6=35044,U6="300 es",ol=2e3,Nw=2001;function QY(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function kw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function fNe(){const t=kw("canvas");return t.style.display="block",t}const z6={};function B6(...t){const e="THREE."+t.shift();console.log(e,...t)}function Yt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function zr(...t){const e="THREE."+t.shift();console.error(e,...t)}function q0(...t){const e=t.join(" ");e in z6||(z6[e]=!0,Yt(...t))}function pNe(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 pf=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,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}};const aa=["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"],u1=Math.PI/180,AP=180/Math.PI;function Wb(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(aa[t&255]+aa[t>>8&255]+aa[t>>16&255]+aa[t>>24&255]+"-"+aa[e&255]+aa[e>>8&255]+"-"+aa[e>>16&15|64]+aa[e>>24&255]+"-"+aa[n&63|128]+aa[n>>8&255]+"-"+aa[n>>16&255]+aa[n>>24&255]+aa[r&255]+aa[r>>8&255]+aa[r>>16&255]+aa[r>>24&255]).toLowerCase()}function gn(t,e,n){return Math.max(e,Math.min(n,t))}function mNe(t,e){return(t%e+e)%e}function gC(t,e,n){return(1-n)*t+n*e}function mx(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 za(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 gNe={DEG2RAD:u1};let cn=class JY{constructor(e=0,n=0){JY.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(gn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Jh=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,s,o){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=a[s+0],m=a[s+1],b=a[s+2],y=a[s+3];if(o<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(f!==y||c!==g||u!==m||d!==b){let v=c*g+u*m+d*b+f*y;v<0&&(g=-g,m=-m,b=-b,y=-y,v=-v);let x=1-o;if(v<.9995){const M=Math.acos(v),S=Math.sin(M);x=Math.sin(x*M)/S,o=Math.sin(o*M)/S,c=c*x+g*o,u=u*x+m*o,d=d*x+b*o,f=f*x+y*o}else{c=c*x+g*o,u=u*x+m*o,d=d*x+b*o,f=f*x+y*o;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,s){const o=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],m=a[s+2],b=a[s+3];return e[n]=o*b+d*f+c*m-u*g,e[n+1]=c*b+d*g+u*f-o*m,e[n+2]=u*b+d*m+o*g-c*f,e[n+3]=d*b-o*f-c*g-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),d=o(i/2),f=o(a/2),g=c(r/2),m=c(i/2),b=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*m*b,this._y=u*m*f-g*d*b,this._z=u*d*b+g*m*f,this._w=u*d*f-g*m*b;break;case"YXZ":this._x=g*d*f+u*m*b,this._y=u*m*f-g*d*b,this._z=u*d*b-g*m*f,this._w=u*d*f+g*m*b;break;case"ZXY":this._x=g*d*f-u*m*b,this._y=u*m*f+g*d*b,this._z=u*d*b+g*m*f,this._w=u*d*f-g*m*b;break;case"ZYX":this._x=g*d*f-u*m*b,this._y=u*m*f+g*d*b,this._z=u*d*b-g*m*f,this._w=u*d*f+g*m*b;break;case"YZX":this._x=g*d*f+u*m*b,this._y=u*m*f+g*d*b,this._z=u*d*b-g*m*f,this._w=u*d*f-g*m*b;break;case"XZY":this._x=g*d*f-u*m*b,this._y=u*m*f-g*d*b,this._z=u*d*b+g*m*f,this._w=u*d*f+g*m*b;break;default:Yt("Quaternion: .setFromEuler() encountered an unknown order: "+s)}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],s=n[1],o=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(s-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+s)/m,this._z=(a+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(a-u)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(s-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(gn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*o+i*u-a*c,this._y=i*d+s*c+a*o-r*u,this._z=a*d+s*u+r*c-i*o,this._w=s*d-r*o-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,s=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,a=-a,s=-s,o=-o);let c=1-n;if(o<.9995){const u=Math.acos(o),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+s*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+s*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}},Je=class eZ{constructor(e=0,n=0,r=0){eZ.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(H6.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(H6.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,s=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])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),d=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-o*d,this.y=r+c*d+o*u-a*f,this.z=i+c*f+a*d-s*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=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,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 xC.copy(this).projectOnVector(e),this.sub(xC)}reflect(e){return this.sub(xC.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(gn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const xC=new Je,H6=new Jh;let dn=class tZ{constructor(e,n,r,i,a,s,o,c,u){tZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,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,s=r[0],o=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],b=r[8],y=i[0],v=i[3],x=i[6],M=i[1],S=i[4],A=i[7],T=i[2],k=i[5],N=i[8];return a[0]=s*y+o*M+c*T,a[3]=s*v+o*S+c*k,a[6]=s*x+o*A+c*N,a[1]=u*y+d*M+f*T,a[4]=u*v+d*S+f*k,a[7]=u*x+d*A+f*N,a[2]=g*y+m*M+b*T,a[5]=g*v+m*S+b*k,a[8]=g*x+m*A+b*N,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],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*o*u-r*a*d+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*s-o*u,g=o*c-d*a,m=u*a-s*c,b=n*f+r*g+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(o*r-i*s)*y,e[3]=g*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-o*n)*y,e[6]=m*y,e[7]=(r*c-u*n)*y,e[8]=(s*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(bC.makeScale(e,n)),this}rotate(e){return this.premultiply(bC.makeRotation(-e)),this}translate(e,n){return this.premultiply(bC.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 bC=new dn,$6=new dn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),V6=new dn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xNe(){const t={enabled:!0,workingColorSpace:Nm,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===qn&&(i.r=Sc(i.r),i.g=Sc(i.g),i.b=Sc(i.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===qn&&(i.r=im(i.r),i.g=im(i.g),i.b=im(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===Iu?Cw: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,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].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 q0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return q0("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({[Nm]:{primaries:e,whitePoint:r,transfer:Cw,toXYZ:$6,fromXYZ:V6,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:qs},outputColorSpaceConfig:{drawingBufferColorSpace:qs}},[qs]:{primaries:e,whitePoint:r,transfer:qn,toXYZ:$6,fromXYZ:V6,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:qs}}}),t}const Cn=xNe();function Sc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function im(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let tp,bNe=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{tp===void 0&&(tp=kw("canvas")),tp.width=e.width,tp.height=e.height;const i=tp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=tp}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=kw("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 s=0;s<a.length;s++)a[s]=Sc(a[s]/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(Sc(n[r]/255)*255):n[r]=Sc(n[r]);return{data:n,width:e.width,height:e.height}}else return Yt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},yNe=0,oO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:yNe++}),this.uuid=Wb(),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 s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(yC(i[s].image)):a.push(yC(i[s]))}else a=yC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function yC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?bNe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Yt("Texture: Unable to serialize Texture."),{})}let vNe=0;const vC=new Je;let $o=class d1 extends pf{constructor(e=d1.DEFAULT_IMAGE,n=d1.DEFAULT_MAPPING,r=mc,i=mc,a=ro,s=xh,o=Do,c=gl,u=d1.DEFAULT_ANISOTROPY,d=Iu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:vNe++}),this.uuid=Wb(),this.name="",this.source=new oO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new cn(0,0),this.repeat=new cn(1,1),this.center=new cn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dn,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(vC).x}get height(){return this.source.getSize(vC).y}get depth(){return this.source.getSize(vC).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){Yt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`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!==HY)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Y3:e.x=e.x-Math.floor(e.x);break;case mc:e.x=e.x<0?0:1;break;case Z3: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 Y3:e.y=e.y-Math.floor(e.y);break;case mc:e.y=e.y<0?0:1;break;case Z3: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++}};$o.DEFAULT_IMAGE=null;$o.DEFAULT_MAPPING=HY;$o.DEFAULT_ANISOTROPY=1;let Yr=class nZ{constructor(e=0,n=0,r=0,i=1){nZ.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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],m=c[5],b=c[9],y=c[2],v=c[6],x=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(b-v)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(b+v)<.1&&Math.abs(u+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(x+1)/2,k=(d+g)/4,N=(f+y)/4,I=(b+v)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=I/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=I/a),this.set(r,i,a,n),this}let M=Math.sqrt((v-b)*(v-b)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(M)<.001&&(M=1),this.x=(v-b)/M,this.y=(f-y)/M,this.z=(g-d)/M,this.w=Math.acos((u+m+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this.w=gn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this.w=gn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},_Ne=class extends pf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ro,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 Yr(0,0,e,n),this.scissorTest=!1,this.viewport=new Yr(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new $o(i);this.textures=[];const s=r.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].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:ro,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 oO(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"})}},ef=class extends _Ne{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},rZ=class extends $o{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=ws,this.minFilter=ws,this.wrapR=mc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},wNe=class extends $o{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=ws,this.minFilter=ws,this.wrapR=mc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class{constructor(e=new Je(1/0,1/0,1/0),n=new Je(-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(vo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(vo.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=vo.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 s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,vo):vo.fromBufferAttribute(a,s),vo.applyMatrix4(e.matrixWorld),this.expandByPoint(vo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Lv.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Lv.copy(r.boundingBox)),Lv.applyMatrix4(e.matrixWorld),this.union(Lv)}const i=e.children;for(let a=0,s=i.length;a<s;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,vo),vo.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(gx),Iv.subVectors(this.max,gx),np.subVectors(e.a,gx),rp.subVectors(e.b,gx),ip.subVectors(e.c,gx),fu.subVectors(rp,np),pu.subVectors(ip,rp),$d.subVectors(np,ip);let n=[0,-fu.z,fu.y,0,-pu.z,pu.y,0,-$d.z,$d.y,fu.z,0,-fu.x,pu.z,0,-pu.x,$d.z,0,-$d.x,-fu.y,fu.x,0,-pu.y,pu.x,0,-$d.y,$d.x,0];return!_C(n,np,rp,ip,Iv)||(n=[1,0,0,0,1,0,0,0,1],!_C(n,np,rp,ip,Iv))?!1:(Fv.crossVectors(fu,pu),n=[Fv.x,Fv.y,Fv.z],_C(n,np,rp,ip,Iv))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vo).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:(Vl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Vl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Vl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Vl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Vl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Vl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Vl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Vl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Vl),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 Vl=[new Je,new Je,new Je,new Je,new Je,new Je,new Je,new Je],vo=new Je,Lv=new tf,np=new Je,rp=new Je,ip=new Je,fu=new Je,pu=new Je,$d=new Je,gx=new Je,Iv=new Je,Fv=new Je,Vd=new Je;function _C(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){Vd.fromArray(t,a);const o=i.x*Math.abs(Vd.x)+i.y*Math.abs(Vd.y)+i.z*Math.abs(Vd.z),c=e.dot(Vd),u=n.dot(Vd),d=r.dot(Vd);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>o)return!1}return!0}const SNe=new tf,xx=new Je,wC=new Je;let UM=class{constructor(e=new Je,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):SNe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;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;xx.subVectors(e,this.center);const n=xx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(xx,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):(wC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xx.copy(e.center).add(wC)),this.expandByPoint(xx.copy(e.center).sub(wC))),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 Gl=new Je,SC=new Je,Uv=new Je,mu=new Je,MC=new Je,zv=new Je,EC=new Je;let lO=class{constructor(e=new Je,n=new Je(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,Gl)),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=Gl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Gl.copy(this.origin).addScaledVector(this.direction,n),Gl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){SC.copy(e).add(n).multiplyScalar(.5),Uv.copy(n).sub(e).normalize(),mu.copy(this.origin).sub(SC);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Uv),o=mu.dot(this.direction),c=-mu.dot(Uv),u=mu.lengthSq(),d=Math.abs(1-s*s);let f,g,m,b;if(d>0)if(f=s*c-o,g=s*o-c,b=a*d,f>=0)if(g>=-b)if(g<=b){const y=1/d;f*=y,g*=y,m=f*(f+s*g+2*o)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g<=-b?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u):g<=b?(f=0,g=Math.min(Math.max(-a,-c),a),m=g*(g+2*c)+u):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(SC).addScaledVector(Uv,g),m}intersectSphere(e,n){Gl.subVectors(e.center,this.origin);const r=Gl.dot(this.direction),i=Gl.dot(Gl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,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,s,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Gl)!==null}intersectTriangle(e,n,r,i,a){MC.subVectors(n,e),zv.subVectors(r,e),EC.crossVectors(MC,zv);let s=this.direction.dot(EC),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;mu.subVectors(this.origin,e);const c=o*this.direction.dot(zv.crossVectors(mu,zv));if(c<0)return null;const u=o*this.direction.dot(MC.cross(mu));if(u<0||c+u>s)return null;const d=-o*mu.dot(EC);return d<0?null:this.at(d/s,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)}},ri=class TP{constructor(e,n,r,i,a,s,o,c,u,d,f,g,m,b,y,v){TP.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,s,o,c,u,d,f,g,m,b,y,v)}set(e,n,r,i,a,s,o,c,u,d,f,g,m,b,y,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=a,x[5]=s,x[9]=o,x[13]=c,x[2]=u,x[6]=d,x[10]=f,x[14]=g,x[3]=m,x[7]=b,x[11]=y,x[15]=v,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 TP().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/ap.setFromMatrixColumn(e,0).length(),a=1/ap.setFromMatrixColumn(e,1).length(),s=1/ap.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]*s,n[9]=r[9]*s,n[10]=r[10]*s,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,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,m=s*f,b=o*d,y=o*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+b*u,n[5]=g-y*u,n[9]=-o*c,n[2]=y-g*u,n[6]=b+m*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,m=c*f,b=u*d,y=u*f;n[0]=g+y*o,n[4]=b*o-m,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=m*o-b,n[6]=y+g*o,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,m=c*f,b=u*d,y=u*f;n[0]=g-y*o,n[4]=-s*f,n[8]=b+m*o,n[1]=m+b*o,n[5]=s*d,n[9]=y-g*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,m=s*f,b=o*d,y=o*f;n[0]=c*d,n[4]=b*u-m,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=m*u-b,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,m=s*u,b=o*c,y=o*u;n[0]=c*d,n[4]=y-g*f,n[8]=b*f+m,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+b,n[10]=g-y*f}else if(e.order==="XZY"){const g=s*c,m=s*u,b=o*c,y=o*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=s*d,n[9]=m*f-b,n[2]=b*f-m,n[6]=o*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(MNe,e,ENe)}lookAt(e,n,r){const i=this.elements;return cs.subVectors(e,n),cs.lengthSq()===0&&(cs.z=1),cs.normalize(),gu.crossVectors(r,cs),gu.lengthSq()===0&&(Math.abs(r.z)===1?cs.x+=1e-4:cs.z+=1e-4,cs.normalize(),gu.crossVectors(r,cs)),gu.normalize(),Bv.crossVectors(cs,gu),i[0]=gu.x,i[4]=Bv.x,i[8]=cs.x,i[1]=gu.y,i[5]=Bv.y,i[9]=cs.y,i[2]=gu.z,i[6]=Bv.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,s=r[0],o=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],b=r[2],y=r[6],v=r[10],x=r[14],M=r[3],S=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],O=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],ee=i[3],Z=i[7],Q=i[11],U=i[15];return a[0]=s*k+o*D+c*R+u*ee,a[4]=s*N+o*F+c*W+u*Z,a[8]=s*I+o*O+c*K+u*Q,a[12]=s*C+o*q+c*G+u*U,a[1]=d*k+f*D+g*R+m*ee,a[5]=d*N+f*F+g*W+m*Z,a[9]=d*I+f*O+g*K+m*Q,a[13]=d*C+f*q+g*G+m*U,a[2]=b*k+y*D+v*R+x*ee,a[6]=b*N+y*F+v*W+x*Z,a[10]=b*I+y*O+v*K+x*Q,a[14]=b*C+y*q+v*G+x*U,a[3]=M*k+S*D+A*R+T*ee,a[7]=M*N+S*F+A*W+T*Z,a[11]=M*I+S*O+A*K+T*Q,a[15]=M*C+S*q+A*G+T*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],s=e[1],o=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],b=e[3],y=e[7],v=e[11],x=e[15];return b*(+a*c*f-i*u*f-a*o*g+r*u*g+i*o*m-r*c*m)+y*(+n*c*m-n*u*g+a*s*g-i*s*m+i*u*d-a*c*d)+v*(+n*u*f-n*o*m-a*s*f+r*s*m+a*o*d-r*u*d)+x*(-i*o*d-n*c*f+n*o*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],b=e[12],y=e[13],v=e[14],x=e[15],M=f*v*u-y*g*u+y*c*m-o*v*m-f*c*x+o*g*x,S=b*g*u-d*v*u-b*c*m+s*v*m+d*c*x-s*g*x,A=d*y*u-b*f*u+b*o*m-s*y*m-d*o*x+s*f*x,T=b*f*c-d*y*c-b*o*g+s*y*g+d*o*v-s*f*v,k=n*M+r*S+i*A+a*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/k;return e[0]=M*N,e[1]=(y*g*a-f*v*a-y*i*m+r*v*m+f*i*x-r*g*x)*N,e[2]=(o*v*a-y*c*a+y*i*u-r*v*u-o*i*x+r*c*x)*N,e[3]=(f*c*a-o*g*a-f*i*u+r*g*u+o*i*m-r*c*m)*N,e[4]=S*N,e[5]=(d*v*a-b*g*a+b*i*m-n*v*m-d*i*x+n*g*x)*N,e[6]=(b*c*a-s*v*a-b*i*u+n*v*u+s*i*x-n*c*x)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*m+n*c*m)*N,e[8]=A*N,e[9]=(b*f*a-d*y*a-b*r*m+n*y*m+d*r*x-n*f*x)*N,e[10]=(s*y*a-b*o*a+b*r*u-n*y*u-s*r*x+n*o*x)*N,e[11]=(d*o*a-s*f*a-d*r*u+n*f*u+s*r*m-n*o*m)*N,e[12]=T*N,e[13]=(d*y*i-b*f*i+b*r*g-n*y*g-d*r*v+n*f*v)*N,e[14]=(b*o*i-s*y*i-b*r*c+n*y*c+s*r*v-n*o*v)*N,e[15]=(s*f*i-d*o*i+d*r*c-n*f*c-s*r*g+n*o*g)*N,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,s=e.x,o=e.y,c=e.z,u=a*s,d=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*s,0,u*c-i*o,d*c+i*s,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,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,d=s+s,f=o+o,g=a*u,m=a*d,b=a*f,y=s*d,v=s*f,x=o*f,M=c*u,S=c*d,A=c*f,T=r.x,k=r.y,N=r.z;return i[0]=(1-(y+x))*T,i[1]=(m+A)*T,i[2]=(b-S)*T,i[3]=0,i[4]=(m-A)*k,i[5]=(1-(g+x))*k,i[6]=(v+M)*k,i[7]=0,i[8]=(b+S)*N,i[9]=(v-M)*N,i[10]=(1-(g+y))*N,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=ap.set(i[0],i[1],i[2]).length();const s=ap.set(i[4],i[5],i[6]).length(),o=ap.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],_o.copy(this);const u=1/a,d=1/s,f=1/o;return _o.elements[0]*=u,_o.elements[1]*=u,_o.elements[2]*=u,_o.elements[4]*=d,_o.elements[5]*=d,_o.elements[6]*=d,_o.elements[8]*=f,_o.elements[9]*=f,_o.elements[10]*=f,n.setFromRotationMatrix(_o),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=ol,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let b,y;if(c)b=a/(s-a),y=s*a/(s-a);else if(o===ol)b=-(s+a)/(s-a),y=-2*s*a/(s-a);else if(o===Nw)b=-s/(s-a),y=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=b,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=ol,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let b,y;if(c)b=1/(s-a),y=s/(s-a);else if(o===ol)b=-2/(s-a),y=-(s+a)/(s-a);else if(o===Nw)b=-1/(s-a),y=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=b,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const ap=new Je,_o=new ri,MNe=new Je(0,0,0),ENe=new Je(1,1,1),gu=new Je,Bv=new Je,cs=new Je,G6=new ri,W6=new Jh;let hd=class iZ{constructor(e=0,n=0,r=0,i=iZ.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],s=i[4],o=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(gn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-gn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(gn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-gn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(gn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-gn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:Yt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return G6.makeRotationFromQuaternion(e),this.setFromRotationMatrix(G6,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return W6.setFromEuler(this),this.setFromQuaternion(W6,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}};hd.DEFAULT_ORDER="XYZ";let aZ=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}},ANe=0;const q6=new Je,sp=new Jh,Wl=new ri,Hv=new Je,bx=new Je,TNe=new Je,CNe=new Jh,K6=new Je(1,0,0),X6=new Je(0,1,0),Y6=new Je(0,0,1),Z6={type:"added"},NNe={type:"removed"},op={type:"childadded",child:null},AC={type:"childremoved",child:null};let Ns=class h1 extends pf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ANe++}),this.uuid=Wb(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=h1.DEFAULT_UP.clone();const e=new Je,n=new hd,r=new Jh,i=new Je(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),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 ri},normalMatrix:{value:new dn}}),this.matrix=new ri,this.matrixWorld=new ri,this.matrixAutoUpdate=h1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=h1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new aZ,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 sp.setFromAxisAngle(e,n),this.quaternion.multiply(sp),this}rotateOnWorldAxis(e,n){return sp.setFromAxisAngle(e,n),this.quaternion.premultiply(sp),this}rotateX(e){return this.rotateOnAxis(K6,e)}rotateY(e){return this.rotateOnAxis(X6,e)}rotateZ(e){return this.rotateOnAxis(Y6,e)}translateOnAxis(e,n){return q6.copy(e).applyQuaternion(this.quaternion),this.position.add(q6.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(K6,e)}translateY(e){return this.translateOnAxis(X6,e)}translateZ(e){return this.translateOnAxis(Y6,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Wl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Hv.copy(e):Hv.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),bx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Wl.lookAt(bx,Hv,this.up):Wl.lookAt(Hv,bx,this.up),this.quaternion.setFromRotationMatrix(Wl),i&&(Wl.extractRotation(i.matrixWorld),sp.setFromRotationMatrix(Wl),this.quaternion.premultiply(sp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(zr("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(Z6),op.child=e,this.dispatchEvent(op),op.child=null):zr("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(NNe),AC.child=e,this.dispatchEvent(AC),AC.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),Wl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Wl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Wl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Z6),op.child=e,this.dispatchEvent(op),op.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 s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;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(bx,e,TNe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bx,CNe,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,s=i.length;a<s;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(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),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(o,c){return o[c.uuid]===void 0&&(o[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 o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.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 o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),m=s(e.animations),b=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}return r.object=i,r;function s(o){const c=[];for(const u in o){const d=o[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}};Ns.DEFAULT_UP=new Je(0,1,0);Ns.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ns.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const wo=new Je,ql=new Je,TC=new Je,Kl=new Je,lp=new Je,cp=new Je,Q6=new Je,CC=new Je,NC=new Je,kC=new Je,PC=new Yr,RC=new Yr,DC=new Yr;let yx=class Fp{constructor(e=new Je,n=new Je,r=new Je){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),wo.subVectors(e,n),i.cross(wo);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){wo.subVectors(i,n),ql.subVectors(r,n),TC.subVectors(e,n);const s=wo.dot(wo),o=wo.dot(ql),c=wo.dot(TC),u=ql.dot(ql),d=ql.dot(TC),f=s*u-o*o;if(f===0)return a.set(0,0,0),null;const g=1/f,m=(u*c-o*d)*g,b=(s*d-o*c)*g;return a.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Kl)===null?!1:Kl.x>=0&&Kl.y>=0&&Kl.x+Kl.y<=1}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,Kl)===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,Kl.x),c.addScaledVector(s,Kl.y),c.addScaledVector(o,Kl.z),c)}static getInterpolatedAttribute(e,n,r,i,a,s){return PC.setScalar(0),RC.setScalar(0),DC.setScalar(0),PC.fromBufferAttribute(e,n),RC.fromBufferAttribute(e,r),DC.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(PC,a.x),s.addScaledVector(RC,a.y),s.addScaledVector(DC,a.z),s}static isFrontFacing(e,n,r,i){return wo.subVectors(r,n),ql.subVectors(e,n),wo.cross(ql).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 wo.subVectors(this.c,this.b),ql.subVectors(this.a,this.b),wo.cross(ql).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Fp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Fp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Fp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Fp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Fp.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 s,o;lp.subVectors(i,r),cp.subVectors(a,r),CC.subVectors(e,r);const c=lp.dot(CC),u=cp.dot(CC);if(c<=0&&u<=0)return n.copy(r);NC.subVectors(e,i);const d=lp.dot(NC),f=cp.dot(NC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return s=c/(c-d),n.copy(r).addScaledVector(lp,s);kC.subVectors(e,a);const m=lp.dot(kC),b=cp.dot(kC);if(b>=0&&m<=b)return n.copy(a);const y=m*u-c*b;if(y<=0&&u>=0&&b<=0)return o=u/(u-b),n.copy(r).addScaledVector(cp,o);const v=d*b-m*f;if(v<=0&&f-d>=0&&m-b>=0)return Q6.subVectors(a,i),o=(f-d)/(f-d+(m-b)),n.copy(i).addScaledVector(Q6,o);const x=1/(v+y+g);return s=y*x,o=g*x,n.copy(r).addScaledVector(lp,s).addScaledVector(cp,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const sZ={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},xu={h:0,s:0,l:0},$v={h:0,s:0,l:0};function jC(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 _n=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=qs){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Cn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Cn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Cn.workingColorSpace){if(e=mNe(e,1),n=gn(n,0,1),r=gn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=jC(s,a,e+1/3),this.g=jC(s,a,e),this.b=jC(s,a,e-1/3)}return Cn.colorSpaceToWorking(this,i),this}setStyle(e,n=qs){function r(a){a!==void 0&&parseFloat(a)<1&&Yt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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(o))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(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:Yt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);Yt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=qs){const r=sZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Yt("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=Sc(e.r),this.g=Sc(e.g),this.b=Sc(e.b),this}copyLinearToSRGB(e){return this.r=im(e.r),this.g=im(e.g),this.b=im(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=qs){return Cn.workingToColorSpace(sa.copy(this),e),Math.round(gn(sa.r*255,0,255))*65536+Math.round(gn(sa.g*255,0,255))*256+Math.round(gn(sa.b*255,0,255))}getHexString(e=qs){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Cn.workingColorSpace){Cn.workingToColorSpace(sa.copy(this),n);const r=sa.r,i=sa.g,a=sa.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const d=(o+s)/2;if(o===s)c=0,u=0;else{const f=s-o;switch(u=d<=.5?f/(s+o):f/(2-s-o),s){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=Cn.workingColorSpace){return Cn.workingToColorSpace(sa.copy(this),n),e.r=sa.r,e.g=sa.g,e.b=sa.b,e}getStyle(e=qs){Cn.workingToColorSpace(sa.copy(this),e);const n=sa.r,r=sa.g,i=sa.b;return e!==qs?`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(xu),this.setHSL(xu.h+e,xu.s+n,xu.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(xu),e.getHSL($v);const r=gC(xu.h,$v.h,n),i=gC(xu.s,$v.s,n),a=gC(xu.l,$v.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 _n;_n.NAMES=sZ;let kNe=0,og=class extends pf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:kNe++}),this.uuid=Wb(),this.name="",this.type="Material",this.blending=rm,this.side=dd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=U3,this.blendDst=z3,this.blendEquation=oh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _n(0,0,0),this.blendAlpha=0,this.depthFunc=Am,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=I6,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ep,this.stencilZFail=ep,this.stencilZPass=ep,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){Yt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`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!==rm&&(r.blending=this.blending),this.side!==dd&&(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!==U3&&(r.blendSrc=this.blendSrc),this.blendDst!==z3&&(r.blendDst=this.blendDst),this.blendEquation!==oh&&(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!==Am&&(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!==I6&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ep&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ep&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ep&&(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 s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}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++}},cO=class extends og{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _n(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 hd,this.combine=Jj,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 qr=new Je,Vv=new cn;let PNe=0,io=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:PNe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=F6,this.updateRanges=[],this.gpuType=gc,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++)Vv.fromBufferAttribute(this,n),Vv.applyMatrix3(e),this.setXY(n,Vv.x,Vv.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyMatrix3(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyMatrix4(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyNormalMatrix(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.transformDirection(e),this.setXYZ(n,qr.x,qr.y,qr.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=mx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=za(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=mx(n,this.array)),n}setX(e,n){return this.normalized&&(n=za(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=mx(n,this.array)),n}setY(e,n){return this.normalized&&(n=za(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=mx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=za(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=mx(n,this.array)),n}setW(e,n){return this.normalized&&(n=za(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=za(n,this.array),r=za(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=za(n,this.array),r=za(r,this.array),i=za(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=za(n,this.array),r=za(r,this.array),i=za(i,this.array),a=za(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!==F6&&(e.usage=this.usage),e}},oZ=class extends io{constructor(e,n,r){super(new Uint16Array(e),n,r)}},lZ=class extends io{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Io=class extends io{constructor(e,n,r){super(new Float32Array(e),n,r)}},RNe=0;const zs=new ri,OC=new Ns,up=new Je,us=new tf,vx=new tf,Ni=new Je;let El=class cZ extends pf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:RNe++}),this.uuid=Wb(),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(QY(e)?lZ:oZ)(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 dn().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 zs.makeRotationFromQuaternion(e),this.applyMatrix4(zs),this}rotateX(e){return zs.makeRotationX(e),this.applyMatrix4(zs),this}rotateY(e){return zs.makeRotationY(e),this.applyMatrix4(zs),this}rotateZ(e){return zs.makeRotationZ(e),this.applyMatrix4(zs),this}translate(e,n,r){return zs.makeTranslation(e,n,r),this.applyMatrix4(zs),this}scale(e,n,r){return zs.makeScale(e,n,r),this.applyMatrix4(zs),this}lookAt(e){return OC.lookAt(e),OC.updateMatrix(),this.applyMatrix4(OC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(up).negate(),this.translate(up.x,up.y,up.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Io(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&&Yt("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 tf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Je(-1/0,-1/0,-1/0),new Je(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];us.setFromBufferAttribute(a),this.morphTargetsRelative?(Ni.addVectors(this.boundingBox.min,us.min),this.boundingBox.expandByPoint(Ni),Ni.addVectors(this.boundingBox.max,us.max),this.boundingBox.expandByPoint(Ni)):(this.boundingBox.expandByPoint(us.min),this.boundingBox.expandByPoint(us.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&zr('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 UM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Je,1/0);return}if(e){const r=this.boundingSphere.center;if(us.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];vx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ni.addVectors(us.min,vx.min),us.expandByPoint(Ni),Ni.addVectors(us.max,vx.max),us.expandByPoint(Ni)):(us.expandByPoint(vx.min),us.expandByPoint(vx.max))}us.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Ni.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ni));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ni.fromBufferAttribute(o,u),c&&(up.fromBufferAttribute(e,u),Ni.add(up)),i=Math.max(i,r.distanceToSquared(Ni))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zr('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){zr("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 io(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),o=[],c=[];for(let I=0;I<r.count;I++)o[I]=new Je,c[I]=new Je;const u=new Je,d=new Je,f=new Je,g=new cn,m=new cn,b=new cn,y=new Je,v=new Je;function x(I,C,D){u.fromBufferAttribute(r,I),d.fromBufferAttribute(r,C),f.fromBufferAttribute(r,D),g.fromBufferAttribute(a,I),m.fromBufferAttribute(a,C),b.fromBufferAttribute(a,D),d.sub(u),f.sub(u),m.sub(g),b.sub(g);const F=1/(m.x*b.y-b.x*m.y);isFinite(F)&&(y.copy(d).multiplyScalar(b.y).addScaledVector(f,-m.y).multiplyScalar(F),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-b.x).multiplyScalar(F),o[I].add(y),o[C].add(y),o[D].add(y),c[I].add(v),c[C].add(v),c[D].add(v))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let I=0,C=M.length;I<C;++I){const D=M[I],F=D.start,O=D.count;for(let q=F,R=F+O;q<R;q+=3)x(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const S=new Je,A=new Je,T=new Je,k=new Je;function N(I){T.fromBufferAttribute(i,I),k.copy(T);const C=o[I];S.copy(C),S.sub(T.multiplyScalar(T.dot(C))).normalize(),A.crossVectors(k,C);const F=A.dot(c[I])<0?-1:1;s.setXYZW(I,S.x,S.y,S.z,F)}for(let I=0,C=M.length;I<C;++I){const D=M[I],F=D.start,O=D.count;for(let q=F,R=F+O;q<R;q+=3)N(e.getX(q+0)),N(e.getX(q+1)),N(e.getX(q+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new io(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Je,a=new Je,s=new Je,o=new Je,c=new Je,u=new Je,d=new Je,f=new Je;if(e)for(let g=0,m=e.count;g<m;g+=3){const b=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),s.fromBufferAttribute(n,v),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),o.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),c.add(d),u.add(d),r.setXYZ(b,o.x,o.y,o.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(v,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ni.fromBufferAttribute(e,n),Ni.normalize(),e.setXYZ(n,Ni.x,Ni.y,Ni.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let m=0,b=0;for(let y=0,v=c.length;y<v;y++){o.isInterleavedBufferAttribute?m=c[y]*o.data.stride+o.offset:m=c[y]*d;for(let x=0;x<d;x++)g[b++]=u[m++]}return new io(g,d,f)}if(this.index===null)return Yt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new cZ,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);c.push(m)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.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 J6=new ri,Gd=new lO,Gv=new UM,eH=new Je,Wv=new Je,qv=new Je,Kv=new Je,LC=new Je,Xv=new Je,tH=new Je,Yv=new Je;let xl=class extends Ns{constructor(e=new El,n=new cO){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,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){Xv.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=o[c],f=a[c];d!==0&&(LC.fromBufferAttribute(f,e),s?Xv.addScaledVector(LC,d):Xv.addScaledVector(LC.sub(n),d))}n.add(Xv)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Gv.copy(r.boundingSphere),Gv.applyMatrix4(a),Gd.copy(e.ray).recast(e.near),!(Gv.containsPoint(Gd.origin)===!1&&(Gd.intersectSphere(Gv,eH)===null||Gd.origin.distanceToSquared(eH)>(e.far-e.near)**2))&&(J6.copy(a).invert(),Gd.copy(e.ray).applyMatrix4(J6),!(r.boundingBox!==null&&Gd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Gd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),S=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=Zv(this,x,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=o.getX(v),S=o.getX(v+1),A=o.getX(v+2);i=Zv(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),S=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=A,N=A+1,I=A+2;i=Zv(this,x,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=v,S=v+1,A=v+2;i=Zv(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function DNe(t,e,n,r,i,a,s,o){let c;if(e.side===qa?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===dd,o),c===null)return null;Yv.copy(o),Yv.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Yv);return u<n.near||u>n.far?null:{distance:u,point:Yv.clone(),object:t}}function Zv(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Wv),t.getVertexPosition(c,qv),t.getVertexPosition(u,Kv);const d=DNe(t,e,n,r,Wv,qv,Kv,tH);if(d){const f=new Je;yx.getBarycoord(tH,Wv,qv,Kv,f),i&&(d.uv=yx.getInterpolatedAttribute(i,o,c,u,f,new cn)),a&&(d.uv1=yx.getInterpolatedAttribute(a,o,c,u,f,new cn)),s&&(d.normal=yx.getInterpolatedAttribute(s,o,c,u,f,new Je),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:c,c:u,normal:new Je,materialIndex:0};yx.getNormal(Wv,qv,Kv,g.normal),d.face=g,d.barycoord=f}return d}let uO=class uZ extends El{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,m=0;b("z","y","x",-1,-1,r,n,e,s,a,0),b("z","y","x",1,-1,r,n,-e,s,a,1),b("x","z","y",1,1,e,r,n,i,s,2),b("x","z","y",1,-1,e,r,-n,i,s,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Io(u,3)),this.setAttribute("normal",new Io(d,3)),this.setAttribute("uv",new Io(f,2));function b(y,v,x,M,S,A,T,k,N,I,C){const D=A/N,F=T/I,O=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let G=0,ee=0;const Z=new Je;for(let Q=0;Q<K;Q++){const U=Q*F-q;for(let $=0;$<W;$++){const X=$*D-O;Z[y]=X*M,Z[v]=U*S,Z[x]=R,u.push(Z.x,Z.y,Z.z),Z[y]=0,Z[v]=0,Z[x]=k>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push($/N),f.push(1-Q/I),G+=1}}for(let Q=0;Q<I;Q++)for(let U=0;U<N;U++){const $=g+U+W*Q,X=g+U+W*(Q+1),te=g+(U+1)+W*(Q+1),fe=g+(U+1)+W*Q;c.push($,X,fe),c.push(X,te,fe),ee+=6}o.addGroup(m,ee,C),m+=ee,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function km(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?(Yt("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 va(t){const e={};for(let n=0;n<t.length;n++){const r=km(t[n]);for(const i in r)e[i]=r[i]}return e}function jNe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function dZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Cn.workingColorSpace}const ONe={clone:km,merge:va};var LNe=`void main() {
  46. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  47. }`,INe=`void main() {
  48. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  49. }`;let Lc=class extends og{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=LNe,this.fragmentShader=INe,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=km(e.uniforms),this.uniformsGroups=jNe(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 s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}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}},hZ=class extends Ns{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ri,this.projectionMatrix=new ri,this.projectionMatrixInverse=new ri,this.coordinateSystem=ol,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 bu=new Je,nH=new cn,rH=new cn;let Ys=class extends hZ{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=AP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(u1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return AP*2*Math.atan(Math.tan(u1*.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){bu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(bu.x,bu.y).multiplyScalar(-e/bu.z),bu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(bu.x,bu.y).multiplyScalar(-e/bu.z)}getViewSize(e,n){return this.getViewBounds(e,nH,rH),n.subVectors(rH,nH)}setViewOffset(e,n,r,i,a,s){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=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(u1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const o=this.filmOffset;o!==0&&(a+=e*o/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 dp=-90,hp=1;let FNe=class extends Ns{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ys(dp,hp,e,n);i.layers=this.layers,this.add(i);const a=new Ys(dp,hp,e,n);a.layers=this.layers,this.add(a);const s=new Ys(dp,hp,e,n);s.layers=this.layers,this.add(s);const o=new Ys(dp,hp,e,n);o.layers=this.layers,this.add(o);const c=new Ys(dp,hp,e,n);c.layers=this.layers,this.add(c);const u=new Ys(dp,hp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,c]=n;for(const u of n)this.remove(u);if(e===ol)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),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Nw)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),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.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,s,o,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},fZ=class extends $o{constructor(e=[],n=Tm,r,i,a,s,o,c,u,d){super(e,n,r,i,a,s,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},UNe=class extends ef{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 fZ(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:`
  50. varying vec3 vWorldDirection;
  51. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  52. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  53. }
  54. void main() {
  55. vWorldDirection = transformDirection( position, modelMatrix );
  56. #include <begin_vertex>
  57. #include <project_vertex>
  58. }
  59. `,fragmentShader:`
  60. uniform sampler2D tEquirect;
  61. varying vec3 vWorldDirection;
  62. #include <common>
  63. void main() {
  64. vec3 direction = normalize( vWorldDirection );
  65. vec2 sampleUV = equirectUv( direction );
  66. gl_FragColor = texture2D( tEquirect, sampleUV );
  67. }
  68. `},i=new uO(5,5,5),a=new Lc({name:"CubemapFromEquirect",uniforms:km(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:qa,blending:wc});a.uniforms.tEquirect.value=n;const s=new xl(i,a),o=n.minFilter;return n.minFilter===xh&&(n.minFilter=ro),new FNe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}},Lx=class extends Ns{constructor(){super(),this.isGroup=!0,this.type="Group"}};const zNe={type:"move"};let IC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lx,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 Lx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Je,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Je),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Je,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Je),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,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),x=this._getHandJoint(u,y);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),m=.02,b=.005;u.inputState.pinching&&g>m+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=m-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(zNe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Lx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},BNe=class extends Ns{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 hd,this.environmentIntensity=1,this.environmentRotation=new hd,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}},HNe=class extends $o{constructor(e=null,n=1,r=1,i,a,s,o,c,u=ws,d=ws,f,g){super(null,s,o,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const FC=new Je,$Ne=new Je,VNe=new dn;let ku=class{constructor(e=new Je(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=FC.subVectors(r,n).cross($Ne.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(FC),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||VNe.getNormalMatrix(e),i=this.coplanarPoint(FC).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 Wd=new UM,GNe=new cn(.5,.5),Qv=new Je;let dO=class{constructor(e=new ku,n=new ku,r=new ku,i=new ku,a=new ku,s=new ku){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),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=ol,r=!1){const i=this.planes,a=e.elements,s=a[0],o=a[1],c=a[2],u=a[3],d=a[4],f=a[5],g=a[6],m=a[7],b=a[8],y=a[9],v=a[10],x=a[11],M=a[12],S=a[13],A=a[14],T=a[15];if(i[0].setComponents(u-s,m-d,x-b,T-M).normalize(),i[1].setComponents(u+s,m+d,x+b,T+M).normalize(),i[2].setComponents(u+o,m+f,x+y,T+S).normalize(),i[3].setComponents(u-o,m-f,x-y,T-S).normalize(),r)i[4].setComponents(c,g,v,A).normalize(),i[5].setComponents(u-c,m-g,x-v,T-A).normalize();else if(i[4].setComponents(u-c,m-g,x-v,T-A).normalize(),n===ol)i[5].setComponents(u+c,m+g,x+v,T+A).normalize();else if(n===Nw)i[5].setComponents(c,g,v,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(),Wd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Wd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Wd)}intersectsSprite(e){Wd.center.set(0,0,0);const n=GNe.distanceTo(e.center);return Wd.radius=.7071067811865476+n,Wd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wd)}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(Qv.x=i.normal.x>0?e.max.x:e.min.x,Qv.y=i.normal.y>0?e.max.y:e.min.y,Qv.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Qv)<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)}},pZ=class extends og{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _n(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 Pw=new Je,Rw=new Je,iH=new ri,_x=new lO,Jv=new UM,UC=new Je,aH=new Je;let WNe=class extends Ns{constructor(e=new El,n=new pZ){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++)Pw.fromBufferAttribute(n,i-1),Rw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Pw.distanceTo(Rw);e.setAttribute("lineDistance",new Io(r,1))}else Yt("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,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Jv.copy(r.boundingSphere),Jv.applyMatrix4(i),Jv.radius+=a,e.ray.intersectsSphere(Jv)===!1)return;iH.copy(i).invert(),_x.copy(e.ray).applyMatrix4(iH);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const m=Math.max(0,s.start),b=Math.min(d.count,s.start+s.count);for(let y=m,v=b-1;y<v;y+=u){const x=d.getX(y),M=d.getX(y+1),S=e_(this,e,_x,c,x,M,y);S&&n.push(S)}if(this.isLineLoop){const y=d.getX(b-1),v=d.getX(m),x=e_(this,e,_x,c,y,v,b-1);x&&n.push(x)}}else{const m=Math.max(0,s.start),b=Math.min(g.count,s.start+s.count);for(let y=m,v=b-1;y<v;y+=u){const x=e_(this,e,_x,c,y,y+1,y);x&&n.push(x)}if(this.isLineLoop){const y=e_(this,e,_x,c,b-1,m,b-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function e_(t,e,n,r,i,a,s){const o=t.geometry.attributes.position;if(Pw.fromBufferAttribute(o,i),Rw.fromBufferAttribute(o,a),n.distanceSqToSegment(Pw,Rw,UC,aH)>r)return;UC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(UC);if(!(u<e.near||u>e.far))return{distance:u,point:aH.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const sH=new Je,oH=new Je;let qNe=class extends WNe{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)sH.fromBufferAttribute(n,i),oH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+sH.distanceTo(oH);e.setAttribute("lineDistance",new Io(r,1))}else Yt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},mZ=class extends $o{constructor(e,n,r=Qh,i,a,s,o=ws,c=ws,u,d=G0,f=1){if(d!==G0&&d!==W0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,a,s,o,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 oO(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 gZ extends $o{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let hO=class xZ extends El{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,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,m=[],b=[],y=[],v=[];for(let x=0;x<d;x++){const M=x*g-s;for(let S=0;S<u;S++){const A=S*f-a;b.push(A,-M,0),y.push(0,0,1),v.push(S/o),v.push(1-x/c)}}for(let x=0;x<c;x++)for(let M=0;M<o;M++){const S=M+u*x,A=M+u*(x+1),T=M+1+u*(x+1),k=M+1+u*x;m.push(S,A,k),m.push(A,T,k)}this.setIndex(m),this.setAttribute("position",new Io(b,3)),this.setAttribute("normal",new Io(y,3)),this.setAttribute("uv",new Io(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class KNe extends og{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _n(16777215),this.specular=new _n(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=YY,this.normalScale=new cn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hd,this.combine=Jj,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 XNe=class extends og{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rNe,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}},YNe=class extends og{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}},bZ=class extends Ns{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new _n(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 zC=new ri,lH=new Je,cH=new Je;let ZNe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new cn(512,512),this.mapType=gl,this.map=null,this.mapPass=null,this.matrix=new ri,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new dO,this._frameExtents=new cn(1,1),this._viewportCount=1,this._viewports=[new Yr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;lH.setFromMatrixPosition(e.matrixWorld),n.position.copy(lH),cH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(cH),n.updateMatrixWorld(),zC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zC,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(zC)}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}},yZ=class extends hZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=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=s,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,s){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=s,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,s=r+e,o=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,s=a+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,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 QNe extends ZNe{constructor(){super(new yZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class uH extends bZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ns.DEFAULT_UP),this.updateMatrix(),this.target=new Ns,this.shadow=new QNe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let JNe=class extends bZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},eke=class extends Ys{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},dH=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=gn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(gn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class tke extends qNe{constructor(e=10,n=10,r=4473924,i=8947848){r=new _n(r),i=new _n(i);const a=n/2,s=e/n,o=e/2,c=[],u=[];for(let g=0,m=0,b=-o;g<=n;g++,b+=s){c.push(-o,0,b,o,0,b),c.push(b,0,-o,b,0,o);const y=g===a?r:i;y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3}const d=new El;d.setAttribute("position",new Io(c,3)),d.setAttribute("color",new Io(u,3));const f=new pZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class nke extends pf{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){Yt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function hH(t,e,n,r){const i=rke(r);switch(n){case qY:return t*e;case XY:return t*e/i.components*i.byteLength;case rO:return t*e/i.components*i.byteLength;case iO:return t*e*2/i.components*i.byteLength;case aO:return t*e*2/i.components*i.byteLength;case KY:return t*e*3/i.components*i.byteLength;case Do:return t*e*4/i.components*i.byteLength;case sO:return t*e*4/i.components*i.byteLength;case s1:case o1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case l1:case c1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case J3:case tP:return Math.max(t,16)*Math.max(e,8)/4;case Q3:case eP:return Math.max(t,8)*Math.max(e,8)/2;case nP:case rP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case iP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case aP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case sP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case oP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case lP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case cP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case uP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case dP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case hP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case fP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case pP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case mP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case gP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case xP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case bP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case yP:case vP:case _P:return Math.ceil(t/4)*Math.ceil(e/4)*16;case wP:case SP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case MP:case EP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function rke(t){switch(t){case gl:case $Y:return{byteLength:1,components:1};case $0:case VY:case sg:return{byteLength:2,components:1};case tO:case nO:return{byteLength:2,components:4};case Qh:case eO:case gc:return{byteLength:4,components:1};case GY:case WY:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Qj}}));typeof window<"u"&&(window.__THREE__?Yt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Qj);function vZ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),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 ike(t){const e=new WeakMap;function n(o,c){const u=o.array,d=o.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(c,g),t.bufferData(c,u,d),o.onUploadCallback();let m;if(u instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)m=t.HALF_FLOAT;else if(u instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=t.SHORT;else if(u instanceof Uint32Array)m=t.UNSIGNED_INT;else if(u instanceof Int32Array)m=t.INT;else if(u instanceof Int8Array)m=t.BYTE;else if(u instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:o.version,size:f}}function r(o,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,o),f.length===0)t.bufferSubData(u,0,d);else{f.sort((m,b)=>m.start-b.start);let g=0;for(let m=1;m<f.length;m++){const b=f[g],y=f[m];y.start<=b.start+b.count+1?b.count=Math.max(b.count,y.start+y.count-b.start):(++g,f[g]=y)}f.length=g+1;for(let m=0,b=f.length;m<b;m++){const y=f[m];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(t.deleteBuffer(c.buffer),e.delete(o))}function s(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const u=e.get(o);if(u===void 0)e.set(o,n(o,c));else if(u.version<o.version){if(u.size!==o.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,o,c),u.version=o.version}}return{get:i,remove:a,update:s}}var ake=`#ifdef USE_ALPHAHASH
  69. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  70. #endif`,ske=`#ifdef USE_ALPHAHASH
  71. const float ALPHA_HASH_SCALE = 0.05;
  72. float hash2D( vec2 value ) {
  73. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  74. }
  75. float hash3D( vec3 value ) {
  76. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  77. }
  78. float getAlphaHashThreshold( vec3 position ) {
  79. float maxDeriv = max(
  80. length( dFdx( position.xyz ) ),
  81. length( dFdy( position.xyz ) )
  82. );
  83. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  84. vec2 pixScales = vec2(
  85. exp2( floor( log2( pixScale ) ) ),
  86. exp2( ceil( log2( pixScale ) ) )
  87. );
  88. vec2 alpha = vec2(
  89. hash3D( floor( pixScales.x * position.xyz ) ),
  90. hash3D( floor( pixScales.y * position.xyz ) )
  91. );
  92. float lerpFactor = fract( log2( pixScale ) );
  93. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  94. float a = min( lerpFactor, 1.0 - lerpFactor );
  95. vec3 cases = vec3(
  96. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  97. ( x - 0.5 * a ) / ( 1.0 - a ),
  98. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  99. );
  100. float threshold = ( x < ( 1.0 - a ) )
  101. ? ( ( x < a ) ? cases.x : cases.y )
  102. : cases.z;
  103. return clamp( threshold , 1.0e-6, 1.0 );
  104. }
  105. #endif`,oke=`#ifdef USE_ALPHAMAP
  106. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  107. #endif`,lke=`#ifdef USE_ALPHAMAP
  108. uniform sampler2D alphaMap;
  109. #endif`,cke=`#ifdef USE_ALPHATEST
  110. #ifdef ALPHA_TO_COVERAGE
  111. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  112. if ( diffuseColor.a == 0.0 ) discard;
  113. #else
  114. if ( diffuseColor.a < alphaTest ) discard;
  115. #endif
  116. #endif`,uke=`#ifdef USE_ALPHATEST
  117. uniform float alphaTest;
  118. #endif`,dke=`#ifdef USE_AOMAP
  119. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  120. reflectedLight.indirectDiffuse *= ambientOcclusion;
  121. #if defined( USE_CLEARCOAT )
  122. clearcoatSpecularIndirect *= ambientOcclusion;
  123. #endif
  124. #if defined( USE_SHEEN )
  125. sheenSpecularIndirect *= ambientOcclusion;
  126. #endif
  127. #if defined( USE_ENVMAP ) && defined( STANDARD )
  128. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  129. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  130. #endif
  131. #endif`,hke=`#ifdef USE_AOMAP
  132. uniform sampler2D aoMap;
  133. uniform float aoMapIntensity;
  134. #endif`,fke=`#ifdef USE_BATCHING
  135. #if ! defined( GL_ANGLE_multi_draw )
  136. #define gl_DrawID _gl_DrawID
  137. uniform int _gl_DrawID;
  138. #endif
  139. uniform highp sampler2D batchingTexture;
  140. uniform highp usampler2D batchingIdTexture;
  141. mat4 getBatchingMatrix( const in float i ) {
  142. int size = textureSize( batchingTexture, 0 ).x;
  143. int j = int( i ) * 4;
  144. int x = j % size;
  145. int y = j / size;
  146. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  147. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  148. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  149. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  150. return mat4( v1, v2, v3, v4 );
  151. }
  152. float getIndirectIndex( const in int i ) {
  153. int size = textureSize( batchingIdTexture, 0 ).x;
  154. int x = i % size;
  155. int y = i / size;
  156. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  157. }
  158. #endif
  159. #ifdef USE_BATCHING_COLOR
  160. uniform sampler2D batchingColorTexture;
  161. vec3 getBatchingColor( const in float i ) {
  162. int size = textureSize( batchingColorTexture, 0 ).x;
  163. int j = int( i );
  164. int x = j % size;
  165. int y = j / size;
  166. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  167. }
  168. #endif`,pke=`#ifdef USE_BATCHING
  169. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  170. #endif`,mke=`vec3 transformed = vec3( position );
  171. #ifdef USE_ALPHAHASH
  172. vPosition = vec3( position );
  173. #endif`,gke=`vec3 objectNormal = vec3( normal );
  174. #ifdef USE_TANGENT
  175. vec3 objectTangent = vec3( tangent.xyz );
  176. #endif`,xke=`float G_BlinnPhong_Implicit( ) {
  177. return 0.25;
  178. }
  179. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  180. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  181. }
  182. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  183. vec3 halfDir = normalize( lightDir + viewDir );
  184. float dotNH = saturate( dot( normal, halfDir ) );
  185. float dotVH = saturate( dot( viewDir, halfDir ) );
  186. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  187. float G = G_BlinnPhong_Implicit( );
  188. float D = D_BlinnPhong( shininess, dotNH );
  189. return F * ( G * D );
  190. } // validated`,bke=`#ifdef USE_IRIDESCENCE
  191. const mat3 XYZ_TO_REC709 = mat3(
  192. 3.2404542, -0.9692660, 0.0556434,
  193. -1.5371385, 1.8760108, -0.2040259,
  194. -0.4985314, 0.0415560, 1.0572252
  195. );
  196. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  197. vec3 sqrtF0 = sqrt( fresnel0 );
  198. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  199. }
  200. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  201. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  202. }
  203. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  204. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  205. }
  206. vec3 evalSensitivity( float OPD, vec3 shift ) {
  207. float phase = 2.0 * PI * OPD * 1.0e-9;
  208. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  209. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  210. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  211. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  212. 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 ) );
  213. xyz /= 1.0685e-7;
  214. vec3 rgb = XYZ_TO_REC709 * xyz;
  215. return rgb;
  216. }
  217. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  218. vec3 I;
  219. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  220. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  221. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  222. if ( cosTheta2Sq < 0.0 ) {
  223. return vec3( 1.0 );
  224. }
  225. float cosTheta2 = sqrt( cosTheta2Sq );
  226. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  227. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  228. float T121 = 1.0 - R12;
  229. float phi12 = 0.0;
  230. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  231. float phi21 = PI - phi12;
  232. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  233. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  234. vec3 phi23 = vec3( 0.0 );
  235. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  236. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  237. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  238. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  239. vec3 phi = vec3( phi21 ) + phi23;
  240. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  241. vec3 r123 = sqrt( R123 );
  242. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  243. vec3 C0 = R12 + Rs;
  244. I = C0;
  245. vec3 Cm = Rs - T121;
  246. for ( int m = 1; m <= 2; ++ m ) {
  247. Cm *= r123;
  248. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  249. I += Cm * Sm;
  250. }
  251. return max( I, vec3( 0.0 ) );
  252. }
  253. #endif`,yke=`#ifdef USE_BUMPMAP
  254. uniform sampler2D bumpMap;
  255. uniform float bumpScale;
  256. vec2 dHdxy_fwd() {
  257. vec2 dSTdx = dFdx( vBumpMapUv );
  258. vec2 dSTdy = dFdy( vBumpMapUv );
  259. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  260. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  261. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  262. return vec2( dBx, dBy );
  263. }
  264. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  265. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  266. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  267. vec3 vN = surf_norm;
  268. vec3 R1 = cross( vSigmaY, vN );
  269. vec3 R2 = cross( vN, vSigmaX );
  270. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  271. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  272. return normalize( abs( fDet ) * surf_norm - vGrad );
  273. }
  274. #endif`,vke=`#if NUM_CLIPPING_PLANES > 0
  275. vec4 plane;
  276. #ifdef ALPHA_TO_COVERAGE
  277. float distanceToPlane, distanceGradient;
  278. float clipOpacity = 1.0;
  279. #pragma unroll_loop_start
  280. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  281. plane = clippingPlanes[ i ];
  282. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  283. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  284. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  285. if ( clipOpacity == 0.0 ) discard;
  286. }
  287. #pragma unroll_loop_end
  288. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  289. float unionClipOpacity = 1.0;
  290. #pragma unroll_loop_start
  291. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  292. plane = clippingPlanes[ i ];
  293. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  294. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  295. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  296. }
  297. #pragma unroll_loop_end
  298. clipOpacity *= 1.0 - unionClipOpacity;
  299. #endif
  300. diffuseColor.a *= clipOpacity;
  301. if ( diffuseColor.a == 0.0 ) discard;
  302. #else
  303. #pragma unroll_loop_start
  304. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  305. plane = clippingPlanes[ i ];
  306. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  307. }
  308. #pragma unroll_loop_end
  309. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  310. bool clipped = true;
  311. #pragma unroll_loop_start
  312. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  313. plane = clippingPlanes[ i ];
  314. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  315. }
  316. #pragma unroll_loop_end
  317. if ( clipped ) discard;
  318. #endif
  319. #endif
  320. #endif`,_ke=`#if NUM_CLIPPING_PLANES > 0
  321. varying vec3 vClipPosition;
  322. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  323. #endif`,wke=`#if NUM_CLIPPING_PLANES > 0
  324. varying vec3 vClipPosition;
  325. #endif`,Ske=`#if NUM_CLIPPING_PLANES > 0
  326. vClipPosition = - mvPosition.xyz;
  327. #endif`,Mke=`#if defined( USE_COLOR_ALPHA )
  328. diffuseColor *= vColor;
  329. #elif defined( USE_COLOR )
  330. diffuseColor.rgb *= vColor;
  331. #endif`,Eke=`#if defined( USE_COLOR_ALPHA )
  332. varying vec4 vColor;
  333. #elif defined( USE_COLOR )
  334. varying vec3 vColor;
  335. #endif`,Ake=`#if defined( USE_COLOR_ALPHA )
  336. varying vec4 vColor;
  337. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  338. varying vec3 vColor;
  339. #endif`,Tke=`#if defined( USE_COLOR_ALPHA )
  340. vColor = vec4( 1.0 );
  341. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  342. vColor = vec3( 1.0 );
  343. #endif
  344. #ifdef USE_COLOR
  345. vColor *= color;
  346. #endif
  347. #ifdef USE_INSTANCING_COLOR
  348. vColor.xyz *= instanceColor.xyz;
  349. #endif
  350. #ifdef USE_BATCHING_COLOR
  351. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  352. vColor.xyz *= batchingColor.xyz;
  353. #endif`,Cke=`#define PI 3.141592653589793
  354. #define PI2 6.283185307179586
  355. #define PI_HALF 1.5707963267948966
  356. #define RECIPROCAL_PI 0.3183098861837907
  357. #define RECIPROCAL_PI2 0.15915494309189535
  358. #define EPSILON 1e-6
  359. #ifndef saturate
  360. #define saturate( a ) clamp( a, 0.0, 1.0 )
  361. #endif
  362. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  363. float pow2( const in float x ) { return x*x; }
  364. vec3 pow2( const in vec3 x ) { return x*x; }
  365. float pow3( const in float x ) { return x*x*x; }
  366. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  367. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  368. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  369. highp float rand( const in vec2 uv ) {
  370. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  371. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  372. return fract( sin( sn ) * c );
  373. }
  374. #ifdef HIGH_PRECISION
  375. float precisionSafeLength( vec3 v ) { return length( v ); }
  376. #else
  377. float precisionSafeLength( vec3 v ) {
  378. float maxComponent = max3( abs( v ) );
  379. return length( v / maxComponent ) * maxComponent;
  380. }
  381. #endif
  382. struct IncidentLight {
  383. vec3 color;
  384. vec3 direction;
  385. bool visible;
  386. };
  387. struct ReflectedLight {
  388. vec3 directDiffuse;
  389. vec3 directSpecular;
  390. vec3 indirectDiffuse;
  391. vec3 indirectSpecular;
  392. };
  393. #ifdef USE_ALPHAHASH
  394. varying vec3 vPosition;
  395. #endif
  396. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  397. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  398. }
  399. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  400. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  401. }
  402. bool isPerspectiveMatrix( mat4 m ) {
  403. return m[ 2 ][ 3 ] == - 1.0;
  404. }
  405. vec2 equirectUv( in vec3 dir ) {
  406. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  407. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  408. return vec2( u, v );
  409. }
  410. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  411. return RECIPROCAL_PI * diffuseColor;
  412. }
  413. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  414. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  415. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  416. }
  417. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  418. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  419. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  420. } // validated`,Nke=`#ifdef ENVMAP_TYPE_CUBE_UV
  421. #define cubeUV_minMipLevel 4.0
  422. #define cubeUV_minTileSize 16.0
  423. float getFace( vec3 direction ) {
  424. vec3 absDirection = abs( direction );
  425. float face = - 1.0;
  426. if ( absDirection.x > absDirection.z ) {
  427. if ( absDirection.x > absDirection.y )
  428. face = direction.x > 0.0 ? 0.0 : 3.0;
  429. else
  430. face = direction.y > 0.0 ? 1.0 : 4.0;
  431. } else {
  432. if ( absDirection.z > absDirection.y )
  433. face = direction.z > 0.0 ? 2.0 : 5.0;
  434. else
  435. face = direction.y > 0.0 ? 1.0 : 4.0;
  436. }
  437. return face;
  438. }
  439. vec2 getUV( vec3 direction, float face ) {
  440. vec2 uv;
  441. if ( face == 0.0 ) {
  442. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  443. } else if ( face == 1.0 ) {
  444. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  445. } else if ( face == 2.0 ) {
  446. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  447. } else if ( face == 3.0 ) {
  448. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  449. } else if ( face == 4.0 ) {
  450. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  451. } else {
  452. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  453. }
  454. return 0.5 * ( uv + 1.0 );
  455. }
  456. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  457. float face = getFace( direction );
  458. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  459. mipInt = max( mipInt, cubeUV_minMipLevel );
  460. float faceSize = exp2( mipInt );
  461. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  462. if ( face > 2.0 ) {
  463. uv.y += faceSize;
  464. face -= 3.0;
  465. }
  466. uv.x += face * faceSize;
  467. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  468. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  469. uv.x *= CUBEUV_TEXEL_WIDTH;
  470. uv.y *= CUBEUV_TEXEL_HEIGHT;
  471. #ifdef texture2DGradEXT
  472. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  473. #else
  474. return texture2D( envMap, uv ).rgb;
  475. #endif
  476. }
  477. #define cubeUV_r0 1.0
  478. #define cubeUV_m0 - 2.0
  479. #define cubeUV_r1 0.8
  480. #define cubeUV_m1 - 1.0
  481. #define cubeUV_r4 0.4
  482. #define cubeUV_m4 2.0
  483. #define cubeUV_r5 0.305
  484. #define cubeUV_m5 3.0
  485. #define cubeUV_r6 0.21
  486. #define cubeUV_m6 4.0
  487. float roughnessToMip( float roughness ) {
  488. float mip = 0.0;
  489. if ( roughness >= cubeUV_r1 ) {
  490. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  491. } else if ( roughness >= cubeUV_r4 ) {
  492. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  493. } else if ( roughness >= cubeUV_r5 ) {
  494. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  495. } else if ( roughness >= cubeUV_r6 ) {
  496. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  497. } else {
  498. mip = - 2.0 * log2( 1.16 * roughness ); }
  499. return mip;
  500. }
  501. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  502. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  503. float mipF = fract( mip );
  504. float mipInt = floor( mip );
  505. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  506. if ( mipF == 0.0 ) {
  507. return vec4( color0, 1.0 );
  508. } else {
  509. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  510. return vec4( mix( color0, color1, mipF ), 1.0 );
  511. }
  512. }
  513. #endif`,kke=`vec3 transformedNormal = objectNormal;
  514. #ifdef USE_TANGENT
  515. vec3 transformedTangent = objectTangent;
  516. #endif
  517. #ifdef USE_BATCHING
  518. mat3 bm = mat3( batchingMatrix );
  519. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  520. transformedNormal = bm * transformedNormal;
  521. #ifdef USE_TANGENT
  522. transformedTangent = bm * transformedTangent;
  523. #endif
  524. #endif
  525. #ifdef USE_INSTANCING
  526. mat3 im = mat3( instanceMatrix );
  527. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  528. transformedNormal = im * transformedNormal;
  529. #ifdef USE_TANGENT
  530. transformedTangent = im * transformedTangent;
  531. #endif
  532. #endif
  533. transformedNormal = normalMatrix * transformedNormal;
  534. #ifdef FLIP_SIDED
  535. transformedNormal = - transformedNormal;
  536. #endif
  537. #ifdef USE_TANGENT
  538. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  539. #ifdef FLIP_SIDED
  540. transformedTangent = - transformedTangent;
  541. #endif
  542. #endif`,Pke=`#ifdef USE_DISPLACEMENTMAP
  543. uniform sampler2D displacementMap;
  544. uniform float displacementScale;
  545. uniform float displacementBias;
  546. #endif`,Rke=`#ifdef USE_DISPLACEMENTMAP
  547. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  548. #endif`,Dke=`#ifdef USE_EMISSIVEMAP
  549. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  550. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  551. emissiveColor = sRGBTransferEOTF( emissiveColor );
  552. #endif
  553. totalEmissiveRadiance *= emissiveColor.rgb;
  554. #endif`,jke=`#ifdef USE_EMISSIVEMAP
  555. uniform sampler2D emissiveMap;
  556. #endif`,Oke="gl_FragColor = linearToOutputTexel( gl_FragColor );",Lke=`vec4 LinearTransferOETF( in vec4 value ) {
  557. return value;
  558. }
  559. vec4 sRGBTransferEOTF( in vec4 value ) {
  560. 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 );
  561. }
  562. vec4 sRGBTransferOETF( in vec4 value ) {
  563. 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 );
  564. }`,Ike=`#ifdef USE_ENVMAP
  565. #ifdef ENV_WORLDPOS
  566. vec3 cameraToFrag;
  567. if ( isOrthographic ) {
  568. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  569. } else {
  570. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  571. }
  572. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  573. #ifdef ENVMAP_MODE_REFLECTION
  574. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  575. #else
  576. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  577. #endif
  578. #else
  579. vec3 reflectVec = vReflect;
  580. #endif
  581. #ifdef ENVMAP_TYPE_CUBE
  582. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  583. #else
  584. vec4 envColor = vec4( 0.0 );
  585. #endif
  586. #ifdef ENVMAP_BLENDING_MULTIPLY
  587. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  588. #elif defined( ENVMAP_BLENDING_MIX )
  589. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  590. #elif defined( ENVMAP_BLENDING_ADD )
  591. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  592. #endif
  593. #endif`,Fke=`#ifdef USE_ENVMAP
  594. uniform float envMapIntensity;
  595. uniform float flipEnvMap;
  596. uniform mat3 envMapRotation;
  597. #ifdef ENVMAP_TYPE_CUBE
  598. uniform samplerCube envMap;
  599. #else
  600. uniform sampler2D envMap;
  601. #endif
  602. #endif`,Uke=`#ifdef USE_ENVMAP
  603. uniform float reflectivity;
  604. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  605. #define ENV_WORLDPOS
  606. #endif
  607. #ifdef ENV_WORLDPOS
  608. varying vec3 vWorldPosition;
  609. uniform float refractionRatio;
  610. #else
  611. varying vec3 vReflect;
  612. #endif
  613. #endif`,zke=`#ifdef USE_ENVMAP
  614. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  615. #define ENV_WORLDPOS
  616. #endif
  617. #ifdef ENV_WORLDPOS
  618. varying vec3 vWorldPosition;
  619. #else
  620. varying vec3 vReflect;
  621. uniform float refractionRatio;
  622. #endif
  623. #endif`,Bke=`#ifdef USE_ENVMAP
  624. #ifdef ENV_WORLDPOS
  625. vWorldPosition = worldPosition.xyz;
  626. #else
  627. vec3 cameraToVertex;
  628. if ( isOrthographic ) {
  629. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  630. } else {
  631. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  632. }
  633. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  634. #ifdef ENVMAP_MODE_REFLECTION
  635. vReflect = reflect( cameraToVertex, worldNormal );
  636. #else
  637. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  638. #endif
  639. #endif
  640. #endif`,Hke=`#ifdef USE_FOG
  641. vFogDepth = - mvPosition.z;
  642. #endif`,$ke=`#ifdef USE_FOG
  643. varying float vFogDepth;
  644. #endif`,Vke=`#ifdef USE_FOG
  645. #ifdef FOG_EXP2
  646. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  647. #else
  648. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  649. #endif
  650. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  651. #endif`,Gke=`#ifdef USE_FOG
  652. uniform vec3 fogColor;
  653. varying float vFogDepth;
  654. #ifdef FOG_EXP2
  655. uniform float fogDensity;
  656. #else
  657. uniform float fogNear;
  658. uniform float fogFar;
  659. #endif
  660. #endif`,Wke=`#ifdef USE_GRADIENTMAP
  661. uniform sampler2D gradientMap;
  662. #endif
  663. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  664. float dotNL = dot( normal, lightDirection );
  665. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  666. #ifdef USE_GRADIENTMAP
  667. return vec3( texture2D( gradientMap, coord ).r );
  668. #else
  669. vec2 fw = fwidth( coord ) * 0.5;
  670. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  671. #endif
  672. }`,qke=`#ifdef USE_LIGHTMAP
  673. uniform sampler2D lightMap;
  674. uniform float lightMapIntensity;
  675. #endif`,Kke=`LambertMaterial material;
  676. material.diffuseColor = diffuseColor.rgb;
  677. material.specularStrength = specularStrength;`,Xke=`varying vec3 vViewPosition;
  678. struct LambertMaterial {
  679. vec3 diffuseColor;
  680. float specularStrength;
  681. };
  682. 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 ) {
  683. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  684. vec3 irradiance = dotNL * directLight.color;
  685. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  686. }
  687. 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 ) {
  688. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  689. }
  690. #define RE_Direct RE_Direct_Lambert
  691. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Yke=`uniform bool receiveShadow;
  692. uniform vec3 ambientLightColor;
  693. #if defined( USE_LIGHT_PROBES )
  694. uniform vec3 lightProbe[ 9 ];
  695. #endif
  696. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  697. float x = normal.x, y = normal.y, z = normal.z;
  698. vec3 result = shCoefficients[ 0 ] * 0.886227;
  699. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  700. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  701. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  702. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  703. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  704. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  705. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  706. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  707. return result;
  708. }
  709. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  710. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  711. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  712. return irradiance;
  713. }
  714. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  715. vec3 irradiance = ambientLightColor;
  716. return irradiance;
  717. }
  718. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  719. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  720. if ( cutoffDistance > 0.0 ) {
  721. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  722. }
  723. return distanceFalloff;
  724. }
  725. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  726. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  727. }
  728. #if NUM_DIR_LIGHTS > 0
  729. struct DirectionalLight {
  730. vec3 direction;
  731. vec3 color;
  732. };
  733. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  734. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  735. light.color = directionalLight.color;
  736. light.direction = directionalLight.direction;
  737. light.visible = true;
  738. }
  739. #endif
  740. #if NUM_POINT_LIGHTS > 0
  741. struct PointLight {
  742. vec3 position;
  743. vec3 color;
  744. float distance;
  745. float decay;
  746. };
  747. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  748. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  749. vec3 lVector = pointLight.position - geometryPosition;
  750. light.direction = normalize( lVector );
  751. float lightDistance = length( lVector );
  752. light.color = pointLight.color;
  753. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  754. light.visible = ( light.color != vec3( 0.0 ) );
  755. }
  756. #endif
  757. #if NUM_SPOT_LIGHTS > 0
  758. struct SpotLight {
  759. vec3 position;
  760. vec3 direction;
  761. vec3 color;
  762. float distance;
  763. float decay;
  764. float coneCos;
  765. float penumbraCos;
  766. };
  767. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  768. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  769. vec3 lVector = spotLight.position - geometryPosition;
  770. light.direction = normalize( lVector );
  771. float angleCos = dot( light.direction, spotLight.direction );
  772. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  773. if ( spotAttenuation > 0.0 ) {
  774. float lightDistance = length( lVector );
  775. light.color = spotLight.color * spotAttenuation;
  776. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  777. light.visible = ( light.color != vec3( 0.0 ) );
  778. } else {
  779. light.color = vec3( 0.0 );
  780. light.visible = false;
  781. }
  782. }
  783. #endif
  784. #if NUM_RECT_AREA_LIGHTS > 0
  785. struct RectAreaLight {
  786. vec3 color;
  787. vec3 position;
  788. vec3 halfWidth;
  789. vec3 halfHeight;
  790. };
  791. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  792. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  793. #endif
  794. #if NUM_HEMI_LIGHTS > 0
  795. struct HemisphereLight {
  796. vec3 direction;
  797. vec3 skyColor;
  798. vec3 groundColor;
  799. };
  800. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  801. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  802. float dotNL = dot( normal, hemiLight.direction );
  803. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  804. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  805. return irradiance;
  806. }
  807. #endif`,Zke=`#ifdef USE_ENVMAP
  808. vec3 getIBLIrradiance( const in vec3 normal ) {
  809. #ifdef ENVMAP_TYPE_CUBE_UV
  810. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  811. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  812. return PI * envMapColor.rgb * envMapIntensity;
  813. #else
  814. return vec3( 0.0 );
  815. #endif
  816. }
  817. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  818. #ifdef ENVMAP_TYPE_CUBE_UV
  819. vec3 reflectVec = reflect( - viewDir, normal );
  820. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  821. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  822. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  823. return envMapColor.rgb * envMapIntensity;
  824. #else
  825. return vec3( 0.0 );
  826. #endif
  827. }
  828. #ifdef USE_ANISOTROPY
  829. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  830. #ifdef ENVMAP_TYPE_CUBE_UV
  831. vec3 bentNormal = cross( bitangent, viewDir );
  832. bentNormal = normalize( cross( bentNormal, bitangent ) );
  833. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  834. return getIBLRadiance( viewDir, bentNormal, roughness );
  835. #else
  836. return vec3( 0.0 );
  837. #endif
  838. }
  839. #endif
  840. #endif`,Qke=`ToonMaterial material;
  841. material.diffuseColor = diffuseColor.rgb;`,Jke=`varying vec3 vViewPosition;
  842. struct ToonMaterial {
  843. vec3 diffuseColor;
  844. };
  845. 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 ) {
  846. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  847. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  848. }
  849. 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 ) {
  850. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  851. }
  852. #define RE_Direct RE_Direct_Toon
  853. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,e3e=`BlinnPhongMaterial material;
  854. material.diffuseColor = diffuseColor.rgb;
  855. material.specularColor = specular;
  856. material.specularShininess = shininess;
  857. material.specularStrength = specularStrength;`,t3e=`varying vec3 vViewPosition;
  858. struct BlinnPhongMaterial {
  859. vec3 diffuseColor;
  860. vec3 specularColor;
  861. float specularShininess;
  862. float specularStrength;
  863. };
  864. 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 ) {
  865. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  866. vec3 irradiance = dotNL * directLight.color;
  867. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  868. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  869. }
  870. 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 ) {
  871. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  872. }
  873. #define RE_Direct RE_Direct_BlinnPhong
  874. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,n3e=`PhysicalMaterial material;
  875. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  876. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  877. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  878. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  879. material.roughness = min( material.roughness, 1.0 );
  880. #ifdef IOR
  881. material.ior = ior;
  882. #ifdef USE_SPECULAR
  883. float specularIntensityFactor = specularIntensity;
  884. vec3 specularColorFactor = specularColor;
  885. #ifdef USE_SPECULAR_COLORMAP
  886. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  887. #endif
  888. #ifdef USE_SPECULAR_INTENSITYMAP
  889. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  890. #endif
  891. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  892. #else
  893. float specularIntensityFactor = 1.0;
  894. vec3 specularColorFactor = vec3( 1.0 );
  895. material.specularF90 = 1.0;
  896. #endif
  897. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  898. #else
  899. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  900. material.specularF90 = 1.0;
  901. #endif
  902. #ifdef USE_CLEARCOAT
  903. material.clearcoat = clearcoat;
  904. material.clearcoatRoughness = clearcoatRoughness;
  905. material.clearcoatF0 = vec3( 0.04 );
  906. material.clearcoatF90 = 1.0;
  907. #ifdef USE_CLEARCOATMAP
  908. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  909. #endif
  910. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  911. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  912. #endif
  913. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  914. material.clearcoatRoughness += geometryRoughness;
  915. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  916. #endif
  917. #ifdef USE_DISPERSION
  918. material.dispersion = dispersion;
  919. #endif
  920. #ifdef USE_IRIDESCENCE
  921. material.iridescence = iridescence;
  922. material.iridescenceIOR = iridescenceIOR;
  923. #ifdef USE_IRIDESCENCEMAP
  924. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  925. #endif
  926. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  927. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  928. #else
  929. material.iridescenceThickness = iridescenceThicknessMaximum;
  930. #endif
  931. #endif
  932. #ifdef USE_SHEEN
  933. material.sheenColor = sheenColor;
  934. #ifdef USE_SHEEN_COLORMAP
  935. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  936. #endif
  937. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  938. #ifdef USE_SHEEN_ROUGHNESSMAP
  939. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  940. #endif
  941. #endif
  942. #ifdef USE_ANISOTROPY
  943. #ifdef USE_ANISOTROPYMAP
  944. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  945. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  946. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  947. #else
  948. vec2 anisotropyV = anisotropyVector;
  949. #endif
  950. material.anisotropy = length( anisotropyV );
  951. if( material.anisotropy == 0.0 ) {
  952. anisotropyV = vec2( 1.0, 0.0 );
  953. } else {
  954. anisotropyV /= material.anisotropy;
  955. material.anisotropy = saturate( material.anisotropy );
  956. }
  957. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  958. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  959. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  960. #endif`,r3e=`uniform sampler2D dfgLUT;
  961. struct PhysicalMaterial {
  962. vec3 diffuseColor;
  963. float roughness;
  964. vec3 specularColor;
  965. float specularF90;
  966. float dispersion;
  967. #ifdef USE_CLEARCOAT
  968. float clearcoat;
  969. float clearcoatRoughness;
  970. vec3 clearcoatF0;
  971. float clearcoatF90;
  972. #endif
  973. #ifdef USE_IRIDESCENCE
  974. float iridescence;
  975. float iridescenceIOR;
  976. float iridescenceThickness;
  977. vec3 iridescenceFresnel;
  978. vec3 iridescenceF0;
  979. #endif
  980. #ifdef USE_SHEEN
  981. vec3 sheenColor;
  982. float sheenRoughness;
  983. #endif
  984. #ifdef IOR
  985. float ior;
  986. #endif
  987. #ifdef USE_TRANSMISSION
  988. float transmission;
  989. float transmissionAlpha;
  990. float thickness;
  991. float attenuationDistance;
  992. vec3 attenuationColor;
  993. #endif
  994. #ifdef USE_ANISOTROPY
  995. float anisotropy;
  996. float alphaT;
  997. vec3 anisotropyT;
  998. vec3 anisotropyB;
  999. #endif
  1000. };
  1001. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1002. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1003. vec3 sheenSpecularDirect = vec3( 0.0 );
  1004. vec3 sheenSpecularIndirect = vec3(0.0 );
  1005. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1006. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1007. float x2 = x * x;
  1008. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1009. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1010. }
  1011. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1012. float a2 = pow2( alpha );
  1013. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1014. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1015. return 0.5 / max( gv + gl, EPSILON );
  1016. }
  1017. float D_GGX( const in float alpha, const in float dotNH ) {
  1018. float a2 = pow2( alpha );
  1019. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1020. return RECIPROCAL_PI * a2 / pow2( denom );
  1021. }
  1022. #ifdef USE_ANISOTROPY
  1023. 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 ) {
  1024. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1025. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1026. float v = 0.5 / ( gv + gl );
  1027. return saturate(v);
  1028. }
  1029. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1030. float a2 = alphaT * alphaB;
  1031. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1032. highp float v2 = dot( v, v );
  1033. float w2 = a2 / v2;
  1034. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1035. }
  1036. #endif
  1037. #ifdef USE_CLEARCOAT
  1038. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1039. vec3 f0 = material.clearcoatF0;
  1040. float f90 = material.clearcoatF90;
  1041. float roughness = material.clearcoatRoughness;
  1042. float alpha = pow2( roughness );
  1043. vec3 halfDir = normalize( lightDir + viewDir );
  1044. float dotNL = saturate( dot( normal, lightDir ) );
  1045. float dotNV = saturate( dot( normal, viewDir ) );
  1046. float dotNH = saturate( dot( normal, halfDir ) );
  1047. float dotVH = saturate( dot( viewDir, halfDir ) );
  1048. vec3 F = F_Schlick( f0, f90, dotVH );
  1049. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1050. float D = D_GGX( alpha, dotNH );
  1051. return F * ( V * D );
  1052. }
  1053. #endif
  1054. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1055. vec3 f0 = material.specularColor;
  1056. float f90 = material.specularF90;
  1057. float roughness = material.roughness;
  1058. float alpha = pow2( roughness );
  1059. vec3 halfDir = normalize( lightDir + viewDir );
  1060. float dotNL = saturate( dot( normal, lightDir ) );
  1061. float dotNV = saturate( dot( normal, viewDir ) );
  1062. float dotNH = saturate( dot( normal, halfDir ) );
  1063. float dotVH = saturate( dot( viewDir, halfDir ) );
  1064. vec3 F = F_Schlick( f0, f90, dotVH );
  1065. #ifdef USE_IRIDESCENCE
  1066. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1067. #endif
  1068. #ifdef USE_ANISOTROPY
  1069. float dotTL = dot( material.anisotropyT, lightDir );
  1070. float dotTV = dot( material.anisotropyT, viewDir );
  1071. float dotTH = dot( material.anisotropyT, halfDir );
  1072. float dotBL = dot( material.anisotropyB, lightDir );
  1073. float dotBV = dot( material.anisotropyB, viewDir );
  1074. float dotBH = dot( material.anisotropyB, halfDir );
  1075. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1076. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1077. #else
  1078. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1079. float D = D_GGX( alpha, dotNH );
  1080. #endif
  1081. return F * ( V * D );
  1082. }
  1083. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1084. const float LUT_SIZE = 64.0;
  1085. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1086. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1087. float dotNV = saturate( dot( N, V ) );
  1088. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1089. uv = uv * LUT_SCALE + LUT_BIAS;
  1090. return uv;
  1091. }
  1092. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1093. float l = length( f );
  1094. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1095. }
  1096. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1097. float x = dot( v1, v2 );
  1098. float y = abs( x );
  1099. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1100. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1101. float v = a / b;
  1102. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1103. return cross( v1, v2 ) * theta_sintheta;
  1104. }
  1105. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1106. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1107. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1108. vec3 lightNormal = cross( v1, v2 );
  1109. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1110. vec3 T1, T2;
  1111. T1 = normalize( V - N * dot( V, N ) );
  1112. T2 = - cross( N, T1 );
  1113. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1114. vec3 coords[ 4 ];
  1115. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1116. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1117. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1118. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1119. coords[ 0 ] = normalize( coords[ 0 ] );
  1120. coords[ 1 ] = normalize( coords[ 1 ] );
  1121. coords[ 2 ] = normalize( coords[ 2 ] );
  1122. coords[ 3 ] = normalize( coords[ 3 ] );
  1123. vec3 vectorFormFactor = vec3( 0.0 );
  1124. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1125. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1126. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1127. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1128. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1129. return vec3( result );
  1130. }
  1131. #if defined( USE_SHEEN )
  1132. float D_Charlie( float roughness, float dotNH ) {
  1133. float alpha = pow2( roughness );
  1134. float invAlpha = 1.0 / alpha;
  1135. float cos2h = dotNH * dotNH;
  1136. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1137. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1138. }
  1139. float V_Neubelt( float dotNV, float dotNL ) {
  1140. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1141. }
  1142. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1143. vec3 halfDir = normalize( lightDir + viewDir );
  1144. float dotNL = saturate( dot( normal, lightDir ) );
  1145. float dotNV = saturate( dot( normal, viewDir ) );
  1146. float dotNH = saturate( dot( normal, halfDir ) );
  1147. float D = D_Charlie( sheenRoughness, dotNH );
  1148. float V = V_Neubelt( dotNV, dotNL );
  1149. return sheenColor * ( D * V );
  1150. }
  1151. #endif
  1152. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1153. float dotNV = saturate( dot( normal, viewDir ) );
  1154. float r2 = roughness * roughness;
  1155. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1156. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1157. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1158. return saturate( DG * RECIPROCAL_PI );
  1159. }
  1160. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1161. float dotNV = saturate( dot( normal, viewDir ) );
  1162. vec2 uv = vec2( roughness, dotNV );
  1163. return texture2D( dfgLUT, uv ).rg;
  1164. }
  1165. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1166. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1167. return specularColor * fab.x + specularF90 * fab.y;
  1168. }
  1169. #ifdef USE_IRIDESCENCE
  1170. 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 ) {
  1171. #else
  1172. 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 ) {
  1173. #endif
  1174. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1175. #ifdef USE_IRIDESCENCE
  1176. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1177. #else
  1178. vec3 Fr = specularColor;
  1179. #endif
  1180. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1181. float Ess = fab.x + fab.y;
  1182. float Ems = 1.0 - Ess;
  1183. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1184. singleScatter += FssEss;
  1185. multiScatter += Fms * Ems;
  1186. }
  1187. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1188. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1189. float dotNL = saturate( dot( normal, lightDir ) );
  1190. float dotNV = saturate( dot( normal, viewDir ) );
  1191. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1192. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1193. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1194. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1195. float Ess_V = dfgV.x + dfgV.y;
  1196. float Ess_L = dfgL.x + dfgL.y;
  1197. float Ems_V = 1.0 - Ess_V;
  1198. float Ems_L = 1.0 - Ess_L;
  1199. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1200. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1201. float compensationFactor = Ems_V * Ems_L;
  1202. vec3 multiScatter = Fms * compensationFactor;
  1203. return singleScatter + multiScatter;
  1204. }
  1205. #if NUM_RECT_AREA_LIGHTS > 0
  1206. 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 ) {
  1207. vec3 normal = geometryNormal;
  1208. vec3 viewDir = geometryViewDir;
  1209. vec3 position = geometryPosition;
  1210. vec3 lightPos = rectAreaLight.position;
  1211. vec3 halfWidth = rectAreaLight.halfWidth;
  1212. vec3 halfHeight = rectAreaLight.halfHeight;
  1213. vec3 lightColor = rectAreaLight.color;
  1214. float roughness = material.roughness;
  1215. vec3 rectCoords[ 4 ];
  1216. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1217. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1218. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1219. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1220. vec4 t1 = texture2D( ltc_1, uv );
  1221. vec4 t2 = texture2D( ltc_2, uv );
  1222. mat3 mInv = mat3(
  1223. vec3( t1.x, 0, t1.y ),
  1224. vec3( 0, 1, 0 ),
  1225. vec3( t1.z, 0, t1.w )
  1226. );
  1227. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1228. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1229. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1230. }
  1231. #endif
  1232. 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 ) {
  1233. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1234. vec3 irradiance = dotNL * directLight.color;
  1235. #ifdef USE_CLEARCOAT
  1236. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1237. vec3 ccIrradiance = dotNLcc * directLight.color;
  1238. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1239. #endif
  1240. #ifdef USE_SHEEN
  1241. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1242. #endif
  1243. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1244. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1245. }
  1246. 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 ) {
  1247. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1248. }
  1249. 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) {
  1250. #ifdef USE_CLEARCOAT
  1251. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1252. #endif
  1253. #ifdef USE_SHEEN
  1254. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1255. #endif
  1256. vec3 singleScattering = vec3( 0.0 );
  1257. vec3 multiScattering = vec3( 0.0 );
  1258. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1259. #ifdef USE_IRIDESCENCE
  1260. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1261. #else
  1262. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1263. #endif
  1264. vec3 totalScattering = singleScattering + multiScattering;
  1265. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1266. reflectedLight.indirectSpecular += radiance * singleScattering;
  1267. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1268. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1269. }
  1270. #define RE_Direct RE_Direct_Physical
  1271. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1272. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1273. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1274. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1275. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1276. }`,i3e=`
  1277. vec3 geometryPosition = - vViewPosition;
  1278. vec3 geometryNormal = normal;
  1279. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1280. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1281. #ifdef USE_CLEARCOAT
  1282. geometryClearcoatNormal = clearcoatNormal;
  1283. #endif
  1284. #ifdef USE_IRIDESCENCE
  1285. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1286. if ( material.iridescenceThickness == 0.0 ) {
  1287. material.iridescence = 0.0;
  1288. } else {
  1289. material.iridescence = saturate( material.iridescence );
  1290. }
  1291. if ( material.iridescence > 0.0 ) {
  1292. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1293. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1294. }
  1295. #endif
  1296. IncidentLight directLight;
  1297. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1298. PointLight pointLight;
  1299. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1300. PointLightShadow pointLightShadow;
  1301. #endif
  1302. #pragma unroll_loop_start
  1303. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1304. pointLight = pointLights[ i ];
  1305. getPointLightInfo( pointLight, geometryPosition, directLight );
  1306. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1307. pointLightShadow = pointLightShadows[ i ];
  1308. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1309. #endif
  1310. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1311. }
  1312. #pragma unroll_loop_end
  1313. #endif
  1314. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1315. SpotLight spotLight;
  1316. vec4 spotColor;
  1317. vec3 spotLightCoord;
  1318. bool inSpotLightMap;
  1319. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1320. SpotLightShadow spotLightShadow;
  1321. #endif
  1322. #pragma unroll_loop_start
  1323. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1324. spotLight = spotLights[ i ];
  1325. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1326. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1327. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1328. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1329. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1330. #else
  1331. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1332. #endif
  1333. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1334. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1335. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1336. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1337. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1338. #endif
  1339. #undef SPOT_LIGHT_MAP_INDEX
  1340. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1341. spotLightShadow = spotLightShadows[ i ];
  1342. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1343. #endif
  1344. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1345. }
  1346. #pragma unroll_loop_end
  1347. #endif
  1348. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1349. DirectionalLight directionalLight;
  1350. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1351. DirectionalLightShadow directionalLightShadow;
  1352. #endif
  1353. #pragma unroll_loop_start
  1354. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1355. directionalLight = directionalLights[ i ];
  1356. getDirectionalLightInfo( directionalLight, directLight );
  1357. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1358. directionalLightShadow = directionalLightShadows[ i ];
  1359. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1360. #endif
  1361. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1362. }
  1363. #pragma unroll_loop_end
  1364. #endif
  1365. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1366. RectAreaLight rectAreaLight;
  1367. #pragma unroll_loop_start
  1368. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1369. rectAreaLight = rectAreaLights[ i ];
  1370. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1371. }
  1372. #pragma unroll_loop_end
  1373. #endif
  1374. #if defined( RE_IndirectDiffuse )
  1375. vec3 iblIrradiance = vec3( 0.0 );
  1376. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1377. #if defined( USE_LIGHT_PROBES )
  1378. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1379. #endif
  1380. #if ( NUM_HEMI_LIGHTS > 0 )
  1381. #pragma unroll_loop_start
  1382. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1383. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1384. }
  1385. #pragma unroll_loop_end
  1386. #endif
  1387. #endif
  1388. #if defined( RE_IndirectSpecular )
  1389. vec3 radiance = vec3( 0.0 );
  1390. vec3 clearcoatRadiance = vec3( 0.0 );
  1391. #endif`,a3e=`#if defined( RE_IndirectDiffuse )
  1392. #ifdef USE_LIGHTMAP
  1393. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1394. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1395. irradiance += lightMapIrradiance;
  1396. #endif
  1397. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1398. iblIrradiance += getIBLIrradiance( geometryNormal );
  1399. #endif
  1400. #endif
  1401. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1402. #ifdef USE_ANISOTROPY
  1403. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1404. #else
  1405. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1406. #endif
  1407. #ifdef USE_CLEARCOAT
  1408. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1409. #endif
  1410. #endif`,s3e=`#if defined( RE_IndirectDiffuse )
  1411. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1412. #endif
  1413. #if defined( RE_IndirectSpecular )
  1414. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1415. #endif`,o3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1416. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1417. #endif`,l3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1418. uniform float logDepthBufFC;
  1419. varying float vFragDepth;
  1420. varying float vIsPerspective;
  1421. #endif`,c3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1422. varying float vFragDepth;
  1423. varying float vIsPerspective;
  1424. #endif`,u3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1425. vFragDepth = 1.0 + gl_Position.w;
  1426. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1427. #endif`,d3e=`#ifdef USE_MAP
  1428. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1429. #ifdef DECODE_VIDEO_TEXTURE
  1430. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1431. #endif
  1432. diffuseColor *= sampledDiffuseColor;
  1433. #endif`,h3e=`#ifdef USE_MAP
  1434. uniform sampler2D map;
  1435. #endif`,f3e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1436. #if defined( USE_POINTS_UV )
  1437. vec2 uv = vUv;
  1438. #else
  1439. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1440. #endif
  1441. #endif
  1442. #ifdef USE_MAP
  1443. diffuseColor *= texture2D( map, uv );
  1444. #endif
  1445. #ifdef USE_ALPHAMAP
  1446. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1447. #endif`,p3e=`#if defined( USE_POINTS_UV )
  1448. varying vec2 vUv;
  1449. #else
  1450. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1451. uniform mat3 uvTransform;
  1452. #endif
  1453. #endif
  1454. #ifdef USE_MAP
  1455. uniform sampler2D map;
  1456. #endif
  1457. #ifdef USE_ALPHAMAP
  1458. uniform sampler2D alphaMap;
  1459. #endif`,m3e=`float metalnessFactor = metalness;
  1460. #ifdef USE_METALNESSMAP
  1461. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1462. metalnessFactor *= texelMetalness.b;
  1463. #endif`,g3e=`#ifdef USE_METALNESSMAP
  1464. uniform sampler2D metalnessMap;
  1465. #endif`,x3e=`#ifdef USE_INSTANCING_MORPH
  1466. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1467. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1468. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1469. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1470. }
  1471. #endif`,b3e=`#if defined( USE_MORPHCOLORS )
  1472. vColor *= morphTargetBaseInfluence;
  1473. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1474. #if defined( USE_COLOR_ALPHA )
  1475. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1476. #elif defined( USE_COLOR )
  1477. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1478. #endif
  1479. }
  1480. #endif`,y3e=`#ifdef USE_MORPHNORMALS
  1481. objectNormal *= morphTargetBaseInfluence;
  1482. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1483. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1484. }
  1485. #endif`,v3e=`#ifdef USE_MORPHTARGETS
  1486. #ifndef USE_INSTANCING_MORPH
  1487. uniform float morphTargetBaseInfluence;
  1488. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1489. #endif
  1490. uniform sampler2DArray morphTargetsTexture;
  1491. uniform ivec2 morphTargetsTextureSize;
  1492. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1493. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1494. int y = texelIndex / morphTargetsTextureSize.x;
  1495. int x = texelIndex - y * morphTargetsTextureSize.x;
  1496. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1497. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1498. }
  1499. #endif`,_3e=`#ifdef USE_MORPHTARGETS
  1500. transformed *= morphTargetBaseInfluence;
  1501. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1502. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1503. }
  1504. #endif`,w3e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1505. #ifdef FLAT_SHADED
  1506. vec3 fdx = dFdx( vViewPosition );
  1507. vec3 fdy = dFdy( vViewPosition );
  1508. vec3 normal = normalize( cross( fdx, fdy ) );
  1509. #else
  1510. vec3 normal = normalize( vNormal );
  1511. #ifdef DOUBLE_SIDED
  1512. normal *= faceDirection;
  1513. #endif
  1514. #endif
  1515. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1516. #ifdef USE_TANGENT
  1517. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1518. #else
  1519. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1520. #if defined( USE_NORMALMAP )
  1521. vNormalMapUv
  1522. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1523. vClearcoatNormalMapUv
  1524. #else
  1525. vUv
  1526. #endif
  1527. );
  1528. #endif
  1529. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1530. tbn[0] *= faceDirection;
  1531. tbn[1] *= faceDirection;
  1532. #endif
  1533. #endif
  1534. #ifdef USE_CLEARCOAT_NORMALMAP
  1535. #ifdef USE_TANGENT
  1536. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1537. #else
  1538. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1539. #endif
  1540. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1541. tbn2[0] *= faceDirection;
  1542. tbn2[1] *= faceDirection;
  1543. #endif
  1544. #endif
  1545. vec3 nonPerturbedNormal = normal;`,S3e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1546. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1547. #ifdef FLIP_SIDED
  1548. normal = - normal;
  1549. #endif
  1550. #ifdef DOUBLE_SIDED
  1551. normal = normal * faceDirection;
  1552. #endif
  1553. normal = normalize( normalMatrix * normal );
  1554. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1555. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1556. mapN.xy *= normalScale;
  1557. normal = normalize( tbn * mapN );
  1558. #elif defined( USE_BUMPMAP )
  1559. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1560. #endif`,M3e=`#ifndef FLAT_SHADED
  1561. varying vec3 vNormal;
  1562. #ifdef USE_TANGENT
  1563. varying vec3 vTangent;
  1564. varying vec3 vBitangent;
  1565. #endif
  1566. #endif`,E3e=`#ifndef FLAT_SHADED
  1567. varying vec3 vNormal;
  1568. #ifdef USE_TANGENT
  1569. varying vec3 vTangent;
  1570. varying vec3 vBitangent;
  1571. #endif
  1572. #endif`,A3e=`#ifndef FLAT_SHADED
  1573. vNormal = normalize( transformedNormal );
  1574. #ifdef USE_TANGENT
  1575. vTangent = normalize( transformedTangent );
  1576. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1577. #endif
  1578. #endif`,T3e=`#ifdef USE_NORMALMAP
  1579. uniform sampler2D normalMap;
  1580. uniform vec2 normalScale;
  1581. #endif
  1582. #ifdef USE_NORMALMAP_OBJECTSPACE
  1583. uniform mat3 normalMatrix;
  1584. #endif
  1585. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1586. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1587. vec3 q0 = dFdx( eye_pos.xyz );
  1588. vec3 q1 = dFdy( eye_pos.xyz );
  1589. vec2 st0 = dFdx( uv.st );
  1590. vec2 st1 = dFdy( uv.st );
  1591. vec3 N = surf_norm;
  1592. vec3 q1perp = cross( q1, N );
  1593. vec3 q0perp = cross( N, q0 );
  1594. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1595. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1596. float det = max( dot( T, T ), dot( B, B ) );
  1597. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1598. return mat3( T * scale, B * scale, N );
  1599. }
  1600. #endif`,C3e=`#ifdef USE_CLEARCOAT
  1601. vec3 clearcoatNormal = nonPerturbedNormal;
  1602. #endif`,N3e=`#ifdef USE_CLEARCOAT_NORMALMAP
  1603. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1604. clearcoatMapN.xy *= clearcoatNormalScale;
  1605. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1606. #endif`,k3e=`#ifdef USE_CLEARCOATMAP
  1607. uniform sampler2D clearcoatMap;
  1608. #endif
  1609. #ifdef USE_CLEARCOAT_NORMALMAP
  1610. uniform sampler2D clearcoatNormalMap;
  1611. uniform vec2 clearcoatNormalScale;
  1612. #endif
  1613. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1614. uniform sampler2D clearcoatRoughnessMap;
  1615. #endif`,P3e=`#ifdef USE_IRIDESCENCEMAP
  1616. uniform sampler2D iridescenceMap;
  1617. #endif
  1618. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1619. uniform sampler2D iridescenceThicknessMap;
  1620. #endif`,R3e=`#ifdef OPAQUE
  1621. diffuseColor.a = 1.0;
  1622. #endif
  1623. #ifdef USE_TRANSMISSION
  1624. diffuseColor.a *= material.transmissionAlpha;
  1625. #endif
  1626. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,D3e=`vec3 packNormalToRGB( const in vec3 normal ) {
  1627. return normalize( normal ) * 0.5 + 0.5;
  1628. }
  1629. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1630. return 2.0 * rgb.xyz - 1.0;
  1631. }
  1632. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1633. const float Inv255 = 1. / 255.;
  1634. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1635. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1636. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1637. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1638. vec4 packDepthToRGBA( const in float v ) {
  1639. if( v <= 0.0 )
  1640. return vec4( 0., 0., 0., 0. );
  1641. if( v >= 1.0 )
  1642. return vec4( 1., 1., 1., 1. );
  1643. float vuf;
  1644. float af = modf( v * PackFactors.a, vuf );
  1645. float bf = modf( vuf * ShiftRight8, vuf );
  1646. float gf = modf( vuf * ShiftRight8, vuf );
  1647. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1648. }
  1649. vec3 packDepthToRGB( const in float v ) {
  1650. if( v <= 0.0 )
  1651. return vec3( 0., 0., 0. );
  1652. if( v >= 1.0 )
  1653. return vec3( 1., 1., 1. );
  1654. float vuf;
  1655. float bf = modf( v * PackFactors.b, vuf );
  1656. float gf = modf( vuf * ShiftRight8, vuf );
  1657. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1658. }
  1659. vec2 packDepthToRG( const in float v ) {
  1660. if( v <= 0.0 )
  1661. return vec2( 0., 0. );
  1662. if( v >= 1.0 )
  1663. return vec2( 1., 1. );
  1664. float vuf;
  1665. float gf = modf( v * 256., vuf );
  1666. return vec2( vuf * Inv255, gf );
  1667. }
  1668. float unpackRGBAToDepth( const in vec4 v ) {
  1669. return dot( v, UnpackFactors4 );
  1670. }
  1671. float unpackRGBToDepth( const in vec3 v ) {
  1672. return dot( v, UnpackFactors3 );
  1673. }
  1674. float unpackRGToDepth( const in vec2 v ) {
  1675. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1676. }
  1677. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1678. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1679. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1680. }
  1681. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1682. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1683. }
  1684. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1685. return ( viewZ + near ) / ( near - far );
  1686. }
  1687. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1688. return depth * ( near - far ) - near;
  1689. }
  1690. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1691. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1692. }
  1693. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1694. return ( near * far ) / ( ( far - near ) * depth - far );
  1695. }`,j3e=`#ifdef PREMULTIPLIED_ALPHA
  1696. gl_FragColor.rgb *= gl_FragColor.a;
  1697. #endif`,O3e=`vec4 mvPosition = vec4( transformed, 1.0 );
  1698. #ifdef USE_BATCHING
  1699. mvPosition = batchingMatrix * mvPosition;
  1700. #endif
  1701. #ifdef USE_INSTANCING
  1702. mvPosition = instanceMatrix * mvPosition;
  1703. #endif
  1704. mvPosition = modelViewMatrix * mvPosition;
  1705. gl_Position = projectionMatrix * mvPosition;`,L3e=`#ifdef DITHERING
  1706. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1707. #endif`,I3e=`#ifdef DITHERING
  1708. vec3 dithering( vec3 color ) {
  1709. float grid_position = rand( gl_FragCoord.xy );
  1710. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1711. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1712. return color + dither_shift_RGB;
  1713. }
  1714. #endif`,F3e=`float roughnessFactor = roughness;
  1715. #ifdef USE_ROUGHNESSMAP
  1716. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1717. roughnessFactor *= texelRoughness.g;
  1718. #endif`,U3e=`#ifdef USE_ROUGHNESSMAP
  1719. uniform sampler2D roughnessMap;
  1720. #endif`,z3e=`#if NUM_SPOT_LIGHT_COORDS > 0
  1721. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1722. #endif
  1723. #if NUM_SPOT_LIGHT_MAPS > 0
  1724. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1725. #endif
  1726. #ifdef USE_SHADOWMAP
  1727. #if NUM_DIR_LIGHT_SHADOWS > 0
  1728. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1729. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1730. struct DirectionalLightShadow {
  1731. float shadowIntensity;
  1732. float shadowBias;
  1733. float shadowNormalBias;
  1734. float shadowRadius;
  1735. vec2 shadowMapSize;
  1736. };
  1737. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1738. #endif
  1739. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1740. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1741. struct SpotLightShadow {
  1742. float shadowIntensity;
  1743. float shadowBias;
  1744. float shadowNormalBias;
  1745. float shadowRadius;
  1746. vec2 shadowMapSize;
  1747. };
  1748. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1749. #endif
  1750. #if NUM_POINT_LIGHT_SHADOWS > 0
  1751. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1752. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1753. struct PointLightShadow {
  1754. float shadowIntensity;
  1755. float shadowBias;
  1756. float shadowNormalBias;
  1757. float shadowRadius;
  1758. vec2 shadowMapSize;
  1759. float shadowCameraNear;
  1760. float shadowCameraFar;
  1761. };
  1762. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1763. #endif
  1764. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1765. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1766. #ifdef USE_REVERSED_DEPTH_BUFFER
  1767. return step( depth, compare );
  1768. #else
  1769. return step( compare, depth );
  1770. #endif
  1771. }
  1772. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1773. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1774. }
  1775. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1776. float occlusion = 1.0;
  1777. vec2 distribution = texture2DDistribution( shadow, uv );
  1778. #ifdef USE_REVERSED_DEPTH_BUFFER
  1779. float hard_shadow = step( distribution.x, compare );
  1780. #else
  1781. float hard_shadow = step( compare, distribution.x );
  1782. #endif
  1783. if ( hard_shadow != 1.0 ) {
  1784. float distance = compare - distribution.x;
  1785. float variance = max( 0.00000, distribution.y * distribution.y );
  1786. 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 );
  1787. }
  1788. return occlusion;
  1789. }
  1790. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1791. float shadow = 1.0;
  1792. shadowCoord.xyz /= shadowCoord.w;
  1793. shadowCoord.z += shadowBias;
  1794. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1795. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1796. if ( frustumTest ) {
  1797. #if defined( SHADOWMAP_TYPE_PCF )
  1798. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1799. float dx0 = - texelSize.x * shadowRadius;
  1800. float dy0 = - texelSize.y * shadowRadius;
  1801. float dx1 = + texelSize.x * shadowRadius;
  1802. float dy1 = + texelSize.y * shadowRadius;
  1803. float dx2 = dx0 / 2.0;
  1804. float dy2 = dy0 / 2.0;
  1805. float dx3 = dx1 / 2.0;
  1806. float dy3 = dy1 / 2.0;
  1807. shadow = (
  1808. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1809. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1810. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1811. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1812. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1813. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1814. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1815. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1816. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1817. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1818. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1819. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1820. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1821. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1822. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1823. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1824. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1825. ) * ( 1.0 / 17.0 );
  1826. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1827. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1828. float dx = texelSize.x;
  1829. float dy = texelSize.y;
  1830. vec2 uv = shadowCoord.xy;
  1831. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1832. uv -= f * texelSize;
  1833. shadow = (
  1834. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1835. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1836. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1837. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1838. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1839. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1840. f.x ) +
  1841. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1842. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1843. f.x ) +
  1844. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1845. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1846. f.y ) +
  1847. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1848. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1849. f.y ) +
  1850. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1851. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1852. f.x ),
  1853. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1854. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1855. f.x ),
  1856. f.y )
  1857. ) * ( 1.0 / 9.0 );
  1858. #elif defined( SHADOWMAP_TYPE_VSM )
  1859. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1860. #else
  1861. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1862. #endif
  1863. }
  1864. return mix( 1.0, shadow, shadowIntensity );
  1865. }
  1866. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1867. vec3 absV = abs( v );
  1868. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1869. absV *= scaleToCube;
  1870. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1871. vec2 planar = v.xy;
  1872. float almostATexel = 1.5 * texelSizeY;
  1873. float almostOne = 1.0 - almostATexel;
  1874. if ( absV.z >= almostOne ) {
  1875. if ( v.z > 0.0 )
  1876. planar.x = 4.0 - v.x;
  1877. } else if ( absV.x >= almostOne ) {
  1878. float signX = sign( v.x );
  1879. planar.x = v.z * signX + 2.0 * signX;
  1880. } else if ( absV.y >= almostOne ) {
  1881. float signY = sign( v.y );
  1882. planar.x = v.x + 2.0 * signY + 2.0;
  1883. planar.y = v.z * signY - 2.0;
  1884. }
  1885. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1886. }
  1887. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1888. float shadow = 1.0;
  1889. vec3 lightToPosition = shadowCoord.xyz;
  1890. float lightToPositionLength = length( lightToPosition );
  1891. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1892. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1893. vec3 bd3D = normalize( lightToPosition );
  1894. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1895. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1896. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1897. shadow = (
  1898. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1899. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1900. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1901. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1902. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1903. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1904. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1905. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1906. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1907. ) * ( 1.0 / 9.0 );
  1908. #else
  1909. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1910. #endif
  1911. }
  1912. return mix( 1.0, shadow, shadowIntensity );
  1913. }
  1914. #endif`,B3e=`#if NUM_SPOT_LIGHT_COORDS > 0
  1915. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1916. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1917. #endif
  1918. #ifdef USE_SHADOWMAP
  1919. #if NUM_DIR_LIGHT_SHADOWS > 0
  1920. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1921. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1922. struct DirectionalLightShadow {
  1923. float shadowIntensity;
  1924. float shadowBias;
  1925. float shadowNormalBias;
  1926. float shadowRadius;
  1927. vec2 shadowMapSize;
  1928. };
  1929. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1930. #endif
  1931. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1932. struct SpotLightShadow {
  1933. float shadowIntensity;
  1934. float shadowBias;
  1935. float shadowNormalBias;
  1936. float shadowRadius;
  1937. vec2 shadowMapSize;
  1938. };
  1939. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1940. #endif
  1941. #if NUM_POINT_LIGHT_SHADOWS > 0
  1942. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1943. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1944. struct PointLightShadow {
  1945. float shadowIntensity;
  1946. float shadowBias;
  1947. float shadowNormalBias;
  1948. float shadowRadius;
  1949. vec2 shadowMapSize;
  1950. float shadowCameraNear;
  1951. float shadowCameraFar;
  1952. };
  1953. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1954. #endif
  1955. #endif`,H3e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1956. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1957. vec4 shadowWorldPosition;
  1958. #endif
  1959. #if defined( USE_SHADOWMAP )
  1960. #if NUM_DIR_LIGHT_SHADOWS > 0
  1961. #pragma unroll_loop_start
  1962. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1963. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1964. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1965. }
  1966. #pragma unroll_loop_end
  1967. #endif
  1968. #if NUM_POINT_LIGHT_SHADOWS > 0
  1969. #pragma unroll_loop_start
  1970. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1971. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1972. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1973. }
  1974. #pragma unroll_loop_end
  1975. #endif
  1976. #endif
  1977. #if NUM_SPOT_LIGHT_COORDS > 0
  1978. #pragma unroll_loop_start
  1979. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1980. shadowWorldPosition = worldPosition;
  1981. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1982. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1983. #endif
  1984. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1985. }
  1986. #pragma unroll_loop_end
  1987. #endif`,$3e=`float getShadowMask() {
  1988. float shadow = 1.0;
  1989. #ifdef USE_SHADOWMAP
  1990. #if NUM_DIR_LIGHT_SHADOWS > 0
  1991. DirectionalLightShadow directionalLight;
  1992. #pragma unroll_loop_start
  1993. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1994. directionalLight = directionalLightShadows[ i ];
  1995. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1996. }
  1997. #pragma unroll_loop_end
  1998. #endif
  1999. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2000. SpotLightShadow spotLight;
  2001. #pragma unroll_loop_start
  2002. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2003. spotLight = spotLightShadows[ i ];
  2004. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2005. }
  2006. #pragma unroll_loop_end
  2007. #endif
  2008. #if NUM_POINT_LIGHT_SHADOWS > 0
  2009. PointLightShadow pointLight;
  2010. #pragma unroll_loop_start
  2011. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2012. pointLight = pointLightShadows[ i ];
  2013. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2014. }
  2015. #pragma unroll_loop_end
  2016. #endif
  2017. #endif
  2018. return shadow;
  2019. }`,V3e=`#ifdef USE_SKINNING
  2020. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2021. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2022. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2023. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2024. #endif`,G3e=`#ifdef USE_SKINNING
  2025. uniform mat4 bindMatrix;
  2026. uniform mat4 bindMatrixInverse;
  2027. uniform highp sampler2D boneTexture;
  2028. mat4 getBoneMatrix( const in float i ) {
  2029. int size = textureSize( boneTexture, 0 ).x;
  2030. int j = int( i ) * 4;
  2031. int x = j % size;
  2032. int y = j / size;
  2033. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2034. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2035. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2036. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2037. return mat4( v1, v2, v3, v4 );
  2038. }
  2039. #endif`,W3e=`#ifdef USE_SKINNING
  2040. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2041. vec4 skinned = vec4( 0.0 );
  2042. skinned += boneMatX * skinVertex * skinWeight.x;
  2043. skinned += boneMatY * skinVertex * skinWeight.y;
  2044. skinned += boneMatZ * skinVertex * skinWeight.z;
  2045. skinned += boneMatW * skinVertex * skinWeight.w;
  2046. transformed = ( bindMatrixInverse * skinned ).xyz;
  2047. #endif`,q3e=`#ifdef USE_SKINNING
  2048. mat4 skinMatrix = mat4( 0.0 );
  2049. skinMatrix += skinWeight.x * boneMatX;
  2050. skinMatrix += skinWeight.y * boneMatY;
  2051. skinMatrix += skinWeight.z * boneMatZ;
  2052. skinMatrix += skinWeight.w * boneMatW;
  2053. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2054. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2055. #ifdef USE_TANGENT
  2056. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2057. #endif
  2058. #endif`,K3e=`float specularStrength;
  2059. #ifdef USE_SPECULARMAP
  2060. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2061. specularStrength = texelSpecular.r;
  2062. #else
  2063. specularStrength = 1.0;
  2064. #endif`,X3e=`#ifdef USE_SPECULARMAP
  2065. uniform sampler2D specularMap;
  2066. #endif`,Y3e=`#if defined( TONE_MAPPING )
  2067. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2068. #endif`,Z3e=`#ifndef saturate
  2069. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2070. #endif
  2071. uniform float toneMappingExposure;
  2072. vec3 LinearToneMapping( vec3 color ) {
  2073. return saturate( toneMappingExposure * color );
  2074. }
  2075. vec3 ReinhardToneMapping( vec3 color ) {
  2076. color *= toneMappingExposure;
  2077. return saturate( color / ( vec3( 1.0 ) + color ) );
  2078. }
  2079. vec3 CineonToneMapping( vec3 color ) {
  2080. color *= toneMappingExposure;
  2081. color = max( vec3( 0.0 ), color - 0.004 );
  2082. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2083. }
  2084. vec3 RRTAndODTFit( vec3 v ) {
  2085. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2086. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2087. return a / b;
  2088. }
  2089. vec3 ACESFilmicToneMapping( vec3 color ) {
  2090. const mat3 ACESInputMat = mat3(
  2091. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2092. vec3( 0.04823, 0.01566, 0.83777 )
  2093. );
  2094. const mat3 ACESOutputMat = mat3(
  2095. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2096. vec3( -0.07367, -0.00605, 1.07602 )
  2097. );
  2098. color *= toneMappingExposure / 0.6;
  2099. color = ACESInputMat * color;
  2100. color = RRTAndODTFit( color );
  2101. color = ACESOutputMat * color;
  2102. return saturate( color );
  2103. }
  2104. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2105. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2106. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2107. vec3( - 0.0728, - 0.0083, 1.1187 )
  2108. );
  2109. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2110. vec3( 0.6274, 0.0691, 0.0164 ),
  2111. vec3( 0.3293, 0.9195, 0.0880 ),
  2112. vec3( 0.0433, 0.0113, 0.8956 )
  2113. );
  2114. vec3 agxDefaultContrastApprox( vec3 x ) {
  2115. vec3 x2 = x * x;
  2116. vec3 x4 = x2 * x2;
  2117. return + 15.5 * x4 * x2
  2118. - 40.14 * x4 * x
  2119. + 31.96 * x4
  2120. - 6.868 * x2 * x
  2121. + 0.4298 * x2
  2122. + 0.1191 * x
  2123. - 0.00232;
  2124. }
  2125. vec3 AgXToneMapping( vec3 color ) {
  2126. const mat3 AgXInsetMatrix = mat3(
  2127. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2128. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2129. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2130. );
  2131. const mat3 AgXOutsetMatrix = mat3(
  2132. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2133. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2134. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2135. );
  2136. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2137. color *= toneMappingExposure;
  2138. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2139. color = AgXInsetMatrix * color;
  2140. color = max( color, 1e-10 ); color = log2( color );
  2141. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2142. color = clamp( color, 0.0, 1.0 );
  2143. color = agxDefaultContrastApprox( color );
  2144. color = AgXOutsetMatrix * color;
  2145. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2146. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2147. color = clamp( color, 0.0, 1.0 );
  2148. return color;
  2149. }
  2150. vec3 NeutralToneMapping( vec3 color ) {
  2151. const float StartCompression = 0.8 - 0.04;
  2152. const float Desaturation = 0.15;
  2153. color *= toneMappingExposure;
  2154. float x = min( color.r, min( color.g, color.b ) );
  2155. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2156. color -= offset;
  2157. float peak = max( color.r, max( color.g, color.b ) );
  2158. if ( peak < StartCompression ) return color;
  2159. float d = 1. - StartCompression;
  2160. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2161. color *= newPeak / peak;
  2162. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2163. return mix( color, vec3( newPeak ), g );
  2164. }
  2165. vec3 CustomToneMapping( vec3 color ) { return color; }`,Q3e=`#ifdef USE_TRANSMISSION
  2166. material.transmission = transmission;
  2167. material.transmissionAlpha = 1.0;
  2168. material.thickness = thickness;
  2169. material.attenuationDistance = attenuationDistance;
  2170. material.attenuationColor = attenuationColor;
  2171. #ifdef USE_TRANSMISSIONMAP
  2172. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2173. #endif
  2174. #ifdef USE_THICKNESSMAP
  2175. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2176. #endif
  2177. vec3 pos = vWorldPosition;
  2178. vec3 v = normalize( cameraPosition - pos );
  2179. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2180. vec4 transmitted = getIBLVolumeRefraction(
  2181. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2182. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2183. material.attenuationColor, material.attenuationDistance );
  2184. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2185. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2186. #endif`,J3e=`#ifdef USE_TRANSMISSION
  2187. uniform float transmission;
  2188. uniform float thickness;
  2189. uniform float attenuationDistance;
  2190. uniform vec3 attenuationColor;
  2191. #ifdef USE_TRANSMISSIONMAP
  2192. uniform sampler2D transmissionMap;
  2193. #endif
  2194. #ifdef USE_THICKNESSMAP
  2195. uniform sampler2D thicknessMap;
  2196. #endif
  2197. uniform vec2 transmissionSamplerSize;
  2198. uniform sampler2D transmissionSamplerMap;
  2199. uniform mat4 modelMatrix;
  2200. uniform mat4 projectionMatrix;
  2201. varying vec3 vWorldPosition;
  2202. float w0( float a ) {
  2203. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2204. }
  2205. float w1( float a ) {
  2206. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2207. }
  2208. float w2( float a ){
  2209. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2210. }
  2211. float w3( float a ) {
  2212. return ( 1.0 / 6.0 ) * ( a * a * a );
  2213. }
  2214. float g0( float a ) {
  2215. return w0( a ) + w1( a );
  2216. }
  2217. float g1( float a ) {
  2218. return w2( a ) + w3( a );
  2219. }
  2220. float h0( float a ) {
  2221. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2222. }
  2223. float h1( float a ) {
  2224. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2225. }
  2226. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2227. uv = uv * texelSize.zw + 0.5;
  2228. vec2 iuv = floor( uv );
  2229. vec2 fuv = fract( uv );
  2230. float g0x = g0( fuv.x );
  2231. float g1x = g1( fuv.x );
  2232. float h0x = h0( fuv.x );
  2233. float h1x = h1( fuv.x );
  2234. float h0y = h0( fuv.y );
  2235. float h1y = h1( fuv.y );
  2236. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2237. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2238. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2239. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2240. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2241. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2242. }
  2243. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2244. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2245. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2246. vec2 fLodSizeInv = 1.0 / fLodSize;
  2247. vec2 cLodSizeInv = 1.0 / cLodSize;
  2248. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2249. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2250. return mix( fSample, cSample, fract( lod ) );
  2251. }
  2252. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2253. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2254. vec3 modelScale;
  2255. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2256. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2257. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2258. return normalize( refractionVector ) * thickness * modelScale;
  2259. }
  2260. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2261. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2262. }
  2263. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2264. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2265. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2266. }
  2267. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2268. if ( isinf( attenuationDistance ) ) {
  2269. return vec3( 1.0 );
  2270. } else {
  2271. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2272. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2273. }
  2274. }
  2275. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2276. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2277. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2278. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2279. vec4 transmittedLight;
  2280. vec3 transmittance;
  2281. #ifdef USE_DISPERSION
  2282. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2283. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2284. for ( int i = 0; i < 3; i ++ ) {
  2285. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2286. vec3 refractedRayExit = position + transmissionRay;
  2287. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2288. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2289. refractionCoords += 1.0;
  2290. refractionCoords /= 2.0;
  2291. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2292. transmittedLight[ i ] = transmissionSample[ i ];
  2293. transmittedLight.a += transmissionSample.a;
  2294. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2295. }
  2296. transmittedLight.a /= 3.0;
  2297. #else
  2298. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2299. vec3 refractedRayExit = position + transmissionRay;
  2300. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2301. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2302. refractionCoords += 1.0;
  2303. refractionCoords /= 2.0;
  2304. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2305. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2306. #endif
  2307. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2308. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2309. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2310. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2311. }
  2312. #endif`,ePe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2313. varying vec2 vUv;
  2314. #endif
  2315. #ifdef USE_MAP
  2316. varying vec2 vMapUv;
  2317. #endif
  2318. #ifdef USE_ALPHAMAP
  2319. varying vec2 vAlphaMapUv;
  2320. #endif
  2321. #ifdef USE_LIGHTMAP
  2322. varying vec2 vLightMapUv;
  2323. #endif
  2324. #ifdef USE_AOMAP
  2325. varying vec2 vAoMapUv;
  2326. #endif
  2327. #ifdef USE_BUMPMAP
  2328. varying vec2 vBumpMapUv;
  2329. #endif
  2330. #ifdef USE_NORMALMAP
  2331. varying vec2 vNormalMapUv;
  2332. #endif
  2333. #ifdef USE_EMISSIVEMAP
  2334. varying vec2 vEmissiveMapUv;
  2335. #endif
  2336. #ifdef USE_METALNESSMAP
  2337. varying vec2 vMetalnessMapUv;
  2338. #endif
  2339. #ifdef USE_ROUGHNESSMAP
  2340. varying vec2 vRoughnessMapUv;
  2341. #endif
  2342. #ifdef USE_ANISOTROPYMAP
  2343. varying vec2 vAnisotropyMapUv;
  2344. #endif
  2345. #ifdef USE_CLEARCOATMAP
  2346. varying vec2 vClearcoatMapUv;
  2347. #endif
  2348. #ifdef USE_CLEARCOAT_NORMALMAP
  2349. varying vec2 vClearcoatNormalMapUv;
  2350. #endif
  2351. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2352. varying vec2 vClearcoatRoughnessMapUv;
  2353. #endif
  2354. #ifdef USE_IRIDESCENCEMAP
  2355. varying vec2 vIridescenceMapUv;
  2356. #endif
  2357. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2358. varying vec2 vIridescenceThicknessMapUv;
  2359. #endif
  2360. #ifdef USE_SHEEN_COLORMAP
  2361. varying vec2 vSheenColorMapUv;
  2362. #endif
  2363. #ifdef USE_SHEEN_ROUGHNESSMAP
  2364. varying vec2 vSheenRoughnessMapUv;
  2365. #endif
  2366. #ifdef USE_SPECULARMAP
  2367. varying vec2 vSpecularMapUv;
  2368. #endif
  2369. #ifdef USE_SPECULAR_COLORMAP
  2370. varying vec2 vSpecularColorMapUv;
  2371. #endif
  2372. #ifdef USE_SPECULAR_INTENSITYMAP
  2373. varying vec2 vSpecularIntensityMapUv;
  2374. #endif
  2375. #ifdef USE_TRANSMISSIONMAP
  2376. uniform mat3 transmissionMapTransform;
  2377. varying vec2 vTransmissionMapUv;
  2378. #endif
  2379. #ifdef USE_THICKNESSMAP
  2380. uniform mat3 thicknessMapTransform;
  2381. varying vec2 vThicknessMapUv;
  2382. #endif`,tPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2383. varying vec2 vUv;
  2384. #endif
  2385. #ifdef USE_MAP
  2386. uniform mat3 mapTransform;
  2387. varying vec2 vMapUv;
  2388. #endif
  2389. #ifdef USE_ALPHAMAP
  2390. uniform mat3 alphaMapTransform;
  2391. varying vec2 vAlphaMapUv;
  2392. #endif
  2393. #ifdef USE_LIGHTMAP
  2394. uniform mat3 lightMapTransform;
  2395. varying vec2 vLightMapUv;
  2396. #endif
  2397. #ifdef USE_AOMAP
  2398. uniform mat3 aoMapTransform;
  2399. varying vec2 vAoMapUv;
  2400. #endif
  2401. #ifdef USE_BUMPMAP
  2402. uniform mat3 bumpMapTransform;
  2403. varying vec2 vBumpMapUv;
  2404. #endif
  2405. #ifdef USE_NORMALMAP
  2406. uniform mat3 normalMapTransform;
  2407. varying vec2 vNormalMapUv;
  2408. #endif
  2409. #ifdef USE_DISPLACEMENTMAP
  2410. uniform mat3 displacementMapTransform;
  2411. varying vec2 vDisplacementMapUv;
  2412. #endif
  2413. #ifdef USE_EMISSIVEMAP
  2414. uniform mat3 emissiveMapTransform;
  2415. varying vec2 vEmissiveMapUv;
  2416. #endif
  2417. #ifdef USE_METALNESSMAP
  2418. uniform mat3 metalnessMapTransform;
  2419. varying vec2 vMetalnessMapUv;
  2420. #endif
  2421. #ifdef USE_ROUGHNESSMAP
  2422. uniform mat3 roughnessMapTransform;
  2423. varying vec2 vRoughnessMapUv;
  2424. #endif
  2425. #ifdef USE_ANISOTROPYMAP
  2426. uniform mat3 anisotropyMapTransform;
  2427. varying vec2 vAnisotropyMapUv;
  2428. #endif
  2429. #ifdef USE_CLEARCOATMAP
  2430. uniform mat3 clearcoatMapTransform;
  2431. varying vec2 vClearcoatMapUv;
  2432. #endif
  2433. #ifdef USE_CLEARCOAT_NORMALMAP
  2434. uniform mat3 clearcoatNormalMapTransform;
  2435. varying vec2 vClearcoatNormalMapUv;
  2436. #endif
  2437. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2438. uniform mat3 clearcoatRoughnessMapTransform;
  2439. varying vec2 vClearcoatRoughnessMapUv;
  2440. #endif
  2441. #ifdef USE_SHEEN_COLORMAP
  2442. uniform mat3 sheenColorMapTransform;
  2443. varying vec2 vSheenColorMapUv;
  2444. #endif
  2445. #ifdef USE_SHEEN_ROUGHNESSMAP
  2446. uniform mat3 sheenRoughnessMapTransform;
  2447. varying vec2 vSheenRoughnessMapUv;
  2448. #endif
  2449. #ifdef USE_IRIDESCENCEMAP
  2450. uniform mat3 iridescenceMapTransform;
  2451. varying vec2 vIridescenceMapUv;
  2452. #endif
  2453. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2454. uniform mat3 iridescenceThicknessMapTransform;
  2455. varying vec2 vIridescenceThicknessMapUv;
  2456. #endif
  2457. #ifdef USE_SPECULARMAP
  2458. uniform mat3 specularMapTransform;
  2459. varying vec2 vSpecularMapUv;
  2460. #endif
  2461. #ifdef USE_SPECULAR_COLORMAP
  2462. uniform mat3 specularColorMapTransform;
  2463. varying vec2 vSpecularColorMapUv;
  2464. #endif
  2465. #ifdef USE_SPECULAR_INTENSITYMAP
  2466. uniform mat3 specularIntensityMapTransform;
  2467. varying vec2 vSpecularIntensityMapUv;
  2468. #endif
  2469. #ifdef USE_TRANSMISSIONMAP
  2470. uniform mat3 transmissionMapTransform;
  2471. varying vec2 vTransmissionMapUv;
  2472. #endif
  2473. #ifdef USE_THICKNESSMAP
  2474. uniform mat3 thicknessMapTransform;
  2475. varying vec2 vThicknessMapUv;
  2476. #endif`,nPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2477. vUv = vec3( uv, 1 ).xy;
  2478. #endif
  2479. #ifdef USE_MAP
  2480. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2481. #endif
  2482. #ifdef USE_ALPHAMAP
  2483. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2484. #endif
  2485. #ifdef USE_LIGHTMAP
  2486. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2487. #endif
  2488. #ifdef USE_AOMAP
  2489. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2490. #endif
  2491. #ifdef USE_BUMPMAP
  2492. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2493. #endif
  2494. #ifdef USE_NORMALMAP
  2495. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2496. #endif
  2497. #ifdef USE_DISPLACEMENTMAP
  2498. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2499. #endif
  2500. #ifdef USE_EMISSIVEMAP
  2501. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2502. #endif
  2503. #ifdef USE_METALNESSMAP
  2504. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2505. #endif
  2506. #ifdef USE_ROUGHNESSMAP
  2507. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2508. #endif
  2509. #ifdef USE_ANISOTROPYMAP
  2510. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2511. #endif
  2512. #ifdef USE_CLEARCOATMAP
  2513. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2514. #endif
  2515. #ifdef USE_CLEARCOAT_NORMALMAP
  2516. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2517. #endif
  2518. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2519. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2520. #endif
  2521. #ifdef USE_IRIDESCENCEMAP
  2522. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2523. #endif
  2524. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2525. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2526. #endif
  2527. #ifdef USE_SHEEN_COLORMAP
  2528. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2529. #endif
  2530. #ifdef USE_SHEEN_ROUGHNESSMAP
  2531. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2532. #endif
  2533. #ifdef USE_SPECULARMAP
  2534. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2535. #endif
  2536. #ifdef USE_SPECULAR_COLORMAP
  2537. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2538. #endif
  2539. #ifdef USE_SPECULAR_INTENSITYMAP
  2540. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2541. #endif
  2542. #ifdef USE_TRANSMISSIONMAP
  2543. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2544. #endif
  2545. #ifdef USE_THICKNESSMAP
  2546. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2547. #endif`,rPe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2548. vec4 worldPosition = vec4( transformed, 1.0 );
  2549. #ifdef USE_BATCHING
  2550. worldPosition = batchingMatrix * worldPosition;
  2551. #endif
  2552. #ifdef USE_INSTANCING
  2553. worldPosition = instanceMatrix * worldPosition;
  2554. #endif
  2555. worldPosition = modelMatrix * worldPosition;
  2556. #endif`;const iPe=`varying vec2 vUv;
  2557. uniform mat3 uvTransform;
  2558. void main() {
  2559. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2560. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2561. }`,aPe=`uniform sampler2D t2D;
  2562. uniform float backgroundIntensity;
  2563. varying vec2 vUv;
  2564. void main() {
  2565. vec4 texColor = texture2D( t2D, vUv );
  2566. #ifdef DECODE_VIDEO_TEXTURE
  2567. 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 );
  2568. #endif
  2569. texColor.rgb *= backgroundIntensity;
  2570. gl_FragColor = texColor;
  2571. #include <tonemapping_fragment>
  2572. #include <colorspace_fragment>
  2573. }`,sPe=`varying vec3 vWorldDirection;
  2574. #include <common>
  2575. void main() {
  2576. vWorldDirection = transformDirection( position, modelMatrix );
  2577. #include <begin_vertex>
  2578. #include <project_vertex>
  2579. gl_Position.z = gl_Position.w;
  2580. }`,oPe=`#ifdef ENVMAP_TYPE_CUBE
  2581. uniform samplerCube envMap;
  2582. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2583. uniform sampler2D envMap;
  2584. #endif
  2585. uniform float flipEnvMap;
  2586. uniform float backgroundBlurriness;
  2587. uniform float backgroundIntensity;
  2588. uniform mat3 backgroundRotation;
  2589. varying vec3 vWorldDirection;
  2590. #include <cube_uv_reflection_fragment>
  2591. void main() {
  2592. #ifdef ENVMAP_TYPE_CUBE
  2593. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2594. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2595. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2596. #else
  2597. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2598. #endif
  2599. texColor.rgb *= backgroundIntensity;
  2600. gl_FragColor = texColor;
  2601. #include <tonemapping_fragment>
  2602. #include <colorspace_fragment>
  2603. }`,lPe=`varying vec3 vWorldDirection;
  2604. #include <common>
  2605. void main() {
  2606. vWorldDirection = transformDirection( position, modelMatrix );
  2607. #include <begin_vertex>
  2608. #include <project_vertex>
  2609. gl_Position.z = gl_Position.w;
  2610. }`,cPe=`uniform samplerCube tCube;
  2611. uniform float tFlip;
  2612. uniform float opacity;
  2613. varying vec3 vWorldDirection;
  2614. void main() {
  2615. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2616. gl_FragColor = texColor;
  2617. gl_FragColor.a *= opacity;
  2618. #include <tonemapping_fragment>
  2619. #include <colorspace_fragment>
  2620. }`,uPe=`#include <common>
  2621. #include <batching_pars_vertex>
  2622. #include <uv_pars_vertex>
  2623. #include <displacementmap_pars_vertex>
  2624. #include <morphtarget_pars_vertex>
  2625. #include <skinning_pars_vertex>
  2626. #include <logdepthbuf_pars_vertex>
  2627. #include <clipping_planes_pars_vertex>
  2628. varying vec2 vHighPrecisionZW;
  2629. void main() {
  2630. #include <uv_vertex>
  2631. #include <batching_vertex>
  2632. #include <skinbase_vertex>
  2633. #include <morphinstance_vertex>
  2634. #ifdef USE_DISPLACEMENTMAP
  2635. #include <beginnormal_vertex>
  2636. #include <morphnormal_vertex>
  2637. #include <skinnormal_vertex>
  2638. #endif
  2639. #include <begin_vertex>
  2640. #include <morphtarget_vertex>
  2641. #include <skinning_vertex>
  2642. #include <displacementmap_vertex>
  2643. #include <project_vertex>
  2644. #include <logdepthbuf_vertex>
  2645. #include <clipping_planes_vertex>
  2646. vHighPrecisionZW = gl_Position.zw;
  2647. }`,dPe=`#if DEPTH_PACKING == 3200
  2648. uniform float opacity;
  2649. #endif
  2650. #include <common>
  2651. #include <packing>
  2652. #include <uv_pars_fragment>
  2653. #include <map_pars_fragment>
  2654. #include <alphamap_pars_fragment>
  2655. #include <alphatest_pars_fragment>
  2656. #include <alphahash_pars_fragment>
  2657. #include <logdepthbuf_pars_fragment>
  2658. #include <clipping_planes_pars_fragment>
  2659. varying vec2 vHighPrecisionZW;
  2660. void main() {
  2661. vec4 diffuseColor = vec4( 1.0 );
  2662. #include <clipping_planes_fragment>
  2663. #if DEPTH_PACKING == 3200
  2664. diffuseColor.a = opacity;
  2665. #endif
  2666. #include <map_fragment>
  2667. #include <alphamap_fragment>
  2668. #include <alphatest_fragment>
  2669. #include <alphahash_fragment>
  2670. #include <logdepthbuf_fragment>
  2671. #ifdef USE_REVERSED_DEPTH_BUFFER
  2672. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2673. #else
  2674. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2675. #endif
  2676. #if DEPTH_PACKING == 3200
  2677. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2678. #elif DEPTH_PACKING == 3201
  2679. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2680. #elif DEPTH_PACKING == 3202
  2681. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2682. #elif DEPTH_PACKING == 3203
  2683. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2684. #endif
  2685. }`,hPe=`#define DISTANCE
  2686. varying vec3 vWorldPosition;
  2687. #include <common>
  2688. #include <batching_pars_vertex>
  2689. #include <uv_pars_vertex>
  2690. #include <displacementmap_pars_vertex>
  2691. #include <morphtarget_pars_vertex>
  2692. #include <skinning_pars_vertex>
  2693. #include <clipping_planes_pars_vertex>
  2694. void main() {
  2695. #include <uv_vertex>
  2696. #include <batching_vertex>
  2697. #include <skinbase_vertex>
  2698. #include <morphinstance_vertex>
  2699. #ifdef USE_DISPLACEMENTMAP
  2700. #include <beginnormal_vertex>
  2701. #include <morphnormal_vertex>
  2702. #include <skinnormal_vertex>
  2703. #endif
  2704. #include <begin_vertex>
  2705. #include <morphtarget_vertex>
  2706. #include <skinning_vertex>
  2707. #include <displacementmap_vertex>
  2708. #include <project_vertex>
  2709. #include <worldpos_vertex>
  2710. #include <clipping_planes_vertex>
  2711. vWorldPosition = worldPosition.xyz;
  2712. }`,fPe=`#define DISTANCE
  2713. uniform vec3 referencePosition;
  2714. uniform float nearDistance;
  2715. uniform float farDistance;
  2716. varying vec3 vWorldPosition;
  2717. #include <common>
  2718. #include <packing>
  2719. #include <uv_pars_fragment>
  2720. #include <map_pars_fragment>
  2721. #include <alphamap_pars_fragment>
  2722. #include <alphatest_pars_fragment>
  2723. #include <alphahash_pars_fragment>
  2724. #include <clipping_planes_pars_fragment>
  2725. void main () {
  2726. vec4 diffuseColor = vec4( 1.0 );
  2727. #include <clipping_planes_fragment>
  2728. #include <map_fragment>
  2729. #include <alphamap_fragment>
  2730. #include <alphatest_fragment>
  2731. #include <alphahash_fragment>
  2732. float dist = length( vWorldPosition - referencePosition );
  2733. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2734. dist = saturate( dist );
  2735. gl_FragColor = packDepthToRGBA( dist );
  2736. }`,pPe=`varying vec3 vWorldDirection;
  2737. #include <common>
  2738. void main() {
  2739. vWorldDirection = transformDirection( position, modelMatrix );
  2740. #include <begin_vertex>
  2741. #include <project_vertex>
  2742. }`,mPe=`uniform sampler2D tEquirect;
  2743. varying vec3 vWorldDirection;
  2744. #include <common>
  2745. void main() {
  2746. vec3 direction = normalize( vWorldDirection );
  2747. vec2 sampleUV = equirectUv( direction );
  2748. gl_FragColor = texture2D( tEquirect, sampleUV );
  2749. #include <tonemapping_fragment>
  2750. #include <colorspace_fragment>
  2751. }`,gPe=`uniform float scale;
  2752. attribute float lineDistance;
  2753. varying float vLineDistance;
  2754. #include <common>
  2755. #include <uv_pars_vertex>
  2756. #include <color_pars_vertex>
  2757. #include <fog_pars_vertex>
  2758. #include <morphtarget_pars_vertex>
  2759. #include <logdepthbuf_pars_vertex>
  2760. #include <clipping_planes_pars_vertex>
  2761. void main() {
  2762. vLineDistance = scale * lineDistance;
  2763. #include <uv_vertex>
  2764. #include <color_vertex>
  2765. #include <morphinstance_vertex>
  2766. #include <morphcolor_vertex>
  2767. #include <begin_vertex>
  2768. #include <morphtarget_vertex>
  2769. #include <project_vertex>
  2770. #include <logdepthbuf_vertex>
  2771. #include <clipping_planes_vertex>
  2772. #include <fog_vertex>
  2773. }`,xPe=`uniform vec3 diffuse;
  2774. uniform float opacity;
  2775. uniform float dashSize;
  2776. uniform float totalSize;
  2777. varying float vLineDistance;
  2778. #include <common>
  2779. #include <color_pars_fragment>
  2780. #include <uv_pars_fragment>
  2781. #include <map_pars_fragment>
  2782. #include <fog_pars_fragment>
  2783. #include <logdepthbuf_pars_fragment>
  2784. #include <clipping_planes_pars_fragment>
  2785. void main() {
  2786. vec4 diffuseColor = vec4( diffuse, opacity );
  2787. #include <clipping_planes_fragment>
  2788. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2789. discard;
  2790. }
  2791. vec3 outgoingLight = vec3( 0.0 );
  2792. #include <logdepthbuf_fragment>
  2793. #include <map_fragment>
  2794. #include <color_fragment>
  2795. outgoingLight = diffuseColor.rgb;
  2796. #include <opaque_fragment>
  2797. #include <tonemapping_fragment>
  2798. #include <colorspace_fragment>
  2799. #include <fog_fragment>
  2800. #include <premultiplied_alpha_fragment>
  2801. }`,bPe=`#include <common>
  2802. #include <batching_pars_vertex>
  2803. #include <uv_pars_vertex>
  2804. #include <envmap_pars_vertex>
  2805. #include <color_pars_vertex>
  2806. #include <fog_pars_vertex>
  2807. #include <morphtarget_pars_vertex>
  2808. #include <skinning_pars_vertex>
  2809. #include <logdepthbuf_pars_vertex>
  2810. #include <clipping_planes_pars_vertex>
  2811. void main() {
  2812. #include <uv_vertex>
  2813. #include <color_vertex>
  2814. #include <morphinstance_vertex>
  2815. #include <morphcolor_vertex>
  2816. #include <batching_vertex>
  2817. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2818. #include <beginnormal_vertex>
  2819. #include <morphnormal_vertex>
  2820. #include <skinbase_vertex>
  2821. #include <skinnormal_vertex>
  2822. #include <defaultnormal_vertex>
  2823. #endif
  2824. #include <begin_vertex>
  2825. #include <morphtarget_vertex>
  2826. #include <skinning_vertex>
  2827. #include <project_vertex>
  2828. #include <logdepthbuf_vertex>
  2829. #include <clipping_planes_vertex>
  2830. #include <worldpos_vertex>
  2831. #include <envmap_vertex>
  2832. #include <fog_vertex>
  2833. }`,yPe=`uniform vec3 diffuse;
  2834. uniform float opacity;
  2835. #ifndef FLAT_SHADED
  2836. varying vec3 vNormal;
  2837. #endif
  2838. #include <common>
  2839. #include <dithering_pars_fragment>
  2840. #include <color_pars_fragment>
  2841. #include <uv_pars_fragment>
  2842. #include <map_pars_fragment>
  2843. #include <alphamap_pars_fragment>
  2844. #include <alphatest_pars_fragment>
  2845. #include <alphahash_pars_fragment>
  2846. #include <aomap_pars_fragment>
  2847. #include <lightmap_pars_fragment>
  2848. #include <envmap_common_pars_fragment>
  2849. #include <envmap_pars_fragment>
  2850. #include <fog_pars_fragment>
  2851. #include <specularmap_pars_fragment>
  2852. #include <logdepthbuf_pars_fragment>
  2853. #include <clipping_planes_pars_fragment>
  2854. void main() {
  2855. vec4 diffuseColor = vec4( diffuse, opacity );
  2856. #include <clipping_planes_fragment>
  2857. #include <logdepthbuf_fragment>
  2858. #include <map_fragment>
  2859. #include <color_fragment>
  2860. #include <alphamap_fragment>
  2861. #include <alphatest_fragment>
  2862. #include <alphahash_fragment>
  2863. #include <specularmap_fragment>
  2864. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2865. #ifdef USE_LIGHTMAP
  2866. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2867. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2868. #else
  2869. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2870. #endif
  2871. #include <aomap_fragment>
  2872. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2873. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2874. #include <envmap_fragment>
  2875. #include <opaque_fragment>
  2876. #include <tonemapping_fragment>
  2877. #include <colorspace_fragment>
  2878. #include <fog_fragment>
  2879. #include <premultiplied_alpha_fragment>
  2880. #include <dithering_fragment>
  2881. }`,vPe=`#define LAMBERT
  2882. varying vec3 vViewPosition;
  2883. #include <common>
  2884. #include <batching_pars_vertex>
  2885. #include <uv_pars_vertex>
  2886. #include <displacementmap_pars_vertex>
  2887. #include <envmap_pars_vertex>
  2888. #include <color_pars_vertex>
  2889. #include <fog_pars_vertex>
  2890. #include <normal_pars_vertex>
  2891. #include <morphtarget_pars_vertex>
  2892. #include <skinning_pars_vertex>
  2893. #include <shadowmap_pars_vertex>
  2894. #include <logdepthbuf_pars_vertex>
  2895. #include <clipping_planes_pars_vertex>
  2896. void main() {
  2897. #include <uv_vertex>
  2898. #include <color_vertex>
  2899. #include <morphinstance_vertex>
  2900. #include <morphcolor_vertex>
  2901. #include <batching_vertex>
  2902. #include <beginnormal_vertex>
  2903. #include <morphnormal_vertex>
  2904. #include <skinbase_vertex>
  2905. #include <skinnormal_vertex>
  2906. #include <defaultnormal_vertex>
  2907. #include <normal_vertex>
  2908. #include <begin_vertex>
  2909. #include <morphtarget_vertex>
  2910. #include <skinning_vertex>
  2911. #include <displacementmap_vertex>
  2912. #include <project_vertex>
  2913. #include <logdepthbuf_vertex>
  2914. #include <clipping_planes_vertex>
  2915. vViewPosition = - mvPosition.xyz;
  2916. #include <worldpos_vertex>
  2917. #include <envmap_vertex>
  2918. #include <shadowmap_vertex>
  2919. #include <fog_vertex>
  2920. }`,_Pe=`#define LAMBERT
  2921. uniform vec3 diffuse;
  2922. uniform vec3 emissive;
  2923. uniform float opacity;
  2924. #include <common>
  2925. #include <packing>
  2926. #include <dithering_pars_fragment>
  2927. #include <color_pars_fragment>
  2928. #include <uv_pars_fragment>
  2929. #include <map_pars_fragment>
  2930. #include <alphamap_pars_fragment>
  2931. #include <alphatest_pars_fragment>
  2932. #include <alphahash_pars_fragment>
  2933. #include <aomap_pars_fragment>
  2934. #include <lightmap_pars_fragment>
  2935. #include <emissivemap_pars_fragment>
  2936. #include <envmap_common_pars_fragment>
  2937. #include <envmap_pars_fragment>
  2938. #include <fog_pars_fragment>
  2939. #include <bsdfs>
  2940. #include <lights_pars_begin>
  2941. #include <normal_pars_fragment>
  2942. #include <lights_lambert_pars_fragment>
  2943. #include <shadowmap_pars_fragment>
  2944. #include <bumpmap_pars_fragment>
  2945. #include <normalmap_pars_fragment>
  2946. #include <specularmap_pars_fragment>
  2947. #include <logdepthbuf_pars_fragment>
  2948. #include <clipping_planes_pars_fragment>
  2949. void main() {
  2950. vec4 diffuseColor = vec4( diffuse, opacity );
  2951. #include <clipping_planes_fragment>
  2952. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2953. vec3 totalEmissiveRadiance = emissive;
  2954. #include <logdepthbuf_fragment>
  2955. #include <map_fragment>
  2956. #include <color_fragment>
  2957. #include <alphamap_fragment>
  2958. #include <alphatest_fragment>
  2959. #include <alphahash_fragment>
  2960. #include <specularmap_fragment>
  2961. #include <normal_fragment_begin>
  2962. #include <normal_fragment_maps>
  2963. #include <emissivemap_fragment>
  2964. #include <lights_lambert_fragment>
  2965. #include <lights_fragment_begin>
  2966. #include <lights_fragment_maps>
  2967. #include <lights_fragment_end>
  2968. #include <aomap_fragment>
  2969. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2970. #include <envmap_fragment>
  2971. #include <opaque_fragment>
  2972. #include <tonemapping_fragment>
  2973. #include <colorspace_fragment>
  2974. #include <fog_fragment>
  2975. #include <premultiplied_alpha_fragment>
  2976. #include <dithering_fragment>
  2977. }`,wPe=`#define MATCAP
  2978. varying vec3 vViewPosition;
  2979. #include <common>
  2980. #include <batching_pars_vertex>
  2981. #include <uv_pars_vertex>
  2982. #include <color_pars_vertex>
  2983. #include <displacementmap_pars_vertex>
  2984. #include <fog_pars_vertex>
  2985. #include <normal_pars_vertex>
  2986. #include <morphtarget_pars_vertex>
  2987. #include <skinning_pars_vertex>
  2988. #include <logdepthbuf_pars_vertex>
  2989. #include <clipping_planes_pars_vertex>
  2990. void main() {
  2991. #include <uv_vertex>
  2992. #include <color_vertex>
  2993. #include <morphinstance_vertex>
  2994. #include <morphcolor_vertex>
  2995. #include <batching_vertex>
  2996. #include <beginnormal_vertex>
  2997. #include <morphnormal_vertex>
  2998. #include <skinbase_vertex>
  2999. #include <skinnormal_vertex>
  3000. #include <defaultnormal_vertex>
  3001. #include <normal_vertex>
  3002. #include <begin_vertex>
  3003. #include <morphtarget_vertex>
  3004. #include <skinning_vertex>
  3005. #include <displacementmap_vertex>
  3006. #include <project_vertex>
  3007. #include <logdepthbuf_vertex>
  3008. #include <clipping_planes_vertex>
  3009. #include <fog_vertex>
  3010. vViewPosition = - mvPosition.xyz;
  3011. }`,SPe=`#define MATCAP
  3012. uniform vec3 diffuse;
  3013. uniform float opacity;
  3014. uniform sampler2D matcap;
  3015. varying vec3 vViewPosition;
  3016. #include <common>
  3017. #include <dithering_pars_fragment>
  3018. #include <color_pars_fragment>
  3019. #include <uv_pars_fragment>
  3020. #include <map_pars_fragment>
  3021. #include <alphamap_pars_fragment>
  3022. #include <alphatest_pars_fragment>
  3023. #include <alphahash_pars_fragment>
  3024. #include <fog_pars_fragment>
  3025. #include <normal_pars_fragment>
  3026. #include <bumpmap_pars_fragment>
  3027. #include <normalmap_pars_fragment>
  3028. #include <logdepthbuf_pars_fragment>
  3029. #include <clipping_planes_pars_fragment>
  3030. void main() {
  3031. vec4 diffuseColor = vec4( diffuse, opacity );
  3032. #include <clipping_planes_fragment>
  3033. #include <logdepthbuf_fragment>
  3034. #include <map_fragment>
  3035. #include <color_fragment>
  3036. #include <alphamap_fragment>
  3037. #include <alphatest_fragment>
  3038. #include <alphahash_fragment>
  3039. #include <normal_fragment_begin>
  3040. #include <normal_fragment_maps>
  3041. vec3 viewDir = normalize( vViewPosition );
  3042. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3043. vec3 y = cross( viewDir, x );
  3044. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3045. #ifdef USE_MATCAP
  3046. vec4 matcapColor = texture2D( matcap, uv );
  3047. #else
  3048. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3049. #endif
  3050. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3051. #include <opaque_fragment>
  3052. #include <tonemapping_fragment>
  3053. #include <colorspace_fragment>
  3054. #include <fog_fragment>
  3055. #include <premultiplied_alpha_fragment>
  3056. #include <dithering_fragment>
  3057. }`,MPe=`#define NORMAL
  3058. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3059. varying vec3 vViewPosition;
  3060. #endif
  3061. #include <common>
  3062. #include <batching_pars_vertex>
  3063. #include <uv_pars_vertex>
  3064. #include <displacementmap_pars_vertex>
  3065. #include <normal_pars_vertex>
  3066. #include <morphtarget_pars_vertex>
  3067. #include <skinning_pars_vertex>
  3068. #include <logdepthbuf_pars_vertex>
  3069. #include <clipping_planes_pars_vertex>
  3070. void main() {
  3071. #include <uv_vertex>
  3072. #include <batching_vertex>
  3073. #include <beginnormal_vertex>
  3074. #include <morphinstance_vertex>
  3075. #include <morphnormal_vertex>
  3076. #include <skinbase_vertex>
  3077. #include <skinnormal_vertex>
  3078. #include <defaultnormal_vertex>
  3079. #include <normal_vertex>
  3080. #include <begin_vertex>
  3081. #include <morphtarget_vertex>
  3082. #include <skinning_vertex>
  3083. #include <displacementmap_vertex>
  3084. #include <project_vertex>
  3085. #include <logdepthbuf_vertex>
  3086. #include <clipping_planes_vertex>
  3087. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3088. vViewPosition = - mvPosition.xyz;
  3089. #endif
  3090. }`,EPe=`#define NORMAL
  3091. uniform float opacity;
  3092. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3093. varying vec3 vViewPosition;
  3094. #endif
  3095. #include <packing>
  3096. #include <uv_pars_fragment>
  3097. #include <normal_pars_fragment>
  3098. #include <bumpmap_pars_fragment>
  3099. #include <normalmap_pars_fragment>
  3100. #include <logdepthbuf_pars_fragment>
  3101. #include <clipping_planes_pars_fragment>
  3102. void main() {
  3103. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3104. #include <clipping_planes_fragment>
  3105. #include <logdepthbuf_fragment>
  3106. #include <normal_fragment_begin>
  3107. #include <normal_fragment_maps>
  3108. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3109. #ifdef OPAQUE
  3110. gl_FragColor.a = 1.0;
  3111. #endif
  3112. }`,APe=`#define PHONG
  3113. varying vec3 vViewPosition;
  3114. #include <common>
  3115. #include <batching_pars_vertex>
  3116. #include <uv_pars_vertex>
  3117. #include <displacementmap_pars_vertex>
  3118. #include <envmap_pars_vertex>
  3119. #include <color_pars_vertex>
  3120. #include <fog_pars_vertex>
  3121. #include <normal_pars_vertex>
  3122. #include <morphtarget_pars_vertex>
  3123. #include <skinning_pars_vertex>
  3124. #include <shadowmap_pars_vertex>
  3125. #include <logdepthbuf_pars_vertex>
  3126. #include <clipping_planes_pars_vertex>
  3127. void main() {
  3128. #include <uv_vertex>
  3129. #include <color_vertex>
  3130. #include <morphcolor_vertex>
  3131. #include <batching_vertex>
  3132. #include <beginnormal_vertex>
  3133. #include <morphinstance_vertex>
  3134. #include <morphnormal_vertex>
  3135. #include <skinbase_vertex>
  3136. #include <skinnormal_vertex>
  3137. #include <defaultnormal_vertex>
  3138. #include <normal_vertex>
  3139. #include <begin_vertex>
  3140. #include <morphtarget_vertex>
  3141. #include <skinning_vertex>
  3142. #include <displacementmap_vertex>
  3143. #include <project_vertex>
  3144. #include <logdepthbuf_vertex>
  3145. #include <clipping_planes_vertex>
  3146. vViewPosition = - mvPosition.xyz;
  3147. #include <worldpos_vertex>
  3148. #include <envmap_vertex>
  3149. #include <shadowmap_vertex>
  3150. #include <fog_vertex>
  3151. }`,TPe=`#define PHONG
  3152. uniform vec3 diffuse;
  3153. uniform vec3 emissive;
  3154. uniform vec3 specular;
  3155. uniform float shininess;
  3156. uniform float opacity;
  3157. #include <common>
  3158. #include <packing>
  3159. #include <dithering_pars_fragment>
  3160. #include <color_pars_fragment>
  3161. #include <uv_pars_fragment>
  3162. #include <map_pars_fragment>
  3163. #include <alphamap_pars_fragment>
  3164. #include <alphatest_pars_fragment>
  3165. #include <alphahash_pars_fragment>
  3166. #include <aomap_pars_fragment>
  3167. #include <lightmap_pars_fragment>
  3168. #include <emissivemap_pars_fragment>
  3169. #include <envmap_common_pars_fragment>
  3170. #include <envmap_pars_fragment>
  3171. #include <fog_pars_fragment>
  3172. #include <bsdfs>
  3173. #include <lights_pars_begin>
  3174. #include <normal_pars_fragment>
  3175. #include <lights_phong_pars_fragment>
  3176. #include <shadowmap_pars_fragment>
  3177. #include <bumpmap_pars_fragment>
  3178. #include <normalmap_pars_fragment>
  3179. #include <specularmap_pars_fragment>
  3180. #include <logdepthbuf_pars_fragment>
  3181. #include <clipping_planes_pars_fragment>
  3182. void main() {
  3183. vec4 diffuseColor = vec4( diffuse, opacity );
  3184. #include <clipping_planes_fragment>
  3185. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3186. vec3 totalEmissiveRadiance = emissive;
  3187. #include <logdepthbuf_fragment>
  3188. #include <map_fragment>
  3189. #include <color_fragment>
  3190. #include <alphamap_fragment>
  3191. #include <alphatest_fragment>
  3192. #include <alphahash_fragment>
  3193. #include <specularmap_fragment>
  3194. #include <normal_fragment_begin>
  3195. #include <normal_fragment_maps>
  3196. #include <emissivemap_fragment>
  3197. #include <lights_phong_fragment>
  3198. #include <lights_fragment_begin>
  3199. #include <lights_fragment_maps>
  3200. #include <lights_fragment_end>
  3201. #include <aomap_fragment>
  3202. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3203. #include <envmap_fragment>
  3204. #include <opaque_fragment>
  3205. #include <tonemapping_fragment>
  3206. #include <colorspace_fragment>
  3207. #include <fog_fragment>
  3208. #include <premultiplied_alpha_fragment>
  3209. #include <dithering_fragment>
  3210. }`,CPe=`#define STANDARD
  3211. varying vec3 vViewPosition;
  3212. #ifdef USE_TRANSMISSION
  3213. varying vec3 vWorldPosition;
  3214. #endif
  3215. #include <common>
  3216. #include <batching_pars_vertex>
  3217. #include <uv_pars_vertex>
  3218. #include <displacementmap_pars_vertex>
  3219. #include <color_pars_vertex>
  3220. #include <fog_pars_vertex>
  3221. #include <normal_pars_vertex>
  3222. #include <morphtarget_pars_vertex>
  3223. #include <skinning_pars_vertex>
  3224. #include <shadowmap_pars_vertex>
  3225. #include <logdepthbuf_pars_vertex>
  3226. #include <clipping_planes_pars_vertex>
  3227. void main() {
  3228. #include <uv_vertex>
  3229. #include <color_vertex>
  3230. #include <morphinstance_vertex>
  3231. #include <morphcolor_vertex>
  3232. #include <batching_vertex>
  3233. #include <beginnormal_vertex>
  3234. #include <morphnormal_vertex>
  3235. #include <skinbase_vertex>
  3236. #include <skinnormal_vertex>
  3237. #include <defaultnormal_vertex>
  3238. #include <normal_vertex>
  3239. #include <begin_vertex>
  3240. #include <morphtarget_vertex>
  3241. #include <skinning_vertex>
  3242. #include <displacementmap_vertex>
  3243. #include <project_vertex>
  3244. #include <logdepthbuf_vertex>
  3245. #include <clipping_planes_vertex>
  3246. vViewPosition = - mvPosition.xyz;
  3247. #include <worldpos_vertex>
  3248. #include <shadowmap_vertex>
  3249. #include <fog_vertex>
  3250. #ifdef USE_TRANSMISSION
  3251. vWorldPosition = worldPosition.xyz;
  3252. #endif
  3253. }`,NPe=`#define STANDARD
  3254. #ifdef PHYSICAL
  3255. #define IOR
  3256. #define USE_SPECULAR
  3257. #endif
  3258. uniform vec3 diffuse;
  3259. uniform vec3 emissive;
  3260. uniform float roughness;
  3261. uniform float metalness;
  3262. uniform float opacity;
  3263. #ifdef IOR
  3264. uniform float ior;
  3265. #endif
  3266. #ifdef USE_SPECULAR
  3267. uniform float specularIntensity;
  3268. uniform vec3 specularColor;
  3269. #ifdef USE_SPECULAR_COLORMAP
  3270. uniform sampler2D specularColorMap;
  3271. #endif
  3272. #ifdef USE_SPECULAR_INTENSITYMAP
  3273. uniform sampler2D specularIntensityMap;
  3274. #endif
  3275. #endif
  3276. #ifdef USE_CLEARCOAT
  3277. uniform float clearcoat;
  3278. uniform float clearcoatRoughness;
  3279. #endif
  3280. #ifdef USE_DISPERSION
  3281. uniform float dispersion;
  3282. #endif
  3283. #ifdef USE_IRIDESCENCE
  3284. uniform float iridescence;
  3285. uniform float iridescenceIOR;
  3286. uniform float iridescenceThicknessMinimum;
  3287. uniform float iridescenceThicknessMaximum;
  3288. #endif
  3289. #ifdef USE_SHEEN
  3290. uniform vec3 sheenColor;
  3291. uniform float sheenRoughness;
  3292. #ifdef USE_SHEEN_COLORMAP
  3293. uniform sampler2D sheenColorMap;
  3294. #endif
  3295. #ifdef USE_SHEEN_ROUGHNESSMAP
  3296. uniform sampler2D sheenRoughnessMap;
  3297. #endif
  3298. #endif
  3299. #ifdef USE_ANISOTROPY
  3300. uniform vec2 anisotropyVector;
  3301. #ifdef USE_ANISOTROPYMAP
  3302. uniform sampler2D anisotropyMap;
  3303. #endif
  3304. #endif
  3305. varying vec3 vViewPosition;
  3306. #include <common>
  3307. #include <packing>
  3308. #include <dithering_pars_fragment>
  3309. #include <color_pars_fragment>
  3310. #include <uv_pars_fragment>
  3311. #include <map_pars_fragment>
  3312. #include <alphamap_pars_fragment>
  3313. #include <alphatest_pars_fragment>
  3314. #include <alphahash_pars_fragment>
  3315. #include <aomap_pars_fragment>
  3316. #include <lightmap_pars_fragment>
  3317. #include <emissivemap_pars_fragment>
  3318. #include <iridescence_fragment>
  3319. #include <cube_uv_reflection_fragment>
  3320. #include <envmap_common_pars_fragment>
  3321. #include <envmap_physical_pars_fragment>
  3322. #include <fog_pars_fragment>
  3323. #include <lights_pars_begin>
  3324. #include <normal_pars_fragment>
  3325. #include <lights_physical_pars_fragment>
  3326. #include <transmission_pars_fragment>
  3327. #include <shadowmap_pars_fragment>
  3328. #include <bumpmap_pars_fragment>
  3329. #include <normalmap_pars_fragment>
  3330. #include <clearcoat_pars_fragment>
  3331. #include <iridescence_pars_fragment>
  3332. #include <roughnessmap_pars_fragment>
  3333. #include <metalnessmap_pars_fragment>
  3334. #include <logdepthbuf_pars_fragment>
  3335. #include <clipping_planes_pars_fragment>
  3336. void main() {
  3337. vec4 diffuseColor = vec4( diffuse, opacity );
  3338. #include <clipping_planes_fragment>
  3339. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3340. vec3 totalEmissiveRadiance = emissive;
  3341. #include <logdepthbuf_fragment>
  3342. #include <map_fragment>
  3343. #include <color_fragment>
  3344. #include <alphamap_fragment>
  3345. #include <alphatest_fragment>
  3346. #include <alphahash_fragment>
  3347. #include <roughnessmap_fragment>
  3348. #include <metalnessmap_fragment>
  3349. #include <normal_fragment_begin>
  3350. #include <normal_fragment_maps>
  3351. #include <clearcoat_normal_fragment_begin>
  3352. #include <clearcoat_normal_fragment_maps>
  3353. #include <emissivemap_fragment>
  3354. #include <lights_physical_fragment>
  3355. #include <lights_fragment_begin>
  3356. #include <lights_fragment_maps>
  3357. #include <lights_fragment_end>
  3358. #include <aomap_fragment>
  3359. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3360. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3361. #include <transmission_fragment>
  3362. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3363. #ifdef USE_SHEEN
  3364. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3365. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3366. #endif
  3367. #ifdef USE_CLEARCOAT
  3368. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3369. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3370. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3371. #endif
  3372. #include <opaque_fragment>
  3373. #include <tonemapping_fragment>
  3374. #include <colorspace_fragment>
  3375. #include <fog_fragment>
  3376. #include <premultiplied_alpha_fragment>
  3377. #include <dithering_fragment>
  3378. }`,kPe=`#define TOON
  3379. varying vec3 vViewPosition;
  3380. #include <common>
  3381. #include <batching_pars_vertex>
  3382. #include <uv_pars_vertex>
  3383. #include <displacementmap_pars_vertex>
  3384. #include <color_pars_vertex>
  3385. #include <fog_pars_vertex>
  3386. #include <normal_pars_vertex>
  3387. #include <morphtarget_pars_vertex>
  3388. #include <skinning_pars_vertex>
  3389. #include <shadowmap_pars_vertex>
  3390. #include <logdepthbuf_pars_vertex>
  3391. #include <clipping_planes_pars_vertex>
  3392. void main() {
  3393. #include <uv_vertex>
  3394. #include <color_vertex>
  3395. #include <morphinstance_vertex>
  3396. #include <morphcolor_vertex>
  3397. #include <batching_vertex>
  3398. #include <beginnormal_vertex>
  3399. #include <morphnormal_vertex>
  3400. #include <skinbase_vertex>
  3401. #include <skinnormal_vertex>
  3402. #include <defaultnormal_vertex>
  3403. #include <normal_vertex>
  3404. #include <begin_vertex>
  3405. #include <morphtarget_vertex>
  3406. #include <skinning_vertex>
  3407. #include <displacementmap_vertex>
  3408. #include <project_vertex>
  3409. #include <logdepthbuf_vertex>
  3410. #include <clipping_planes_vertex>
  3411. vViewPosition = - mvPosition.xyz;
  3412. #include <worldpos_vertex>
  3413. #include <shadowmap_vertex>
  3414. #include <fog_vertex>
  3415. }`,PPe=`#define TOON
  3416. uniform vec3 diffuse;
  3417. uniform vec3 emissive;
  3418. uniform float opacity;
  3419. #include <common>
  3420. #include <packing>
  3421. #include <dithering_pars_fragment>
  3422. #include <color_pars_fragment>
  3423. #include <uv_pars_fragment>
  3424. #include <map_pars_fragment>
  3425. #include <alphamap_pars_fragment>
  3426. #include <alphatest_pars_fragment>
  3427. #include <alphahash_pars_fragment>
  3428. #include <aomap_pars_fragment>
  3429. #include <lightmap_pars_fragment>
  3430. #include <emissivemap_pars_fragment>
  3431. #include <gradientmap_pars_fragment>
  3432. #include <fog_pars_fragment>
  3433. #include <bsdfs>
  3434. #include <lights_pars_begin>
  3435. #include <normal_pars_fragment>
  3436. #include <lights_toon_pars_fragment>
  3437. #include <shadowmap_pars_fragment>
  3438. #include <bumpmap_pars_fragment>
  3439. #include <normalmap_pars_fragment>
  3440. #include <logdepthbuf_pars_fragment>
  3441. #include <clipping_planes_pars_fragment>
  3442. void main() {
  3443. vec4 diffuseColor = vec4( diffuse, opacity );
  3444. #include <clipping_planes_fragment>
  3445. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3446. vec3 totalEmissiveRadiance = emissive;
  3447. #include <logdepthbuf_fragment>
  3448. #include <map_fragment>
  3449. #include <color_fragment>
  3450. #include <alphamap_fragment>
  3451. #include <alphatest_fragment>
  3452. #include <alphahash_fragment>
  3453. #include <normal_fragment_begin>
  3454. #include <normal_fragment_maps>
  3455. #include <emissivemap_fragment>
  3456. #include <lights_toon_fragment>
  3457. #include <lights_fragment_begin>
  3458. #include <lights_fragment_maps>
  3459. #include <lights_fragment_end>
  3460. #include <aomap_fragment>
  3461. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3462. #include <opaque_fragment>
  3463. #include <tonemapping_fragment>
  3464. #include <colorspace_fragment>
  3465. #include <fog_fragment>
  3466. #include <premultiplied_alpha_fragment>
  3467. #include <dithering_fragment>
  3468. }`,RPe=`uniform float size;
  3469. uniform float scale;
  3470. #include <common>
  3471. #include <color_pars_vertex>
  3472. #include <fog_pars_vertex>
  3473. #include <morphtarget_pars_vertex>
  3474. #include <logdepthbuf_pars_vertex>
  3475. #include <clipping_planes_pars_vertex>
  3476. #ifdef USE_POINTS_UV
  3477. varying vec2 vUv;
  3478. uniform mat3 uvTransform;
  3479. #endif
  3480. void main() {
  3481. #ifdef USE_POINTS_UV
  3482. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3483. #endif
  3484. #include <color_vertex>
  3485. #include <morphinstance_vertex>
  3486. #include <morphcolor_vertex>
  3487. #include <begin_vertex>
  3488. #include <morphtarget_vertex>
  3489. #include <project_vertex>
  3490. gl_PointSize = size;
  3491. #ifdef USE_SIZEATTENUATION
  3492. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3493. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3494. #endif
  3495. #include <logdepthbuf_vertex>
  3496. #include <clipping_planes_vertex>
  3497. #include <worldpos_vertex>
  3498. #include <fog_vertex>
  3499. }`,DPe=`uniform vec3 diffuse;
  3500. uniform float opacity;
  3501. #include <common>
  3502. #include <color_pars_fragment>
  3503. #include <map_particle_pars_fragment>
  3504. #include <alphatest_pars_fragment>
  3505. #include <alphahash_pars_fragment>
  3506. #include <fog_pars_fragment>
  3507. #include <logdepthbuf_pars_fragment>
  3508. #include <clipping_planes_pars_fragment>
  3509. void main() {
  3510. vec4 diffuseColor = vec4( diffuse, opacity );
  3511. #include <clipping_planes_fragment>
  3512. vec3 outgoingLight = vec3( 0.0 );
  3513. #include <logdepthbuf_fragment>
  3514. #include <map_particle_fragment>
  3515. #include <color_fragment>
  3516. #include <alphatest_fragment>
  3517. #include <alphahash_fragment>
  3518. outgoingLight = diffuseColor.rgb;
  3519. #include <opaque_fragment>
  3520. #include <tonemapping_fragment>
  3521. #include <colorspace_fragment>
  3522. #include <fog_fragment>
  3523. #include <premultiplied_alpha_fragment>
  3524. }`,jPe=`#include <common>
  3525. #include <batching_pars_vertex>
  3526. #include <fog_pars_vertex>
  3527. #include <morphtarget_pars_vertex>
  3528. #include <skinning_pars_vertex>
  3529. #include <logdepthbuf_pars_vertex>
  3530. #include <shadowmap_pars_vertex>
  3531. void main() {
  3532. #include <batching_vertex>
  3533. #include <beginnormal_vertex>
  3534. #include <morphinstance_vertex>
  3535. #include <morphnormal_vertex>
  3536. #include <skinbase_vertex>
  3537. #include <skinnormal_vertex>
  3538. #include <defaultnormal_vertex>
  3539. #include <begin_vertex>
  3540. #include <morphtarget_vertex>
  3541. #include <skinning_vertex>
  3542. #include <project_vertex>
  3543. #include <logdepthbuf_vertex>
  3544. #include <worldpos_vertex>
  3545. #include <shadowmap_vertex>
  3546. #include <fog_vertex>
  3547. }`,OPe=`uniform vec3 color;
  3548. uniform float opacity;
  3549. #include <common>
  3550. #include <packing>
  3551. #include <fog_pars_fragment>
  3552. #include <bsdfs>
  3553. #include <lights_pars_begin>
  3554. #include <logdepthbuf_pars_fragment>
  3555. #include <shadowmap_pars_fragment>
  3556. #include <shadowmask_pars_fragment>
  3557. void main() {
  3558. #include <logdepthbuf_fragment>
  3559. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3560. #include <tonemapping_fragment>
  3561. #include <colorspace_fragment>
  3562. #include <fog_fragment>
  3563. }`,LPe=`uniform float rotation;
  3564. uniform vec2 center;
  3565. #include <common>
  3566. #include <uv_pars_vertex>
  3567. #include <fog_pars_vertex>
  3568. #include <logdepthbuf_pars_vertex>
  3569. #include <clipping_planes_pars_vertex>
  3570. void main() {
  3571. #include <uv_vertex>
  3572. vec4 mvPosition = modelViewMatrix[ 3 ];
  3573. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3574. #ifndef USE_SIZEATTENUATION
  3575. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3576. if ( isPerspective ) scale *= - mvPosition.z;
  3577. #endif
  3578. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3579. vec2 rotatedPosition;
  3580. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3581. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3582. mvPosition.xy += rotatedPosition;
  3583. gl_Position = projectionMatrix * mvPosition;
  3584. #include <logdepthbuf_vertex>
  3585. #include <clipping_planes_vertex>
  3586. #include <fog_vertex>
  3587. }`,IPe=`uniform vec3 diffuse;
  3588. uniform float opacity;
  3589. #include <common>
  3590. #include <uv_pars_fragment>
  3591. #include <map_pars_fragment>
  3592. #include <alphamap_pars_fragment>
  3593. #include <alphatest_pars_fragment>
  3594. #include <alphahash_pars_fragment>
  3595. #include <fog_pars_fragment>
  3596. #include <logdepthbuf_pars_fragment>
  3597. #include <clipping_planes_pars_fragment>
  3598. void main() {
  3599. vec4 diffuseColor = vec4( diffuse, opacity );
  3600. #include <clipping_planes_fragment>
  3601. vec3 outgoingLight = vec3( 0.0 );
  3602. #include <logdepthbuf_fragment>
  3603. #include <map_fragment>
  3604. #include <alphamap_fragment>
  3605. #include <alphatest_fragment>
  3606. #include <alphahash_fragment>
  3607. outgoingLight = diffuseColor.rgb;
  3608. #include <opaque_fragment>
  3609. #include <tonemapping_fragment>
  3610. #include <colorspace_fragment>
  3611. #include <fog_fragment>
  3612. }`,on={alphahash_fragment:ake,alphahash_pars_fragment:ske,alphamap_fragment:oke,alphamap_pars_fragment:lke,alphatest_fragment:cke,alphatest_pars_fragment:uke,aomap_fragment:dke,aomap_pars_fragment:hke,batching_pars_vertex:fke,batching_vertex:pke,begin_vertex:mke,beginnormal_vertex:gke,bsdfs:xke,iridescence_fragment:bke,bumpmap_pars_fragment:yke,clipping_planes_fragment:vke,clipping_planes_pars_fragment:_ke,clipping_planes_pars_vertex:wke,clipping_planes_vertex:Ske,color_fragment:Mke,color_pars_fragment:Eke,color_pars_vertex:Ake,color_vertex:Tke,common:Cke,cube_uv_reflection_fragment:Nke,defaultnormal_vertex:kke,displacementmap_pars_vertex:Pke,displacementmap_vertex:Rke,emissivemap_fragment:Dke,emissivemap_pars_fragment:jke,colorspace_fragment:Oke,colorspace_pars_fragment:Lke,envmap_fragment:Ike,envmap_common_pars_fragment:Fke,envmap_pars_fragment:Uke,envmap_pars_vertex:zke,envmap_physical_pars_fragment:Zke,envmap_vertex:Bke,fog_vertex:Hke,fog_pars_vertex:$ke,fog_fragment:Vke,fog_pars_fragment:Gke,gradientmap_pars_fragment:Wke,lightmap_pars_fragment:qke,lights_lambert_fragment:Kke,lights_lambert_pars_fragment:Xke,lights_pars_begin:Yke,lights_toon_fragment:Qke,lights_toon_pars_fragment:Jke,lights_phong_fragment:e3e,lights_phong_pars_fragment:t3e,lights_physical_fragment:n3e,lights_physical_pars_fragment:r3e,lights_fragment_begin:i3e,lights_fragment_maps:a3e,lights_fragment_end:s3e,logdepthbuf_fragment:o3e,logdepthbuf_pars_fragment:l3e,logdepthbuf_pars_vertex:c3e,logdepthbuf_vertex:u3e,map_fragment:d3e,map_pars_fragment:h3e,map_particle_fragment:f3e,map_particle_pars_fragment:p3e,metalnessmap_fragment:m3e,metalnessmap_pars_fragment:g3e,morphinstance_vertex:x3e,morphcolor_vertex:b3e,morphnormal_vertex:y3e,morphtarget_pars_vertex:v3e,morphtarget_vertex:_3e,normal_fragment_begin:w3e,normal_fragment_maps:S3e,normal_pars_fragment:M3e,normal_pars_vertex:E3e,normal_vertex:A3e,normalmap_pars_fragment:T3e,clearcoat_normal_fragment_begin:C3e,clearcoat_normal_fragment_maps:N3e,clearcoat_pars_fragment:k3e,iridescence_pars_fragment:P3e,opaque_fragment:R3e,packing:D3e,premultiplied_alpha_fragment:j3e,project_vertex:O3e,dithering_fragment:L3e,dithering_pars_fragment:I3e,roughnessmap_fragment:F3e,roughnessmap_pars_fragment:U3e,shadowmap_pars_fragment:z3e,shadowmap_pars_vertex:B3e,shadowmap_vertex:H3e,shadowmask_pars_fragment:$3e,skinbase_vertex:V3e,skinning_pars_vertex:G3e,skinning_vertex:W3e,skinnormal_vertex:q3e,specularmap_fragment:K3e,specularmap_pars_fragment:X3e,tonemapping_fragment:Y3e,tonemapping_pars_fragment:Z3e,transmission_fragment:Q3e,transmission_pars_fragment:J3e,uv_pars_fragment:ePe,uv_pars_vertex:tPe,uv_vertex:nPe,worldpos_vertex:rPe,background_vert:iPe,background_frag:aPe,backgroundCube_vert:sPe,backgroundCube_frag:oPe,cube_vert:lPe,cube_frag:cPe,depth_vert:uPe,depth_frag:dPe,distanceRGBA_vert:hPe,distanceRGBA_frag:fPe,equirect_vert:pPe,equirect_frag:mPe,linedashed_vert:gPe,linedashed_frag:xPe,meshbasic_vert:bPe,meshbasic_frag:yPe,meshlambert_vert:vPe,meshlambert_frag:_Pe,meshmatcap_vert:wPe,meshmatcap_frag:SPe,meshnormal_vert:MPe,meshnormal_frag:EPe,meshphong_vert:APe,meshphong_frag:TPe,meshphysical_vert:CPe,meshphysical_frag:NPe,meshtoon_vert:kPe,meshtoon_frag:PPe,points_vert:RPe,points_frag:DPe,shadow_vert:jPe,shadow_frag:OPe,sprite_vert:LPe,sprite_frag:IPe},At={common:{diffuse:{value:new _n(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new dn}},envmap:{envMap:{value:null},envMapRotation:{value:new dn},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 dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new dn},normalScale:{value:new cn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new dn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new dn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new dn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new dn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _n(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 _n(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0},uvTransform:{value:new dn}},sprite:{diffuse:{value:new _n(16777215)},opacity:{value:1},center:{value:new cn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}}},nl={basic:{uniforms:va([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.fog]),vertexShader:on.meshbasic_vert,fragmentShader:on.meshbasic_frag},lambert:{uniforms:va([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.fog,At.lights,{emissive:{value:new _n(0)}}]),vertexShader:on.meshlambert_vert,fragmentShader:on.meshlambert_frag},phong:{uniforms:va([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.fog,At.lights,{emissive:{value:new _n(0)},specular:{value:new _n(1118481)},shininess:{value:30}}]),vertexShader:on.meshphong_vert,fragmentShader:on.meshphong_frag},standard:{uniforms:va([At.common,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.roughnessmap,At.metalnessmap,At.fog,At.lights,{emissive:{value:new _n(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag},toon:{uniforms:va([At.common,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.gradientmap,At.fog,At.lights,{emissive:{value:new _n(0)}}]),vertexShader:on.meshtoon_vert,fragmentShader:on.meshtoon_frag},matcap:{uniforms:va([At.common,At.bumpmap,At.normalmap,At.displacementmap,At.fog,{matcap:{value:null}}]),vertexShader:on.meshmatcap_vert,fragmentShader:on.meshmatcap_frag},points:{uniforms:va([At.points,At.fog]),vertexShader:on.points_vert,fragmentShader:on.points_frag},dashed:{uniforms:va([At.common,At.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:on.linedashed_vert,fragmentShader:on.linedashed_frag},depth:{uniforms:va([At.common,At.displacementmap]),vertexShader:on.depth_vert,fragmentShader:on.depth_frag},normal:{uniforms:va([At.common,At.bumpmap,At.normalmap,At.displacementmap,{opacity:{value:1}}]),vertexShader:on.meshnormal_vert,fragmentShader:on.meshnormal_frag},sprite:{uniforms:va([At.sprite,At.fog]),vertexShader:on.sprite_vert,fragmentShader:on.sprite_frag},background:{uniforms:{uvTransform:{value:new dn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:on.background_vert,fragmentShader:on.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new dn}},vertexShader:on.backgroundCube_vert,fragmentShader:on.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:on.cube_vert,fragmentShader:on.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:on.equirect_vert,fragmentShader:on.equirect_frag},distanceRGBA:{uniforms:va([At.common,At.displacementmap,{referencePosition:{value:new Je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:on.distanceRGBA_vert,fragmentShader:on.distanceRGBA_frag},shadow:{uniforms:va([At.lights,At.fog,{color:{value:new _n(0)},opacity:{value:1}}]),vertexShader:on.shadow_vert,fragmentShader:on.shadow_frag}};nl.physical={uniforms:va([nl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new dn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new dn},clearcoatNormalScale:{value:new cn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new dn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new dn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new dn},sheen:{value:0},sheenColor:{value:new _n(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new dn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new dn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new dn},transmissionSamplerSize:{value:new cn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new dn},attenuationDistance:{value:0},attenuationColor:{value:new _n(0)},specularColor:{value:new _n(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new dn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new dn},anisotropyVector:{value:new cn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new dn}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag};const t_={r:0,b:0,g:0},qd=new hd,FPe=new ri;function UPe(t,e,n,r,i,a,s){const o=new _n(0);let c=a===!0?0:1,u,d,f=null,g=0,m=null;function b(S){let A=S.isScene===!0?S.background:null;return A&&A.isTexture&&(A=(S.backgroundBlurriness>0?n:e).get(A)),A}function y(S){let A=!1;const T=b(S);T===null?x(o,c):T&&T.isColor&&(x(T,1),A=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,s):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(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 v(S,A){const T=b(A);T&&(T.isCubeTexture||T.mapping===FM)?(d===void 0&&(d=new xl(new uO(1,1,1),new Lc({name:"BackgroundCubeMaterial",uniforms:km(nl.backgroundCube.uniforms),vertexShader:nl.backgroundCube.vertexShader,fragmentShader:nl.backgroundCube.fragmentShader,side:qa,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,N,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),qd.copy(A.backgroundRotation),qd.x*=-1,qd.y*=-1,qd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(qd.y*=-1,qd.z*=-1),d.material.uniforms.envMap.value=T,d.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(FPe.makeRotationFromEuler(qd)),d.material.toneMapped=Cn.getTransfer(T.colorSpace)!==qn,(f!==T||g!==T.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),d.layers.enableAll(),S.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new xl(new hO(2,2),new Lc({name:"BackgroundMaterial",uniforms:km(nl.background.uniforms),vertexShader:nl.background.vertexShader,fragmentShader:nl.background.fragmentShader,side:dd,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=T,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Cn.getTransfer(T.colorSpace)!==qn,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||g!==T.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),u.layers.enableAll(),S.unshift(u,u.geometry,u.material,0,0,null))}function x(S,A){S.getRGB(t_,dZ(t)),r.buffers.color.setClear(t_.r,t_.g,t_.b,A,s)}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 o},setClearColor:function(S,A=1){o.set(S),c=A,x(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,x(o,c)},render:y,addToRenderList:v,dispose:M}}function zPe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function o(D,F,O,q,R){let W=!1;const K=f(q,O,F);a!==K&&(a=K,u(a.object)),W=m(D,q,O,R),W&&b(D,q,O,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(W||s)&&(s=!1,A(D,F,O,q),R!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(R).buffer))}function c(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function f(D,F,O){const q=O.wireframe===!0;let R=r[D.id];R===void 0&&(R={},r[D.id]=R);let W=R[F.id];W===void 0&&(W={},R[F.id]=W);let K=W[q];return K===void 0&&(K=g(c()),W[q]=K),K}function g(D){const F=[],O=[],q=[];for(let R=0;R<n;R++)F[R]=0,O[R]=0,q[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:O,attributeDivisors:q,object:D,attributes:{},index:null}}function m(D,F,O,q){const R=a.attributes,W=F.attributes;let K=0;const G=O.getAttributes();for(const ee in G)if(G[ee].location>=0){const Q=R[ee];let U=W[ee];if(U===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(U=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(U=D.instanceColor)),Q===void 0||Q.attribute!==U||U&&Q.data!==U.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function b(D,F,O,q){const R={},W=F.attributes;let K=0;const G=O.getAttributes();for(const ee in G)if(G[ee].location>=0){let Q=W[ee];Q===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor));const U={};U.attribute=Q,Q&&Q.data&&(U.data=Q.data),R[ee]=U,K++}a.attributes=R,a.attributesNum=K,a.index=q}function y(){const D=a.newAttributes;for(let F=0,O=D.length;F<O;F++)D[F]=0}function v(D){x(D,0)}function x(D,F){const O=a.newAttributes,q=a.enabledAttributes,R=a.attributeDivisors;O[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),R[D]!==F&&(t.vertexAttribDivisor(D,F),R[D]=F)}function M(){const D=a.newAttributes,F=a.enabledAttributes;for(let O=0,q=F.length;O<q;O++)F[O]!==D[O]&&(t.disableVertexAttribArray(O),F[O]=0)}function S(D,F,O,q,R,W,K){K===!0?t.vertexAttribIPointer(D,F,O,R,W):t.vertexAttribPointer(D,F,O,q,R,W)}function A(D,F,O,q){y();const R=q.attributes,W=O.getAttributes(),K=F.defaultAttributeValues;for(const G in W){const ee=W[G];if(ee.location>=0){let Z=R[G];if(Z===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor)),Z!==void 0){const Q=Z.normalized,U=Z.itemSize,$=e.get(Z);if($===void 0)continue;const X=$.buffer,te=$.type,fe=$.bytesPerElement,pe=te===t.INT||te===t.UNSIGNED_INT||Z.gpuType===eO;if(Z.isInterleavedBufferAttribute){const be=Z.data,Ne=be.stride,ie=Z.offset;if(be.isInstancedInterleavedBuffer){for(let xe=0;xe<ee.locationSize;xe++)x(ee.location+xe,be.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=be.meshPerAttribute*be.count)}else for(let xe=0;xe<ee.locationSize;xe++)v(ee.location+xe);t.bindBuffer(t.ARRAY_BUFFER,X);for(let xe=0;xe<ee.locationSize;xe++)S(ee.location+xe,U/ee.locationSize,te,Q,Ne*fe,(ie+U/ee.locationSize*xe)*fe,pe)}else{if(Z.isInstancedBufferAttribute){for(let be=0;be<ee.locationSize;be++)x(ee.location+be,Z.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let be=0;be<ee.locationSize;be++)v(ee.location+be);t.bindBuffer(t.ARRAY_BUFFER,X);for(let be=0;be<ee.locationSize;be++)S(ee.location+be,U/ee.locationSize,te,Q,U*fe,U/ee.locationSize*be*fe,pe)}}else if(K!==void 0){const Q=K[G];if(Q!==void 0)switch(Q.length){case 2:t.vertexAttrib2fv(ee.location,Q);break;case 3:t.vertexAttrib3fv(ee.location,Q);break;case 4:t.vertexAttrib4fv(ee.location,Q);break;default:t.vertexAttrib1fv(ee.location,Q)}}}}M()}function T(){I();for(const D in r){const F=r[D];for(const O in F){const q=F[O];for(const R in q)d(q[R].object),delete q[R];delete F[O]}delete r[D]}}function k(D){if(r[D.id]===void 0)return;const F=r[D.id];for(const O in F){const q=F[O];for(const R in q)d(q[R].object),delete q[R];delete F[O]}delete r[D.id]}function N(D){for(const F in r){const O=r[F];if(O[D.id]===void 0)continue;const q=O[D.id];for(const R in q)d(q[R].object),delete q[R];delete O[D.id]}}function I(){C(),s=!0,a!==i&&(a=i,u(a.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:I,resetDefaultState:C,dispose:T,releaseStatesOfGeometry:k,releaseStatesOfProgram:N,initAttributes:y,enableAttribute:v,disableUnusedAttributes:M}}function BPe(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 s(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function o(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let m=0;for(let b=0;b<f;b++)m+=d[b];n.update(m,r,1)}function c(u,d,f,g){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<u.length;b++)s(u[b],d[b],g[b]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let b=0;for(let y=0;y<f;y++)b+=d[y]*g[y];n.update(b,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function HPe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(N){return!(N!==Do&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(N){const I=N===sg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==gl&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==gc&&!I)}function c(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="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&&(Yt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),x=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),T=b>0,k=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:o,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:b,maxTextureSize:y,maxCubemapSize:v,maxAttributes:x,maxVertexUniforms:M,maxVaryings:S,maxFragmentUniforms:A,vertexTextures:T,maxSamples:k}}function $Pe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new ku,o=new dn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const b=f.clippingPlanes,y=f.clipIntersection,v=f.clipShadows,x=t.get(f);if(!i||b===null||b.length===0||a&&!v)a?d(null):u();else{const M=a?0:r,S=M*4;let A=x.clippingState||null;c.value=A,A=d(b,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];x.clippingState=A,this.numIntersection=y?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,g,m,b){const y=f!==null?f.length:0;let v=null;if(y!==0){if(v=c.value,b!==!0||v===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let S=0,A=m;S!==y;++S,A+=4)s.copy(f[S]).applyMatrix4(M,o),s.normal.toArray(v,A),v[A+3]=s.constant}c.value=v,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function VPe(t){let e=new WeakMap;function n(s,o){return o===K3?s.mapping=Tm:o===X3&&(s.mapping=Cm),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===K3||o===X3)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new UNe(c.height);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const Bu=4,fH=[.125,.215,.35,.446,.526,.582],lh=20,GPe=256,wx=new yZ,pH=new _n;let BC=null,HC=0,$C=0,VC=!1;const WPe=new Je;let mH=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:s=256,position:o=WPe}=a;BC=this._renderer.getRenderTarget(),HC=this._renderer.getActiveCubeFace(),$C=this._renderer.getActiveMipmapLevel(),VC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,o),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=bH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=xH(),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(BC,HC,$C),this._renderer.xr.enabled=VC,e.scissorTest=!1,fp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Tm||e.mapping===Cm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),BC=this._renderer.getRenderTarget(),HC=this._renderer.getActiveCubeFace(),$C=this._renderer.getActiveMipmapLevel(),VC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:ro,minFilter:ro,generateMipmaps:!1,type:sg,format:Do,colorSpace:Nm,depthBuffer:!1},i=gH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=gH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=qPe(a)),this._blurMaterial=XPe(a,e,n),this._ggxMaterial=KPe(a,e,n)}return i}_compileMaterial(e){const n=new xl(new El,e);this._renderer.compile(n,wx)}_sceneToCubeUV(e,n,r,i,a){const c=new Ys(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,g=f.autoClear,m=f.toneMapping;f.getClearColor(pH),f.toneMapping=Yu,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new xl(new uO,new cO({name:"PMREM.Background",side:qa,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,v=y.material;let x=!1;const M=e.background;M?M.isColor&&(v.color.copy(M),e.background=null,x=!0):(v.color.copy(pH),x=!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 T=this._cubeSize;fp(i,A*T,S>2?T:0,T,T),f.setRenderTarget(i),x&&f.render(y,c),f.render(e,c)}f.toneMapping=m,f.autoClear=g,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Tm||e.mapping===Cm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=bH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=xH());const a=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const o=a.uniforms;o.envMap.value=e;const c=this._cubeSize;fp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,wx)}_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,s=this._ggxMaterial,o=this._lodMeshes[r];o.material=s;const c=s.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,m=f*g,{_lodMax:b}=this,y=this._sizeLods[r],v=3*y*(r>b-Bu?r-b+Bu:0),x=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=b-n,fp(a,v,x,3*y,2*y),i.setRenderTarget(a),i.render(o,wx),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,fp(e,v,x,3*y,2*y),i.setRenderTarget(e),i.render(o,wx)}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&zr("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const g=u.uniforms,m=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*lh-1),y=a/b,v=isFinite(a)?1+Math.floor(d*y):lh;v>lh&&Yt(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${lh}`);const x=[];let M=0;for(let N=0;N<lh;++N){const I=N/y,C=Math.exp(-I*I/2);x.push(C),N===0?M+=C:N<v&&(M+=2*C)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=x,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=b,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-Bu?i-S+Bu:0),k=4*(this._cubeSize-A);fp(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,wx)}};function qPe(t){const e=[],n=[],r=[];let i=t;const a=t-Bu+1+fH.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);e.push(o);let c=1/o;s>t-Bu?c=fH[s-t+Bu-1]:s===0&&(c=0),n.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,b=6,y=3,v=2,x=1,M=new Float32Array(y*b*m),S=new Float32Array(v*b*m),A=new Float32Array(x*b*m);for(let k=0;k<m;k++){const N=k%3*2/3-1,I=k>2?0:-1,C=[N,I,0,N+2/3,I,0,N+2/3,I+1,0,N,I,0,N+2/3,I+1,0,N,I+1,0];M.set(C,y*b*k),S.set(g,v*b*k);const D=[k,k,k,k,k,k];A.set(D,x*b*k)}const T=new El;T.setAttribute("position",new io(M,y)),T.setAttribute("uv",new io(S,v)),T.setAttribute("faceIndex",new io(A,x)),r.push(new xl(T,null)),i>Bu&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function gH(t,e,n){const r=new ef(t,e,n);return r.texture.mapping=FM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function fp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function KPe(t,e,n){return new Lc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:GPe,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:zM(),fragmentShader:`
  3613. precision highp float;
  3614. precision highp int;
  3615. varying vec3 vOutputDirection;
  3616. uniform sampler2D envMap;
  3617. uniform float roughness;
  3618. uniform float mipInt;
  3619. #define ENVMAP_TYPE_CUBE_UV
  3620. #include <cube_uv_reflection_fragment>
  3621. #define PI 3.14159265359
  3622. // Van der Corput radical inverse
  3623. float radicalInverse_VdC(uint bits) {
  3624. bits = (bits << 16u) | (bits >> 16u);
  3625. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3626. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3627. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3628. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3629. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3630. }
  3631. // Hammersley sequence
  3632. vec2 hammersley(uint i, uint N) {
  3633. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3634. }
  3635. // GGX VNDF importance sampling (Eric Heitz 2018)
  3636. // "Sampling the GGX Distribution of Visible Normals"
  3637. // https://jcgt.org/published/0007/04/01/
  3638. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3639. float alpha = roughness * roughness;
  3640. // Section 3.2: Transform view direction to hemisphere configuration
  3641. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3642. // Section 4.1: Orthonormal basis
  3643. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3644. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3645. vec3 T2 = cross(Vh, T1);
  3646. // Section 4.2: Parameterization of projected area
  3647. float r = sqrt(Xi.x);
  3648. float phi = 2.0 * PI * Xi.y;
  3649. float t1 = r * cos(phi);
  3650. float t2 = r * sin(phi);
  3651. float s = 0.5 * (1.0 + Vh.z);
  3652. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3653. // Section 4.3: Reprojection onto hemisphere
  3654. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3655. // Section 3.4: Transform back to ellipsoid configuration
  3656. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3657. }
  3658. void main() {
  3659. vec3 N = normalize(vOutputDirection);
  3660. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3661. vec3 prefilteredColor = vec3(0.0);
  3662. float totalWeight = 0.0;
  3663. // For very low roughness, just sample the environment directly
  3664. if (roughness < 0.001) {
  3665. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3666. return;
  3667. }
  3668. // Tangent space basis for VNDF sampling
  3669. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3670. vec3 tangent = normalize(cross(up, N));
  3671. vec3 bitangent = cross(N, tangent);
  3672. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3673. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3674. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3675. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3676. // Transform H back to world space
  3677. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3678. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3679. float NdotL = max(dot(N, L), 0.0);
  3680. if(NdotL > 0.0) {
  3681. // Sample environment at fixed mip level
  3682. // VNDF importance sampling handles the distribution filtering
  3683. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3684. // Weight by NdotL for the split-sum approximation
  3685. // VNDF PDF naturally accounts for the visible microfacet distribution
  3686. prefilteredColor += sampleColor * NdotL;
  3687. totalWeight += NdotL;
  3688. }
  3689. }
  3690. if (totalWeight > 0.0) {
  3691. prefilteredColor = prefilteredColor / totalWeight;
  3692. }
  3693. gl_FragColor = vec4(prefilteredColor, 1.0);
  3694. }
  3695. `,blending:wc,depthTest:!1,depthWrite:!1})}function XPe(t,e,n){const r=new Float32Array(lh),i=new Je(0,1,0);return new Lc({name:"SphericalGaussianBlur",defines:{n:lh,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:zM(),fragmentShader:`
  3696. precision mediump float;
  3697. precision mediump int;
  3698. varying vec3 vOutputDirection;
  3699. uniform sampler2D envMap;
  3700. uniform int samples;
  3701. uniform float weights[ n ];
  3702. uniform bool latitudinal;
  3703. uniform float dTheta;
  3704. uniform float mipInt;
  3705. uniform vec3 poleAxis;
  3706. #define ENVMAP_TYPE_CUBE_UV
  3707. #include <cube_uv_reflection_fragment>
  3708. vec3 getSample( float theta, vec3 axis ) {
  3709. float cosTheta = cos( theta );
  3710. // Rodrigues' axis-angle rotation
  3711. vec3 sampleDirection = vOutputDirection * cosTheta
  3712. + cross( axis, vOutputDirection ) * sin( theta )
  3713. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3714. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3715. }
  3716. void main() {
  3717. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3718. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3719. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3720. }
  3721. axis = normalize( axis );
  3722. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3723. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3724. for ( int i = 1; i < n; i++ ) {
  3725. if ( i >= samples ) {
  3726. break;
  3727. }
  3728. float theta = dTheta * float( i );
  3729. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3730. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3731. }
  3732. }
  3733. `,blending:wc,depthTest:!1,depthWrite:!1})}function xH(){return new Lc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:zM(),fragmentShader:`
  3734. precision mediump float;
  3735. precision mediump int;
  3736. varying vec3 vOutputDirection;
  3737. uniform sampler2D envMap;
  3738. #include <common>
  3739. void main() {
  3740. vec3 outputDirection = normalize( vOutputDirection );
  3741. vec2 uv = equirectUv( outputDirection );
  3742. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3743. }
  3744. `,blending:wc,depthTest:!1,depthWrite:!1})}function bH(){return new Lc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:zM(),fragmentShader:`
  3745. precision mediump float;
  3746. precision mediump int;
  3747. uniform float flipEnvMap;
  3748. varying vec3 vOutputDirection;
  3749. uniform samplerCube envMap;
  3750. void main() {
  3751. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3752. }
  3753. `,blending:wc,depthTest:!1,depthWrite:!1})}function zM(){return`
  3754. precision mediump float;
  3755. precision mediump int;
  3756. attribute float faceIndex;
  3757. varying vec3 vOutputDirection;
  3758. // RH coordinate system; PMREM face-indexing convention
  3759. vec3 getDirection( vec2 uv, float face ) {
  3760. uv = 2.0 * uv - 1.0;
  3761. vec3 direction = vec3( uv, 1.0 );
  3762. if ( face == 0.0 ) {
  3763. direction = direction.zyx; // ( 1, v, u ) pos x
  3764. } else if ( face == 1.0 ) {
  3765. direction = direction.xzy;
  3766. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3767. } else if ( face == 2.0 ) {
  3768. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3769. } else if ( face == 3.0 ) {
  3770. direction = direction.zyx;
  3771. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3772. } else if ( face == 4.0 ) {
  3773. direction = direction.xzy;
  3774. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3775. } else if ( face == 5.0 ) {
  3776. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3777. }
  3778. return direction;
  3779. }
  3780. void main() {
  3781. vOutputDirection = getDirection( uv, faceIndex );
  3782. gl_Position = vec4( position, 1.0 );
  3783. }
  3784. `}function YPe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===K3||c===X3,d=c===Tm||c===Cm;if(u||d){let f=e.get(o);const g=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new mH(t)),f=u?n.fromEquirectangular(o,f):n.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const m=o.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new mH(t)),f=u?n.fromEquirectangular(o):n.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",a),f.texture):null}}}return o}function i(o){let c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function a(o){const c=o.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function ZPe(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&&q0("WebGLRenderer: "+r+" extension not supported."),i}}}function QPe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const b in g.attributes)e.remove(g.attributes[b]);g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function u(f){const g=[],m=f.index,b=f.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let S=0,A=M.length;S<A;S+=3){const T=M[S+0],k=M[S+1],N=M[S+2];g.push(T,k,k,N,N,T)}}else if(b!==void 0){const M=b.array;y=b.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const T=S+0,k=S+1,N=S+2;g.push(T,k,k,N,N,T)}}else return;const v=new(QY(g)?lZ:oZ)(g,1);v.version=y;const x=a.get(f);x&&e.remove(x),a.set(f,v)}function d(f){const g=a.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:o,update:c,getWireframeAttribute:d}}function JPe(t,e,n){let r;function i(g){r=g}let a,s;function o(g){a=g.type,s=g.bytesPerElement}function c(g,m){t.drawElements(r,m,a,g*s),n.update(m,r,1)}function u(g,m,b){b!==0&&(t.drawElementsInstanced(r,m,a,g*s,b),n.update(m,r,b))}function d(g,m,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,a,g,0,b);let v=0;for(let x=0;x<b;x++)v+=m[x];n.update(v,r,1)}function f(g,m,b,y){if(b===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<g.length;x++)u(g[x]/s,m[x],y[x]);else{v.multiDrawElementsInstancedWEBGL(r,m,0,a,g,0,y,0,b);let x=0;for(let M=0;M<b;M++)x+=m[M]*y[M];n.update(x,r,1)}}this.setMode=i,this.setIndex=o,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function eRe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:zr("WebGLInfo: Unknown draw mode:",s);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 tRe(t,e,n){const r=new WeakMap,i=new Yr;function a(s,o,c){const u=s.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(o);if(g===void 0||g.count!==f){let D=function(){I.dispose(),r.delete(o),o.removeEventListener("dispose",D)};var m=D;g!==void 0&&g.texture.dispose();const b=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],M=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let A=0;b===!0&&(A=1),y===!0&&(A=2),v===!0&&(A=3);let T=o.attributes.position.count*A,k=1;T>e.maxTextureSize&&(k=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const N=new Float32Array(T*k*4*f),I=new rZ(N,T,k,f);I.type=gc,I.needsUpdate=!0;const C=A*4;for(let F=0;F<f;F++){const O=x[F],q=M[F],R=S[F],W=T*k*4*F;for(let K=0;K<O.count;K++){const G=K*C;b===!0&&(i.fromBufferAttribute(O,K),N[W+G+0]=i.x,N[W+G+1]=i.y,N[W+G+2]=i.z,N[W+G+3]=0),y===!0&&(i.fromBufferAttribute(q,K),N[W+G+4]=i.x,N[W+G+5]=i.y,N[W+G+6]=i.z,N[W+G+7]=0),v===!0&&(i.fromBufferAttribute(R,K),N[W+G+8]=i.x,N[W+G+9]=i.y,N[W+G+10]=i.z,N[W+G+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:I,size:new cn(T,k)},r.set(o,g),o.addEventListener("dispose",D)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let b=0;for(let v=0;v<u.length;v++)b+=u[v];const y=o.morphTargetsRelative?1:1-b;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:a}}function nRe(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",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}const _Z=new $o,yH=new mZ(1,1),wZ=new rZ,SZ=new wNe,MZ=new fZ,vH=[],_H=[],wH=new Float32Array(16),SH=new Float32Array(9),MH=new Float32Array(4);function lg(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 s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function pi(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 mi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function BM(t,e){let n=_H[e];n===void 0&&(n=new Int32Array(e),_H[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function rRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function iRe(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(pi(n,e))return;t.uniform2fv(this.addr,e),mi(n,e)}}function aRe(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(pi(n,e))return;t.uniform3fv(this.addr,e),mi(n,e)}}function sRe(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(pi(n,e))return;t.uniform4fv(this.addr,e),mi(n,e)}}function oRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;MH.set(r),t.uniformMatrix2fv(this.addr,!1,MH),mi(n,r)}}function lRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;SH.set(r),t.uniformMatrix3fv(this.addr,!1,SH),mi(n,r)}}function cRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;wH.set(r),t.uniformMatrix4fv(this.addr,!1,wH),mi(n,r)}}function uRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function dRe(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(pi(n,e))return;t.uniform2iv(this.addr,e),mi(n,e)}}function hRe(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(pi(n,e))return;t.uniform3iv(this.addr,e),mi(n,e)}}function fRe(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(pi(n,e))return;t.uniform4iv(this.addr,e),mi(n,e)}}function pRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function mRe(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(pi(n,e))return;t.uniform2uiv(this.addr,e),mi(n,e)}}function gRe(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(pi(n,e))return;t.uniform3uiv(this.addr,e),mi(n,e)}}function xRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||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(pi(n,e))return;t.uniform4uiv(this.addr,e),mi(n,e)}}function bRe(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?(yH.compareFunction=ZY,a=yH):a=_Z,n.setTexture2D(e||a,i)}function yRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||SZ,i)}function vRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||MZ,i)}function _Re(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||wZ,i)}function wRe(t){switch(t){case 5126:return rRe;case 35664:return iRe;case 35665:return aRe;case 35666:return sRe;case 35674:return oRe;case 35675:return lRe;case 35676:return cRe;case 5124:case 35670:return uRe;case 35667:case 35671:return dRe;case 35668:case 35672:return hRe;case 35669:case 35673:return fRe;case 5125:return pRe;case 36294:return mRe;case 36295:return gRe;case 36296:return xRe;case 35678:case 36198:case 36298:case 36306:case 35682:return bRe;case 35679:case 36299:case 36307:return yRe;case 35680:case 36300:case 36308:case 36293:return vRe;case 36289:case 36303:case 36311:case 36292:return _Re}}function SRe(t,e){t.uniform1fv(this.addr,e)}function MRe(t,e){const n=lg(e,this.size,2);t.uniform2fv(this.addr,n)}function ERe(t,e){const n=lg(e,this.size,3);t.uniform3fv(this.addr,n)}function ARe(t,e){const n=lg(e,this.size,4);t.uniform4fv(this.addr,n)}function TRe(t,e){const n=lg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function CRe(t,e){const n=lg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function NRe(t,e){const n=lg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function kRe(t,e){t.uniform1iv(this.addr,e)}function PRe(t,e){t.uniform2iv(this.addr,e)}function RRe(t,e){t.uniform3iv(this.addr,e)}function DRe(t,e){t.uniform4iv(this.addr,e)}function jRe(t,e){t.uniform1uiv(this.addr,e)}function ORe(t,e){t.uniform2uiv(this.addr,e)}function LRe(t,e){t.uniform3uiv(this.addr,e)}function IRe(t,e){t.uniform4uiv(this.addr,e)}function FRe(t,e,n){const r=this.cache,i=e.length,a=BM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||_Z,a[s])}function URe(t,e,n){const r=this.cache,i=e.length,a=BM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||SZ,a[s])}function zRe(t,e,n){const r=this.cache,i=e.length,a=BM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||MZ,a[s])}function BRe(t,e,n){const r=this.cache,i=e.length,a=BM(n,i);pi(r,a)||(t.uniform1iv(this.addr,a),mi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||wZ,a[s])}function HRe(t){switch(t){case 5126:return SRe;case 35664:return MRe;case 35665:return ERe;case 35666:return ARe;case 35674:return TRe;case 35675:return CRe;case 35676:return NRe;case 5124:case 35670:return kRe;case 35667:case 35671:return PRe;case 35668:case 35672:return RRe;case 35669:case 35673:return DRe;case 5125:return jRe;case 36294:return ORe;case 36295:return LRe;case 36296:return IRe;case 35678:case 36198:case 36298:case 36306:case 35682:return FRe;case 35679:case 36299:case 36307:return URe;case 35680:case 36300:case 36308:case 36293:return zRe;case 36289:case 36303:case 36311:case 36292:return BRe}}let $Re=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=wRe(n.type)}},VRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=HRe(n.type)}},GRe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}};const GC=/(\w+)(\])?(\[|\.)?/g;function EH(t,e){t.seq.push(e),t.map[e.id]=e}function WRe(t,e,n){const r=t.name,i=r.length;for(GC.lastIndex=0;;){const a=GC.exec(r),s=GC.lastIndex;let o=a[1];const c=a[2]==="]",u=a[3];if(c&&(o=o|0),u===void 0||u==="["&&s+2===i){EH(n,u===void 0?new $Re(o,t,e):new VRe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new GRe(o),EH(n,f)),n=f}}}let f1=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),s=e.getUniformLocation(n,a.name);WRe(a,s,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,s=n.length;a!==s;++a){const o=n[a],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}};function AH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const qRe=37297;let KRe=0;function XRe(t,e){const n=t.split(`
  3785. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  3786. `)}const TH=new dn;function YRe(t){Cn._getMatrix(TH,Cn.workingColorSpace,t);const e=`mat3( ${TH.elements.map(n=>n.toFixed(4))} )`;switch(Cn.getTransfer(t)){case Cw:return[e,"LinearTransferOETF"];case qn:return[e,"sRGBTransferOETF"];default:return Yt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function CH(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
  3787. `+a+`
  3788. `+XRe(t.getShaderSource(e),o)}else return a}function ZRe(t,e){const n=YRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3789. `)}function QRe(t,e){let n;switch(e){case XCe:n="Linear";break;case YCe:n="Reinhard";break;case ZCe:n="Cineon";break;case QCe:n="ACESFilmic";break;case eNe:n="AgX";break;case tNe:n="Neutral";break;case JCe:n="Custom";break;default:Yt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const n_=new Je;function JRe(){Cn.getLuminanceCoefficients(n_);const t=n_.x.toFixed(4),e=n_.y.toFixed(4),n=n_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3790. `)}function eDe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ix).join(`
  3791. `)}function tDe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3792. `)}function nDe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Ix(t){return t!==""}function NH(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 kH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const rDe=/^[ \t]*#include +<([\w\d./]+)>/gm;function CP(t){return t.replace(rDe,aDe)}const iDe=new Map;function aDe(t,e){let n=on[e];if(n===void 0){const r=iDe.get(e);if(r!==void 0)n=on[r],Yt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return CP(n)}const sDe=/#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 PH(t){return t.replace(sDe,oDe)}function oDe(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 RH(t){let e=`precision ${t.precision} float;
  3793. precision ${t.precision} int;
  3794. precision ${t.precision} sampler2D;
  3795. precision ${t.precision} samplerCube;
  3796. precision ${t.precision} sampler3D;
  3797. precision ${t.precision} sampler2DArray;
  3798. precision ${t.precision} sampler2DShadow;
  3799. precision ${t.precision} samplerCubeShadow;
  3800. precision ${t.precision} sampler2DArrayShadow;
  3801. precision ${t.precision} isampler2D;
  3802. precision ${t.precision} isampler3D;
  3803. precision ${t.precision} isamplerCube;
  3804. precision ${t.precision} isampler2DArray;
  3805. precision ${t.precision} usampler2D;
  3806. precision ${t.precision} usampler3D;
  3807. precision ${t.precision} usamplerCube;
  3808. precision ${t.precision} usampler2DArray;
  3809. `;return t.precision==="highp"?e+=`
  3810. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3811. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3812. #define LOW_PRECISION`),e}function lDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===BY?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===CCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ic&&(e="SHADOWMAP_TYPE_VSM"),e}function cDe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Tm:case Cm:e="ENVMAP_TYPE_CUBE";break;case FM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function uDe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Cm:e="ENVMAP_MODE_REFRACTION";break}return e}function dDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case Jj:e="ENVMAP_BLENDING_MULTIPLY";break;case qCe:e="ENVMAP_BLENDING_MIX";break;case KCe:e="ENVMAP_BLENDING_ADD";break}return e}function hDe(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 fDe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const c=lDe(n),u=cDe(n),d=uDe(n),f=dDe(n),g=hDe(n),m=eDe(n),b=tDe(a),y=i.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
  3813. `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Ix).join(`
  3814. `),v.length>0&&(v+=`
  3815. `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Ix).join(`
  3816. `),x.length>0&&(x+=`
  3817. `)):(v=[RH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3818. `].filter(Ix).join(`
  3819. `),x=[RH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Yu?"#define TONE_MAPPING":"",n.toneMapping!==Yu?on.tonemapping_pars_fragment:"",n.toneMapping!==Yu?QRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",on.colorspace_pars_fragment,ZRe("linearToOutputTexel",n.outputColorSpace),JRe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3820. `].filter(Ix).join(`
  3821. `)),s=CP(s),s=NH(s,n),s=kH(s,n),o=CP(o),o=NH(o,n),o=kH(o,n),s=PH(s),o=PH(o),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  3822. `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3823. `)+`
  3824. `+v,x=["#define varying in",n.glslVersion===U6?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===U6?"":"#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(`
  3825. `)+`
  3826. `+x);const S=M+v+s,A=M+x+o,T=AH(i,i.VERTEX_SHADER,S),k=AH(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function N(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(k)||"",W=O.trim(),K=q.trim(),G=R.trim();let ee=!0,Z=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(ee=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const Q=CH(i,T,"vertex"),U=CH(i,k,"fragment");zr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3827. Material Name: `+F.name+`
  3828. Material Type: `+F.type+`
  3829. Program Info Log: `+W+`
  3830. `+Q+`
  3831. `+U)}else W!==""?Yt("WebGLProgram: Program Info Log:",W):(K===""||G==="")&&(Z=!1);Z&&(F.diagnostics={runnable:ee,programLog:W,vertexShader:{log:K,prefix:v},fragmentShader:{log:G,prefix:x}})}i.deleteShader(T),i.deleteShader(k),I=new f1(i,y),C=nDe(i,y)}let I;this.getUniforms=function(){return I===void 0&&N(this),I};let C;this.getAttributes=function(){return C===void 0&&N(this),C};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,qRe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=KRe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let pDe=0,mDe=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),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.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 gDe(e),n.set(e,r)),r}},gDe=class{constructor(e){this.id=pDe++,this.code=e,this.usedTimes=0}};function xDe(t,e,n,r,i,a,s){const o=new aZ,c=new mDe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return u.add(C),C===0?"uv":`uv${C}`}function v(C,D,F,O,q){const R=O.fog,W=q.geometry,K=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),ee=G&&G.mapping===FM?G.image.height:null,Z=b[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&Yt("WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Q!==void 0?Q.length:0;let $=0;W.morphAttributes.position!==void 0&&($=1),W.morphAttributes.normal!==void 0&&($=2),W.morphAttributes.color!==void 0&&($=3);let X,te,fe,pe;if(Z){const St=nl[Z];X=St.vertexShader,te=St.fragmentShader}else X=C.vertexShader,te=C.fragmentShader,c.update(C),fe=c.getVertexShaderID(C),pe=c.getFragmentShaderID(C);const be=t.getRenderTarget(),Ne=t.state.buffers.depth.getReversed(),ie=q.isInstancedMesh===!0,xe=q.isBatchedMesh===!0,Re=!!C.map,he=!!C.matcap,ht=!!G,H=!!C.aoMap,B=!!C.lightMap,re=!!C.bumpMap,V=!!C.normalMap,J=!!C.displacementMap,se=!!C.emissiveMap,Ae=!!C.metalnessMap,Pe=!!C.roughnessMap,Se=C.anisotropy>0,z=C.clearcoat>0,L=C.dispersion>0,ne=C.iridescence>0,ve=C.sheen>0,we=C.transmission>0,ye=Se&&!!C.anisotropyMap,nt=z&&!!C.clearcoatMap,Be=z&&!!C.clearcoatNormalMap,ue=z&&!!C.clearcoatRoughnessMap,Ve=ne&&!!C.iridescenceMap,Fe=ne&&!!C.iridescenceThicknessMap,oe=ve&&!!C.sheenColorMap,et=ve&&!!C.sheenRoughnessMap,He=!!C.specularMap,Ke=!!C.specularColorMap,ct=!!C.specularIntensityMap,de=we&&!!C.transmissionMap,Ye=we&&!!C.thicknessMap,ge=!!C.gradientMap,Ue=!!C.alphaMap,Ce=C.alphaTest>0,_e=!!C.alphaHash,ce=!!C.extensions;let st=Yu;C.toneMapped&&(be===null||be.isXRRenderTarget===!0)&&(st=t.toneMapping);const xt={shaderID:Z,shaderType:C.type,shaderName:C.name,vertexShader:X,fragmentShader:te,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:pe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:xe,batchingColor:xe&&q._colorsTexture!==null,instancing:ie,instancingColor:ie&&q.instanceColor!==null,instancingMorph:ie&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:be===null?t.outputColorSpace:be.isXRRenderTarget===!0?be.texture.colorSpace:Nm,alphaToCoverage:!!C.alphaToCoverage,map:Re,matcap:he,envMap:ht,envMapMode:ht&&G.mapping,envMapCubeUVHeight:ee,aoMap:H,lightMap:B,bumpMap:re,normalMap:V,displacementMap:g&&J,emissiveMap:se,normalMapObjectSpace:V&&C.normalMapType===aNe,normalMapTangentSpace:V&&C.normalMapType===YY,metalnessMap:Ae,roughnessMap:Pe,anisotropy:Se,anisotropyMap:ye,clearcoat:z,clearcoatMap:nt,clearcoatNormalMap:Be,clearcoatRoughnessMap:ue,dispersion:L,iridescence:ne,iridescenceMap:Ve,iridescenceThicknessMap:Fe,sheen:ve,sheenColorMap:oe,sheenRoughnessMap:et,specularMap:He,specularColorMap:Ke,specularIntensityMap:ct,transmission:we,transmissionMap:de,thicknessMap:Ye,gradientMap:ge,opaque:C.transparent===!1&&C.blending===rm&&C.alphaToCoverage===!1,alphaMap:Ue,alphaTest:Ce,alphaHash:_e,combine:C.combine,mapUv:Re&&y(C.map.channel),aoMapUv:H&&y(C.aoMap.channel),lightMapUv:B&&y(C.lightMap.channel),bumpMapUv:re&&y(C.bumpMap.channel),normalMapUv:V&&y(C.normalMap.channel),displacementMapUv:J&&y(C.displacementMap.channel),emissiveMapUv:se&&y(C.emissiveMap.channel),metalnessMapUv:Ae&&y(C.metalnessMap.channel),roughnessMapUv:Pe&&y(C.roughnessMap.channel),anisotropyMapUv:ye&&y(C.anisotropyMap.channel),clearcoatMapUv:nt&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:Be&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ue&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Fe&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:et&&y(C.sheenRoughnessMap.channel),specularMapUv:He&&y(C.specularMap.channel),specularColorMapUv:Ke&&y(C.specularColorMap.channel),specularIntensityMapUv:ct&&y(C.specularIntensityMap.channel),transmissionMapUv:de&&y(C.transmissionMap.channel),thicknessMapUv:Ye&&y(C.thicknessMap.channel),alphaMapUv:Ue&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(V||Se),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Re||Ue),fog:!!R,useFog:C.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ne,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:$,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:st,decodeVideoTexture:Re&&C.map.isVideoTexture===!0&&Cn.getTransfer(C.map.colorSpace)===qn,decodeVideoTextureEmissive:se&&C.emissiveMap.isVideoTexture===!0&&Cn.getTransfer(C.emissiveMap.colorSpace)===qn,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===rl,flipSided:C.side===qa,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:ce&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ce&&C.extensions.multiDraw===!0||xe)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return xt.vertexUv1s=u.has(1),xt.vertexUv2s=u.has(2),xt.vertexUv3s=u.has(3),u.clear(),xt}function x(C){const D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)D.push(F),D.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(M(D,C),S(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function M(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function S(C,D){o.disableAll(),D.supportsVertexTextures&&o.enable(0),D.instancing&&o.enable(1),D.instancingColor&&o.enable(2),D.instancingMorph&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),D.dispersion&&o.enable(20),D.batchingColor&&o.enable(21),D.gradientMap&&o.enable(22),C.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.reversedDepthBuffer&&o.enable(4),D.skinning&&o.enable(5),D.morphTargets&&o.enable(6),D.morphNormals&&o.enable(7),D.morphColors&&o.enable(8),D.premultipliedAlpha&&o.enable(9),D.shadowMapEnabled&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),D.decodeVideoTextureEmissive&&o.enable(20),D.alphaToCoverage&&o.enable(21),C.push(o.mask)}function A(C){const D=b[C.type];let F;if(D){const O=nl[D];F=ONe.clone(O.uniforms)}else F=C.uniforms;return F}function T(C,D){let F;for(let O=0,q=d.length;O<q;O++){const R=d[O];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new fDe(t,D,C,a),d.push(F)),F}function k(C){if(--C.usedTimes===0){const D=d.indexOf(C);d[D]=d[d.length-1],d.pop(),C.destroy()}}function N(C){c.remove(C)}function I(){c.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:d,dispose:I}}function bDe(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function r(s){t.delete(s)}function i(s,o,c){t.get(s)[o]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function yDe(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 DH(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 jH(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,m,b,y,v){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:g,material:m,groupOrder:b,renderOrder:f.renderOrder,z:y,group:v},t[e]=x):(x.id=f.id,x.object=f,x.geometry=g,x.material=m,x.groupOrder=b,x.renderOrder=f.renderOrder,x.z=y,x.group=v),e++,x}function o(f,g,m,b,y,v){const x=s(f,g,m,b,y,v);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function c(f,g,m,b,y,v){const x=s(f,g,m,b,y,v);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function u(f,g){n.length>1&&n.sort(f||yDe),r.length>1&&r.sort(g||DH),i.length>1&&i.sort(g||DH)}function d(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:c,finish:d,sort:u}}function vDe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new jH,t.set(r,[s])):i>=a.length?(s=new jH,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function _De(){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 Je,color:new _n};break;case"SpotLight":n={position:new Je,direction:new Je,color:new _n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Je,color:new _n,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Je,skyColor:new _n,groundColor:new _n};break;case"RectAreaLight":n={color:new _n,position:new Je,halfWidth:new Je,halfHeight:new Je};break}return t[e.id]=n,n}}}function wDe(){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 cn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let SDe=0;function MDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function EDe(t){const e=new _De,n=wDe(),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 Je);const i=new Je,a=new ri,s=new ri;function o(u){let d=0,f=0,g=0;for(let C=0;C<9;C++)r.probe[C].set(0,0,0);let m=0,b=0,y=0,v=0,x=0,M=0,S=0,A=0,T=0,k=0,N=0;u.sort(MDe);for(let C=0,D=u.length;C<D;C++){const F=u[C],O=F.color,q=F.intensity,R=F.distance,W=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=O.r*q,f+=O.g*q,g+=O.b*q;else if(F.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(F.sh.coefficients[K],q);N++}else if(F.isDirectionalLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const G=F.shadow,ee=n.get(F);ee.shadowIntensity=G.intensity,ee.shadowBias=G.bias,ee.shadowNormalBias=G.normalBias,ee.shadowRadius=G.radius,ee.shadowMapSize=G.mapSize,r.directionalShadow[m]=ee,r.directionalShadowMap[m]=W,r.directionalShadowMatrix[m]=F.shadow.matrix,M++}r.directional[m]=K,m++}else if(F.isSpotLight){const K=e.get(F);K.position.setFromMatrixPosition(F.matrixWorld),K.color.copy(O).multiplyScalar(q),K.distance=R,K.coneCos=Math.cos(F.angle),K.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),K.decay=F.decay,r.spot[y]=K;const G=F.shadow;if(F.map&&(r.spotLightMap[T]=F.map,T++,G.updateMatrices(F),F.castShadow&&k++),r.spotLightMatrix[y]=G.matrix,F.castShadow){const ee=n.get(F);ee.shadowIntensity=G.intensity,ee.shadowBias=G.bias,ee.shadowNormalBias=G.normalBias,ee.shadowRadius=G.radius,ee.shadowMapSize=G.mapSize,r.spotShadow[y]=ee,r.spotShadowMap[y]=W,A++}y++}else if(F.isRectAreaLight){const K=e.get(F);K.color.copy(O).multiplyScalar(q),K.halfWidth.set(F.width*.5,0,0),K.halfHeight.set(0,F.height*.5,0),r.rectArea[v]=K,v++}else if(F.isPointLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),K.distance=F.distance,K.decay=F.decay,F.castShadow){const G=F.shadow,ee=n.get(F);ee.shadowIntensity=G.intensity,ee.shadowBias=G.bias,ee.shadowNormalBias=G.normalBias,ee.shadowRadius=G.radius,ee.shadowMapSize=G.mapSize,ee.shadowCameraNear=G.camera.near,ee.shadowCameraFar=G.camera.far,r.pointShadow[b]=ee,r.pointShadowMap[b]=W,r.pointShadowMatrix[b]=F.shadow.matrix,S++}r.point[b]=K,b++}else if(F.isHemisphereLight){const K=e.get(F);K.skyColor.copy(F.color).multiplyScalar(q),K.groundColor.copy(F.groundColor).multiplyScalar(q),r.hemi[x]=K,x++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=At.LTC_FLOAT_1,r.rectAreaLTC2=At.LTC_FLOAT_2):(r.rectAreaLTC1=At.LTC_HALF_1,r.rectAreaLTC2=At.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const I=r.hash;(I.directionalLength!==m||I.pointLength!==b||I.spotLength!==y||I.rectAreaLength!==v||I.hemiLength!==x||I.numDirectionalShadows!==M||I.numPointShadows!==S||I.numSpotShadows!==A||I.numSpotMaps!==T||I.numLightProbes!==N)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=v,r.point.length=b,r.hemi.length=x,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+T-k,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=N,I.directionalLength=m,I.pointLength=b,I.spotLength=y,I.rectAreaLength=v,I.hemiLength=x,I.numDirectionalShadows=M,I.numPointShadows=S,I.numSpotShadows=A,I.numSpotMaps=T,I.numLightProbes=N,r.version=SDe++)}function c(u,d){let f=0,g=0,m=0,b=0,y=0;const v=d.matrixWorldInverse;for(let x=0,M=u.length;x<M;x++){const S=u[x];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(v),f++}else if(S.isSpotLight){const A=r.spot[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(v),m++}else if(S.isRectAreaLight){const A=r.rectArea[b];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),s.identity(),a.copy(S.matrixWorld),a.premultiply(v),s.extractRotation(a),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(s),A.halfHeight.applyMatrix4(s),b++}else if(S.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),g++}else if(S.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(v),y++}}}return{setup:o,setupView:c,state:r}}function OH(t){const e=new EDe(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function s(d){r.push(d)}function o(){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:o,setupLightsView:c,pushLight:a,pushShadow:s}}function ADe(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let o;return s===void 0?(o=new OH(t),e.set(i,[o])):a>=s.length?(o=new OH(t),s.push(o)):o=s[a],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const TDe=`void main() {
  3832. gl_Position = vec4( position, 1.0 );
  3833. }`,CDe=`uniform sampler2D shadow_pass;
  3834. uniform vec2 resolution;
  3835. uniform float radius;
  3836. #include <packing>
  3837. void main() {
  3838. const float samples = float( VSM_SAMPLES );
  3839. float mean = 0.0;
  3840. float squared_mean = 0.0;
  3841. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3842. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3843. for ( float i = 0.0; i < samples; i ++ ) {
  3844. float uvOffset = uvStart + i * uvStride;
  3845. #ifdef HORIZONTAL_PASS
  3846. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3847. mean += distribution.x;
  3848. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3849. #else
  3850. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3851. mean += depth;
  3852. squared_mean += depth * depth;
  3853. #endif
  3854. }
  3855. mean = mean / samples;
  3856. squared_mean = squared_mean / samples;
  3857. float std_dev = sqrt( squared_mean - mean * mean );
  3858. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3859. }`;function NDe(t,e,n){let r=new dO;const i=new cn,a=new cn,s=new Yr,o=new XNe({depthPacking:iNe}),c=new YNe,u={},d=n.maxTextureSize,f={[dd]:qa,[qa]:dd,[rl]:rl},g=new Lc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new cn},radius:{value:4}},vertexShader:TDe,fragmentShader:CDe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const b=new El;b.setAttribute("position",new io(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new xl(b,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=BY;let x=this.type;this.render=function(k,N,I){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||k.length===0)return;const C=t.getRenderTarget(),D=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),O=t.state;O.setBlending(wc),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=x!==ic&&this.type===ic,R=x===ic&&this.type!==ic;for(let W=0,K=k.length;W<K;W++){const G=k[W],ee=G.shadow;if(ee===void 0){Yt("WebGLShadowMap:",G,"has no shadow.");continue}if(ee.autoUpdate===!1&&ee.needsUpdate===!1)continue;i.copy(ee.mapSize);const Z=ee.getFrameExtents();if(i.multiply(Z),a.copy(ee.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,ee.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,ee.mapSize.y=a.y)),ee.map===null||q===!0||R===!0){const U=this.type!==ic?{minFilter:ws,magFilter:ws}:{};ee.map!==null&&ee.map.dispose(),ee.map=new ef(i.x,i.y,U),ee.map.texture.name=G.name+".shadowMap",ee.camera.updateProjectionMatrix()}t.setRenderTarget(ee.map),t.clear();const Q=ee.getViewportCount();for(let U=0;U<Q;U++){const $=ee.getViewport(U);s.set(a.x*$.x,a.y*$.y,a.x*$.z,a.y*$.w),O.viewport(s),ee.updateMatrices(G,U),r=ee.getFrustum(),A(N,I,ee.camera,G,this.type)}ee.isPointLightShadow!==!0&&this.type===ic&&M(ee,I),ee.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(C,D,F)};function M(k,N){const I=e.update(y);g.defines.VSM_SAMPLES!==k.blurSamples&&(g.defines.VSM_SAMPLES=k.blurSamples,m.defines.VSM_SAMPLES=k.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new ef(i.x,i.y)),g.uniforms.shadow_pass.value=k.map.texture,g.uniforms.resolution.value=k.mapSize,g.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(N,null,I,g,y,null),m.uniforms.shadow_pass.value=k.mapPass.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(N,null,I,m,y,null)}function S(k,N,I,C){let D=null;const F=I.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(F!==void 0)D=F;else if(D=I.isPointLight===!0?c:o,t.localClippingEnabled&&N.clipShadows===!0&&Array.isArray(N.clippingPlanes)&&N.clippingPlanes.length!==0||N.displacementMap&&N.displacementScale!==0||N.alphaMap&&N.alphaTest>0||N.map&&N.alphaTest>0||N.alphaToCoverage===!0){const O=D.uuid,q=N.uuid;let R=u[O];R===void 0&&(R={},u[O]=R);let W=R[q];W===void 0&&(W=D.clone(),R[q]=W,N.addEventListener("dispose",T)),D=W}if(D.visible=N.visible,D.wireframe=N.wireframe,C===ic?D.side=N.shadowSide!==null?N.shadowSide:N.side:D.side=N.shadowSide!==null?N.shadowSide:f[N.side],D.alphaMap=N.alphaMap,D.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,D.map=N.map,D.clipShadows=N.clipShadows,D.clippingPlanes=N.clippingPlanes,D.clipIntersection=N.clipIntersection,D.displacementMap=N.displacementMap,D.displacementScale=N.displacementScale,D.displacementBias=N.displacementBias,D.wireframeLinewidth=N.wireframeLinewidth,D.linewidth=N.linewidth,I.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const O=t.properties.get(D);O.light=I}return D}function A(k,N,I,C,D){if(k.visible===!1)return;if(k.layers.test(N.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&D===ic)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,k.matrixWorld);const q=e.update(k),R=k.material;if(Array.isArray(R)){const W=q.groups;for(let K=0,G=W.length;K<G;K++){const ee=W[K],Z=R[ee.materialIndex];if(Z&&Z.visible){const Q=S(k,Z,C,D);k.onBeforeShadow(t,k,N,I,q,Q,ee),t.renderBufferDirect(I,null,q,Q,k,ee),k.onAfterShadow(t,k,N,I,q,Q,ee)}}}else if(R.visible){const W=S(k,R,C,D);k.onBeforeShadow(t,k,N,I,q,W,null),t.renderBufferDirect(I,null,q,W,k,null),k.onAfterShadow(t,k,N,I,q,W,null)}}const O=k.children;for(let q=0,R=O.length;q<R;q++)A(O[q],N,I,C,D)}function T(k){k.target.removeEventListener("dispose",T);for(const I in u){const C=u[I],D=k.target.uuid;D in C&&(C[D].dispose(),delete C[D])}}}const kDe={[B3]:H3,[$3]:W3,[V3]:q3,[Am]:G3,[H3]:B3,[W3]:$3,[q3]:V3,[G3]:Am};function PDe(t,e){function n(){let de=!1;const Ye=new Yr;let ge=null;const Ue=new Yr(0,0,0,0);return{setMask:function(Ce){ge!==Ce&&!de&&(t.colorMask(Ce,Ce,Ce,Ce),ge=Ce)},setLocked:function(Ce){de=Ce},setClear:function(Ce,_e,ce,st,xt){xt===!0&&(Ce*=st,_e*=st,ce*=st),Ye.set(Ce,_e,ce,st),Ue.equals(Ye)===!1&&(t.clearColor(Ce,_e,ce,st),Ue.copy(Ye))},reset:function(){de=!1,ge=null,Ue.set(-1,0,0,0)}}}function r(){let de=!1,Ye=!1,ge=null,Ue=null,Ce=null;return{setReversed:function(_e){if(Ye!==_e){const ce=e.get("EXT_clip_control");_e?ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.ZERO_TO_ONE_EXT):ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.NEGATIVE_ONE_TO_ONE_EXT),Ye=_e;const st=Ce;Ce=null,this.setClear(st)}},getReversed:function(){return Ye},setTest:function(_e){_e?be(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(_e){ge!==_e&&!de&&(t.depthMask(_e),ge=_e)},setFunc:function(_e){if(Ye&&(_e=kDe[_e]),Ue!==_e){switch(_e){case B3:t.depthFunc(t.NEVER);break;case H3:t.depthFunc(t.ALWAYS);break;case $3:t.depthFunc(t.LESS);break;case Am:t.depthFunc(t.LEQUAL);break;case V3:t.depthFunc(t.EQUAL);break;case G3:t.depthFunc(t.GEQUAL);break;case W3:t.depthFunc(t.GREATER);break;case q3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=_e}},setLocked:function(_e){de=_e},setClear:function(_e){Ce!==_e&&(Ye&&(_e=1-_e),t.clearDepth(_e),Ce=_e)},reset:function(){de=!1,ge=null,Ue=null,Ce=null,Ye=!1}}}function i(){let de=!1,Ye=null,ge=null,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null;return{setTest:function(St){de||(St?be(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(St){Ye!==St&&!de&&(t.stencilMask(St),Ye=St)},setFunc:function(St,Qt,Ot){(ge!==St||Ue!==Qt||Ce!==Ot)&&(t.stencilFunc(St,Qt,Ot),ge=St,Ue=Qt,Ce=Ot)},setOp:function(St,Qt,Ot){(_e!==St||ce!==Qt||st!==Ot)&&(t.stencilOp(St,Qt,Ot),_e=St,ce=Qt,st=Ot)},setLocked:function(St){de=St},setClear:function(St){xt!==St&&(t.clearStencil(St),xt=St)},reset:function(){de=!1,Ye=null,ge=null,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null}}}const a=new n,s=new r,o=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,m=[],b=null,y=!1,v=null,x=null,M=null,S=null,A=null,T=null,k=null,N=new _n(0,0,0),I=0,C=!1,D=null,F=null,O=null,q=null,R=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(ee)[1]),K=G>=1):ee.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),K=G>=2);let Z=null,Q={};const U=t.getParameter(t.SCISSOR_BOX),$=t.getParameter(t.VIEWPORT),X=new Yr().fromArray(U),te=new Yr().fromArray($);function fe(de,Ye,ge,Ue){const Ce=new Uint8Array(4),_e=t.createTexture();t.bindTexture(de,_e),t.texParameteri(de,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(de,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let ce=0;ce<ge;ce++)de===t.TEXTURE_3D||de===t.TEXTURE_2D_ARRAY?t.texImage3D(Ye,0,t.RGBA,1,1,Ue,0,t.RGBA,t.UNSIGNED_BYTE,Ce):t.texImage2D(Ye+ce,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ce);return _e}const pe={};pe[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),pe[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),pe[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),pe[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),be(t.DEPTH_TEST),s.setFunc(Am),re(!1),V(D6),be(t.CULL_FACE),H(wc);function be(de){d[de]!==!0&&(t.enable(de),d[de]=!0)}function Ne(de){d[de]!==!1&&(t.disable(de),d[de]=!1)}function ie(de,Ye){return f[de]!==Ye?(t.bindFramebuffer(de,Ye),f[de]=Ye,de===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Ye),de===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Ye),!0):!1}function xe(de,Ye){let ge=m,Ue=!1;if(de){ge=g.get(Ye),ge===void 0&&(ge=[],g.set(Ye,ge));const Ce=de.textures;if(ge.length!==Ce.length||ge[0]!==t.COLOR_ATTACHMENT0){for(let _e=0,ce=Ce.length;_e<ce;_e++)ge[_e]=t.COLOR_ATTACHMENT0+_e;ge.length=Ce.length,Ue=!0}}else ge[0]!==t.BACK&&(ge[0]=t.BACK,Ue=!0);Ue&&t.drawBuffers(ge)}function Re(de){return b!==de?(t.useProgram(de),b=de,!0):!1}const he={[oh]:t.FUNC_ADD,[kCe]:t.FUNC_SUBTRACT,[PCe]:t.FUNC_REVERSE_SUBTRACT};he[RCe]=t.MIN,he[DCe]=t.MAX;const ht={[jCe]:t.ZERO,[OCe]:t.ONE,[LCe]:t.SRC_COLOR,[U3]:t.SRC_ALPHA,[HCe]:t.SRC_ALPHA_SATURATE,[zCe]:t.DST_COLOR,[FCe]:t.DST_ALPHA,[ICe]:t.ONE_MINUS_SRC_COLOR,[z3]:t.ONE_MINUS_SRC_ALPHA,[BCe]:t.ONE_MINUS_DST_COLOR,[UCe]:t.ONE_MINUS_DST_ALPHA,[$Ce]:t.CONSTANT_COLOR,[VCe]:t.ONE_MINUS_CONSTANT_COLOR,[GCe]:t.CONSTANT_ALPHA,[WCe]:t.ONE_MINUS_CONSTANT_ALPHA};function H(de,Ye,ge,Ue,Ce,_e,ce,st,xt,St){if(de===wc){y===!0&&(Ne(t.BLEND),y=!1);return}if(y===!1&&(be(t.BLEND),y=!0),de!==NCe){if(de!==v||St!==C){if((x!==oh||A!==oh)&&(t.blendEquation(t.FUNC_ADD),x=oh,A=oh),St)switch(de){case rm:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case j6:t.blendFunc(t.ONE,t.ONE);break;case O6:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case L6:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:zr("WebGLState: Invalid blending: ",de);break}else switch(de){case rm:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case j6:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case O6:zr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case L6:zr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zr("WebGLState: Invalid blending: ",de);break}M=null,S=null,T=null,k=null,N.set(0,0,0),I=0,v=de,C=St}return}Ce=Ce||Ye,_e=_e||ge,ce=ce||Ue,(Ye!==x||Ce!==A)&&(t.blendEquationSeparate(he[Ye],he[Ce]),x=Ye,A=Ce),(ge!==M||Ue!==S||_e!==T||ce!==k)&&(t.blendFuncSeparate(ht[ge],ht[Ue],ht[_e],ht[ce]),M=ge,S=Ue,T=_e,k=ce),(st.equals(N)===!1||xt!==I)&&(t.blendColor(st.r,st.g,st.b,xt),N.copy(st),I=xt),v=de,C=!1}function B(de,Ye){de.side===rl?Ne(t.CULL_FACE):be(t.CULL_FACE);let ge=de.side===qa;Ye&&(ge=!ge),re(ge),de.blending===rm&&de.transparent===!1?H(wc):H(de.blending,de.blendEquation,de.blendSrc,de.blendDst,de.blendEquationAlpha,de.blendSrcAlpha,de.blendDstAlpha,de.blendColor,de.blendAlpha,de.premultipliedAlpha),s.setFunc(de.depthFunc),s.setTest(de.depthTest),s.setMask(de.depthWrite),a.setMask(de.colorWrite);const Ue=de.stencilWrite;o.setTest(Ue),Ue&&(o.setMask(de.stencilWriteMask),o.setFunc(de.stencilFunc,de.stencilRef,de.stencilFuncMask),o.setOp(de.stencilFail,de.stencilZFail,de.stencilZPass)),se(de.polygonOffset,de.polygonOffsetFactor,de.polygonOffsetUnits),de.alphaToCoverage===!0?be(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function re(de){D!==de&&(de?t.frontFace(t.CW):t.frontFace(t.CCW),D=de)}function V(de){de!==ACe?(be(t.CULL_FACE),de!==F&&(de===D6?t.cullFace(t.BACK):de===TCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),F=de}function J(de){de!==O&&(K&&t.lineWidth(de),O=de)}function se(de,Ye,ge){de?(be(t.POLYGON_OFFSET_FILL),(q!==Ye||R!==ge)&&(t.polygonOffset(Ye,ge),q=Ye,R=ge)):Ne(t.POLYGON_OFFSET_FILL)}function Ae(de){de?be(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function Pe(de){de===void 0&&(de=t.TEXTURE0+W-1),Z!==de&&(t.activeTexture(de),Z=de)}function Se(de,Ye,ge){ge===void 0&&(Z===null?ge=t.TEXTURE0+W-1:ge=Z);let Ue=Q[ge];Ue===void 0&&(Ue={type:void 0,texture:void 0},Q[ge]=Ue),(Ue.type!==de||Ue.texture!==Ye)&&(Z!==ge&&(t.activeTexture(ge),Z=ge),t.bindTexture(de,Ye||pe[de]),Ue.type=de,Ue.texture=Ye)}function z(){const de=Q[Z];de!==void 0&&de.type!==void 0&&(t.bindTexture(de.type,null),de.type=void 0,de.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ve(){try{t.texSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function we(){try{t.texSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ye(){try{t.compressedTexSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function nt(){try{t.compressedTexSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Be(){try{t.texStorage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ue(){try{t.texStorage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Ve(){try{t.texImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Fe(){try{t.texImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function oe(de){X.equals(de)===!1&&(t.scissor(de.x,de.y,de.z,de.w),X.copy(de))}function et(de){te.equals(de)===!1&&(t.viewport(de.x,de.y,de.z,de.w),te.copy(de))}function He(de,Ye){let ge=u.get(Ye);ge===void 0&&(ge=new WeakMap,u.set(Ye,ge));let Ue=ge.get(de);Ue===void 0&&(Ue=t.getUniformBlockIndex(Ye,de.name),ge.set(de,Ue))}function Ke(de,Ye){const Ue=u.get(Ye).get(de);c.get(Ye)!==Ue&&(t.uniformBlockBinding(Ye,Ue,de.__bindingPointIndex),c.set(Ye,Ue))}function ct(){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),s.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Z=null,Q={},f={},g=new WeakMap,m=[],b=null,y=!1,v=null,x=null,M=null,S=null,A=null,T=null,k=null,N=new _n(0,0,0),I=0,C=!1,D=null,F=null,O=null,q=null,R=null,X.set(0,0,t.canvas.width,t.canvas.height),te.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:be,disable:Ne,bindFramebuffer:ie,drawBuffers:xe,useProgram:Re,setBlending:H,setMaterial:B,setFlipSided:re,setCullFace:V,setLineWidth:J,setPolygonOffset:se,setScissorTest:Ae,activeTexture:Pe,bindTexture:Se,unbindTexture:z,compressedTexImage2D:L,compressedTexImage3D:ne,texImage2D:Ve,texImage3D:Fe,updateUBOMapping:He,uniformBlockBinding:Ke,texStorage2D:Be,texStorage3D:ue,texSubImage2D:ve,texSubImage3D:we,compressedTexSubImage2D:ye,compressedTexSubImage3D:nt,scissor:oe,viewport:et,reset:ct}}function RDe(t,e,n,r,i,a,s){const o=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 cn,d=new WeakMap;let f;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(z,L){return m?new OffscreenCanvas(z,L):kw("canvas")}function y(z,L,ne){let ve=1;const we=Se(z);if((we.width>ne||we.height>ne)&&(ve=ne/Math.max(we.width,we.height)),ve<1)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap||typeof VideoFrame<"u"&&z instanceof VideoFrame){const ye=Math.floor(ve*we.width),nt=Math.floor(ve*we.height);f===void 0&&(f=b(ye,nt));const Be=L?b(ye,nt):f;return Be.width=ye,Be.height=nt,Be.getContext("2d").drawImage(z,0,0,ye,nt),Yt("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ye+"x"+nt+")."),Be}else return"data"in z&&Yt("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),z;return z}function v(z){return z.generateMipmaps}function x(z){t.generateMipmap(z)}function M(z){return z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:z.isWebGL3DRenderTarget?t.TEXTURE_3D:z.isWebGLArrayRenderTarget||z.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function S(z,L,ne,ve,we=!1){if(z!==null){if(t[z]!==void 0)return t[z];Yt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let ye=L;if(L===t.RED&&(ne===t.FLOAT&&(ye=t.R32F),ne===t.HALF_FLOAT&&(ye=t.R16F),ne===t.UNSIGNED_BYTE&&(ye=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.R8UI),ne===t.UNSIGNED_SHORT&&(ye=t.R16UI),ne===t.UNSIGNED_INT&&(ye=t.R32UI),ne===t.BYTE&&(ye=t.R8I),ne===t.SHORT&&(ye=t.R16I),ne===t.INT&&(ye=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ye=t.RG32F),ne===t.HALF_FLOAT&&(ye=t.RG16F),ne===t.UNSIGNED_BYTE&&(ye=t.RG8)),L===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RG8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RG16UI),ne===t.UNSIGNED_INT&&(ye=t.RG32UI),ne===t.BYTE&&(ye=t.RG8I),ne===t.SHORT&&(ye=t.RG16I),ne===t.INT&&(ye=t.RG32I)),L===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RGB16UI),ne===t.UNSIGNED_INT&&(ye=t.RGB32UI),ne===t.BYTE&&(ye=t.RGB8I),ne===t.SHORT&&(ye=t.RGB16I),ne===t.INT&&(ye=t.RGB32I)),L===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RGBA16UI),ne===t.UNSIGNED_INT&&(ye=t.RGBA32UI),ne===t.BYTE&&(ye=t.RGBA8I),ne===t.SHORT&&(ye=t.RGBA16I),ne===t.INT&&(ye=t.RGBA32I)),L===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(ye=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(ye=t.R11F_G11F_B10F)),L===t.RGBA){const nt=we?Cw:Cn.getTransfer(ve);ne===t.FLOAT&&(ye=t.RGBA32F),ne===t.HALF_FLOAT&&(ye=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ye=nt===qn?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function A(z,L){let ne;return z?L===null||L===Qh||L===V0?ne=t.DEPTH24_STENCIL8:L===gc?ne=t.DEPTH32F_STENCIL8:L===$0&&(ne=t.DEPTH24_STENCIL8,Yt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Qh||L===V0?ne=t.DEPTH_COMPONENT24:L===gc?ne=t.DEPTH_COMPONENT32F:L===$0&&(ne=t.DEPTH_COMPONENT16),ne}function T(z,L){return v(z)===!0||z.isFramebufferTexture&&z.minFilter!==ws&&z.minFilter!==ro?Math.log2(Math.max(L.width,L.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?L.mipmaps.length:1}function k(z){const L=z.target;L.removeEventListener("dispose",k),I(L),L.isVideoTexture&&d.delete(L)}function N(z){const L=z.target;L.removeEventListener("dispose",N),D(L)}function I(z){const L=r.get(z);if(L.__webglInit===void 0)return;const ne=z.source,ve=g.get(ne);if(ve){const we=ve[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&C(z),Object.keys(ve).length===0&&g.delete(ne)}r.remove(z)}function C(z){const L=r.get(z);t.deleteTexture(L.__webglTexture);const ne=z.source,ve=g.get(ne);delete ve[L.__cacheKey],s.memory.textures--}function D(z){const L=r.get(z);if(z.depthTexture&&(z.depthTexture.dispose(),r.remove(z.depthTexture)),z.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++){if(Array.isArray(L.__webglFramebuffer[ve]))for(let we=0;we<L.__webglFramebuffer[ve].length;we++)t.deleteFramebuffer(L.__webglFramebuffer[ve][we]);else t.deleteFramebuffer(L.__webglFramebuffer[ve]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ve])}else{if(Array.isArray(L.__webglFramebuffer))for(let ve=0;ve<L.__webglFramebuffer.length;ve++)t.deleteFramebuffer(L.__webglFramebuffer[ve]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ve=0;ve<L.__webglColorRenderbuffer.length;ve++)L.__webglColorRenderbuffer[ve]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ve]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const ne=z.textures;for(let ve=0,we=ne.length;ve<we;ve++){const ye=r.get(ne[ve]);ye.__webglTexture&&(t.deleteTexture(ye.__webglTexture),s.memory.textures--),r.remove(ne[ve])}r.remove(z)}let F=0;function O(){F=0}function q(){const z=F;return z>=i.maxTextures&&Yt("WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+i.maxTextures),F+=1,z}function R(z){const L=[];return L.push(z.wrapS),L.push(z.wrapT),L.push(z.wrapR||0),L.push(z.magFilter),L.push(z.minFilter),L.push(z.anisotropy),L.push(z.internalFormat),L.push(z.format),L.push(z.type),L.push(z.generateMipmaps),L.push(z.premultiplyAlpha),L.push(z.flipY),L.push(z.unpackAlignment),L.push(z.colorSpace),L.join()}function W(z,L){const ne=r.get(z);if(z.isVideoTexture&&Ae(z),z.isRenderTargetTexture===!1&&z.isExternalTexture!==!0&&z.version>0&&ne.__version!==z.version){const ve=z.image;if(ve===null)Yt("WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)Yt("WebGLRenderer: Texture marked for update but image is incomplete");else{pe(ne,z,L);return}}else z.isExternalTexture&&(ne.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function K(z,L){const ne=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ne.__version!==z.version){pe(ne,z,L);return}else z.isExternalTexture&&(ne.__webglTexture=z.sourceTexture?z.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function G(z,L){const ne=r.get(z);if(z.isRenderTargetTexture===!1&&z.version>0&&ne.__version!==z.version){pe(ne,z,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function ee(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){be(ne,z,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const Z={[Y3]:t.REPEAT,[mc]:t.CLAMP_TO_EDGE,[Z3]:t.MIRRORED_REPEAT},Q={[ws]:t.NEAREST,[nNe]:t.NEAREST_MIPMAP_NEAREST,[Ov]:t.NEAREST_MIPMAP_LINEAR,[ro]:t.LINEAR,[mC]:t.LINEAR_MIPMAP_NEAREST,[xh]:t.LINEAR_MIPMAP_LINEAR},U={[sNe]:t.NEVER,[hNe]:t.ALWAYS,[oNe]:t.LESS,[ZY]:t.LEQUAL,[lNe]:t.EQUAL,[dNe]:t.GEQUAL,[cNe]:t.GREATER,[uNe]:t.NOTEQUAL};function $(z,L){if(L.type===gc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===ro||L.magFilter===mC||L.magFilter===Ov||L.magFilter===xh||L.minFilter===ro||L.minFilter===mC||L.minFilter===Ov||L.minFilter===xh)&&Yt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(z,t.TEXTURE_WRAP_S,Z[L.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,Z[L.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,Z[L.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,Q[L.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,Q[L.minFilter]),L.compareFunction&&(t.texParameteri(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,U[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ws||L.minFilter!==Ov&&L.minFilter!==xh||L.type===gc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");t.texParameterf(z,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function X(z,L){let ne=!1;z.__webglInit===void 0&&(z.__webglInit=!0,L.addEventListener("dispose",k));const ve=L.source;let we=g.get(ve);we===void 0&&(we={},g.set(ve,we));const ye=R(L);if(ye!==z.__cacheKey){we[ye]===void 0&&(we[ye]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),we[ye].usedTimes++;const nt=we[z.__cacheKey];nt!==void 0&&(we[z.__cacheKey].usedTimes--,nt.usedTimes===0&&C(L)),z.__cacheKey=ye,z.__webglTexture=we[ye].texture}return ne}function te(z,L,ne){return Math.floor(Math.floor(z/ne)/L)}function fe(z,L,ne,ve){const ye=z.updateRanges;if(ye.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,ne,ve,L.data);else{ye.sort((Fe,oe)=>Fe.start-oe.start);let nt=0;for(let Fe=1;Fe<ye.length;Fe++){const oe=ye[nt],et=ye[Fe],He=oe.start+oe.count,Ke=te(et.start,L.width,4),ct=te(oe.start,L.width,4);et.start<=He+1&&Ke===ct&&te(et.start+et.count-1,L.width,4)===Ke?oe.count=Math.max(oe.count,et.start+et.count-oe.start):(++nt,ye[nt]=et)}ye.length=nt+1;const Be=t.getParameter(t.UNPACK_ROW_LENGTH),ue=t.getParameter(t.UNPACK_SKIP_PIXELS),Ve=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Fe=0,oe=ye.length;Fe<oe;Fe++){const et=ye[Fe],He=Math.floor(et.start/4),Ke=Math.ceil(et.count/4),ct=He%L.width,de=Math.floor(He/L.width),Ye=Ke,ge=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ct),t.pixelStorei(t.UNPACK_SKIP_ROWS,de),n.texSubImage2D(t.TEXTURE_2D,0,ct,de,Ye,ge,ne,ve,L.data)}z.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Be),t.pixelStorei(t.UNPACK_SKIP_PIXELS,ue),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ve)}}function pe(z,L,ne){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const we=X(z,L),ye=L.source;n.bindTexture(ve,z.__webglTexture,t.TEXTURE0+ne);const nt=r.get(ye);if(ye.version!==nt.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Be=Cn.getPrimaries(Cn.workingColorSpace),ue=L.colorSpace===Iu?null:Cn.getPrimaries(L.colorSpace),Ve=L.colorSpace===Iu||Be===ue?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,Ve);let Fe=y(L.image,!1,i.maxTextureSize);Fe=Pe(L,Fe);const oe=a.convert(L.format,L.colorSpace),et=a.convert(L.type);let He=S(L.internalFormat,oe,et,L.colorSpace,L.isVideoTexture);$(ve,L);let Ke;const ct=L.mipmaps,de=L.isVideoTexture!==!0,Ye=nt.__version===void 0||we===!0,ge=ye.dataReady,Ue=T(L,Fe);if(L.isDepthTexture)He=A(L.format===W0,L.type),Ye&&(de?n.texStorage2D(t.TEXTURE_2D,1,He,Fe.width,Fe.height):n.texImage2D(t.TEXTURE_2D,0,He,Fe.width,Fe.height,0,oe,et,null));else if(L.isDataTexture)if(ct.length>0){de&&Ye&&n.texStorage2D(t.TEXTURE_2D,Ue,He,ct[0].width,ct[0].height);for(let Ce=0,_e=ct.length;Ce<_e;Ce++)Ke=ct[Ce],de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,oe,et,Ke.data):n.texImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,oe,et,Ke.data);L.generateMipmaps=!1}else de?(Ye&&n.texStorage2D(t.TEXTURE_2D,Ue,He,Fe.width,Fe.height),ge&&fe(L,Fe,oe,et)):n.texImage2D(t.TEXTURE_2D,0,He,Fe.width,Fe.height,0,oe,et,Fe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){de&&Ye&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,He,ct[0].width,ct[0].height,Fe.depth);for(let Ce=0,_e=ct.length;Ce<_e;Ce++)if(Ke=ct[Ce],L.format!==Do)if(oe!==null)if(de){if(ge)if(L.layerUpdates.size>0){const ce=hH(Ke.width,Ke.height,L.format,L.type);for(const st of L.layerUpdates){const xt=Ke.data.subarray(st*ce/Ke.data.BYTES_PER_ELEMENT,(st+1)*ce/Ke.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,st,Ke.width,Ke.height,1,oe,xt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ke.width,Ke.height,Fe.depth,oe,Ke.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,He,Ke.width,Ke.height,Fe.depth,0,Ke.data,0,0);else Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else de?ge&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ke.width,Ke.height,Fe.depth,oe,et,Ke.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,He,Ke.width,Ke.height,Fe.depth,0,oe,et,Ke.data)}else{de&&Ye&&n.texStorage2D(t.TEXTURE_2D,Ue,He,ct[0].width,ct[0].height);for(let Ce=0,_e=ct.length;Ce<_e;Ce++)Ke=ct[Ce],L.format!==Do?oe!==null?de?ge&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,oe,Ke.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,Ke.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,oe,et,Ke.data):n.texImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,oe,et,Ke.data)}else if(L.isDataArrayTexture)if(de){if(Ye&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,He,Fe.width,Fe.height,Fe.depth),ge)if(L.layerUpdates.size>0){const Ce=hH(Fe.width,Fe.height,L.format,L.type);for(const _e of L.layerUpdates){const ce=Fe.data.subarray(_e*Ce/Fe.data.BYTES_PER_ELEMENT,(_e+1)*Ce/Fe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,_e,Fe.width,Fe.height,1,oe,et,ce)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Fe.width,Fe.height,Fe.depth,oe,et,Fe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,He,Fe.width,Fe.height,Fe.depth,0,oe,et,Fe.data);else if(L.isData3DTexture)de?(Ye&&n.texStorage3D(t.TEXTURE_3D,Ue,He,Fe.width,Fe.height,Fe.depth),ge&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Fe.width,Fe.height,Fe.depth,oe,et,Fe.data)):n.texImage3D(t.TEXTURE_3D,0,He,Fe.width,Fe.height,Fe.depth,0,oe,et,Fe.data);else if(L.isFramebufferTexture){if(Ye)if(de)n.texStorage2D(t.TEXTURE_2D,Ue,He,Fe.width,Fe.height);else{let Ce=Fe.width,_e=Fe.height;for(let ce=0;ce<Ue;ce++)n.texImage2D(t.TEXTURE_2D,ce,He,Ce,_e,0,oe,et,null),Ce>>=1,_e>>=1}}else if(ct.length>0){if(de&&Ye){const Ce=Se(ct[0]);n.texStorage2D(t.TEXTURE_2D,Ue,He,Ce.width,Ce.height)}for(let Ce=0,_e=ct.length;Ce<_e;Ce++)Ke=ct[Ce],de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,oe,et,Ke):n.texImage2D(t.TEXTURE_2D,Ce,He,oe,et,Ke);L.generateMipmaps=!1}else if(de){if(Ye){const Ce=Se(Fe);n.texStorage2D(t.TEXTURE_2D,Ue,He,Ce.width,Ce.height)}ge&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe,et,Fe)}else n.texImage2D(t.TEXTURE_2D,0,He,oe,et,Fe);v(L)&&x(ve),nt.__version=ye.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function be(z,L,ne){if(L.image.length!==6)return;const ve=X(z,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ne);const ye=r.get(we);if(we.version!==ye.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const nt=Cn.getPrimaries(Cn.workingColorSpace),Be=L.colorSpace===Iu?null:Cn.getPrimaries(L.colorSpace),ue=L.colorSpace===Iu||nt===Be?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,ue);const Ve=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let _e=0;_e<6;_e++)!Ve&&!Fe?oe[_e]=y(L.image[_e],!0,i.maxCubemapSize):oe[_e]=Fe?L.image[_e].image:L.image[_e],oe[_e]=Pe(L,oe[_e]);const et=oe[0],He=a.convert(L.format,L.colorSpace),Ke=a.convert(L.type),ct=S(L.internalFormat,He,Ke,L.colorSpace),de=L.isVideoTexture!==!0,Ye=ye.__version===void 0||ve===!0,ge=we.dataReady;let Ue=T(L,et);$(t.TEXTURE_CUBE_MAP,L);let Ce;if(Ve){de&&Ye&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,ct,et.width,et.height);for(let _e=0;_e<6;_e++){Ce=oe[_e].mipmaps;for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];L.format!==Do?He!==null?de?ge&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,He,st.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,ct,st.width,st.height,0,st.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,He,Ke,st.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,ct,st.width,st.height,0,He,Ke,st.data)}}}else{if(Ce=L.mipmaps,de&&Ye){Ce.length>0&&Ue++;const _e=Se(oe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,ct,_e.width,_e.height)}for(let _e=0;_e<6;_e++)if(Fe){de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,oe[_e].width,oe[_e].height,He,Ke,oe[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,ct,oe[_e].width,oe[_e].height,0,He,Ke,oe[_e].data);for(let ce=0;ce<Ce.length;ce++){const xt=Ce[ce].image[_e].image;de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,xt.width,xt.height,He,Ke,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,ct,xt.width,xt.height,0,He,Ke,xt.data)}}else{de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,He,Ke,oe[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,ct,He,Ke,oe[_e]);for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,He,Ke,st.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,ct,He,Ke,st.image[_e])}}}v(L)&&x(t.TEXTURE_CUBE_MAP),ye.__version=we.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function Ne(z,L,ne,ve,we,ye){const nt=a.convert(ne.format,ne.colorSpace),Be=a.convert(ne.type),ue=S(ne.internalFormat,nt,Be,ne.colorSpace),Ve=r.get(L),Fe=r.get(ne);if(Fe.__renderTarget=L,!Ve.__hasExternalTextures){const oe=Math.max(1,L.width>>ye),et=Math.max(1,L.height>>ye);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ye,ue,oe,et,L.depth,0,nt,Be,null):n.texImage2D(we,ye,ue,oe,et,0,nt,Be,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,we,Fe.__webglTexture,0,J(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,we,Fe.__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ie(z,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,z),L.depthBuffer){const ve=L.depthTexture,we=ve&&ve.isDepthTexture?ve.type:null,ye=A(L.stencilBuffer,we),nt=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Be=J(L);se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Be,ye,L.width,L.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,ye,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ye,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,nt,t.RENDERBUFFER,z)}else{const ve=L.textures;for(let we=0;we<ve.length;we++){const ye=ve[we],nt=a.convert(ye.format,ye.colorSpace),Be=a.convert(ye.type),ue=S(ye.internalFormat,nt,Be,ye.colorSpace),Ve=J(L);ne&&se(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,ue,L.width,L.height):se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,ue,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ue,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function xe(z,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ve=r.get(L.depthTexture);ve.__renderTarget=L,(!ve.__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),W(L.depthTexture,0);const we=ve.__webglTexture,ye=J(L);if(L.depthTexture.format===G0)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0);else if(L.depthTexture.format===W0)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function Re(z){const L=r.get(z),ne=z.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==z.depthTexture){const ve=z.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ve){const we=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ve.removeEventListener("dispose",we)};ve.addEventListener("dispose",we),L.__depthDisposeCallback=we}L.__boundDepthTexture=ve}if(z.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const ve=z.texture.mipmaps;ve&&ve.length>0?xe(L.__webglFramebuffer[0],z):xe(L.__webglFramebuffer,z)}else if(ne){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]===void 0)L.__webglDepthbuffer[ve]=t.createRenderbuffer(),ie(L.__webglDepthbuffer[ve],z,!1);else{const we=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=L.__webglDepthbuffer[ve];t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ye)}}else{const ve=z.texture.mipmaps;if(ve&&ve.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),ie(L.__webglDepthbuffer,z,!1);else{const we=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ye)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(z,L,ne){const ve=r.get(z);L!==void 0&&Ne(ve.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&Re(z)}function ht(z){const L=z.texture,ne=r.get(z),ve=r.get(L);z.addEventListener("dispose",N);const we=z.textures,ye=z.isWebGLCubeRenderTarget===!0,nt=we.length>1;if(nt||(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,s.memory.textures++),ye){ne.__webglFramebuffer=[];for(let Be=0;Be<6;Be++)if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Be]=[];for(let ue=0;ue<L.mipmaps.length;ue++)ne.__webglFramebuffer[Be][ue]=t.createFramebuffer()}else ne.__webglFramebuffer[Be]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Be=0;Be<L.mipmaps.length;Be++)ne.__webglFramebuffer[Be]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(nt)for(let Be=0,ue=we.length;Be<ue;Be++){const Ve=r.get(we[Be]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),s.memory.textures++)}if(z.samples>0&&se(z)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Be=0;Be<we.length;Be++){const ue=we[Be];ne.__webglColorRenderbuffer[Be]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Be]);const Ve=a.convert(ue.format,ue.colorSpace),Fe=a.convert(ue.type),oe=S(ue.internalFormat,Ve,Fe,ue.colorSpace,z.isXRRenderTarget===!0),et=J(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,et,oe,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Be,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Be])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),ie(ne.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),$(t.TEXTURE_CUBE_MAP,L);for(let Be=0;Be<6;Be++)if(L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Ne(ne.__webglFramebuffer[Be][ue],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,ue);else Ne(ne.__webglFramebuffer[Be],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0);v(L)&&x(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(nt){for(let Be=0,ue=we.length;Be<ue;Be++){const Ve=we[Be],Fe=r.get(Ve);let oe=t.TEXTURE_2D;(z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(oe=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(oe,Fe.__webglTexture),$(oe,Ve),Ne(ne.__webglFramebuffer,z,Ve,t.COLOR_ATTACHMENT0+Be,oe,0),v(Ve)&&x(oe)}n.unbindTexture()}else{let Be=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(Be=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Be,ve.__webglTexture),$(Be,L),L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Ne(ne.__webglFramebuffer[ue],z,L,t.COLOR_ATTACHMENT0,Be,ue);else Ne(ne.__webglFramebuffer,z,L,t.COLOR_ATTACHMENT0,Be,0);v(L)&&x(Be),n.unbindTexture()}z.depthBuffer&&Re(z)}function H(z){const L=z.textures;for(let ne=0,ve=L.length;ne<ve;ne++){const we=L[ne];if(v(we)){const ye=M(z),nt=r.get(we).__webglTexture;n.bindTexture(ye,nt),x(ye),n.unbindTexture()}}}const B=[],re=[];function V(z){if(z.samples>0){if(se(z)===!1){const L=z.textures,ne=z.width,ve=z.height;let we=t.COLOR_BUFFER_BIT;const ye=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,nt=r.get(z),Be=L.length>1;if(Be)for(let Ve=0;Ve<L.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,nt.__webglMultisampledFramebuffer);const ue=z.texture.mipmaps;ue&&ue.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglFramebuffer);for(let Ve=0;Ve<L.length;Ve++){if(z.resolveDepthBuffer&&(z.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&z.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Be){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,nt.__webglColorRenderbuffer[Ve]);const Fe=r.get(L[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Fe,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,we,t.NEAREST),c===!0&&(B.length=0,re.length=0,B.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&z.resolveDepthBuffer===!1&&(B.push(ye),re.push(ye),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,re)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Be)for(let Ve=0;Ve<L.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,nt.__webglColorRenderbuffer[Ve]);const Fe=r.get(L[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglMultisampledFramebuffer)}else if(z.depthBuffer&&z.resolveDepthBuffer===!1&&c){const L=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function J(z){return Math.min(i.maxSamples,z.samples)}function se(z){const L=r.get(z);return z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ae(z){const L=s.render.frame;d.get(z)!==L&&(d.set(z,L),z.update())}function Pe(z,L){const ne=z.colorSpace,ve=z.format,we=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||ne!==Nm&&ne!==Iu&&(Cn.getTransfer(ne)===qn?(ve!==Do||we!==gl)&&Yt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zr("WebGLTextures: Unsupported texture color space:",ne)),L}function Se(z){return typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement?(u.width=z.naturalWidth||z.width,u.height=z.naturalHeight||z.height):typeof VideoFrame<"u"&&z instanceof VideoFrame?(u.width=z.displayWidth,u.height=z.displayHeight):(u.width=z.width,u.height=z.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=ee,this.rebindTextures=he,this.setupRenderTarget=ht,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=V,this.setupDepthRenderbuffer=Re,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=se}function DDe(t,e){function n(r,i=Iu){let a;const s=Cn.getTransfer(i);if(r===gl)return t.UNSIGNED_BYTE;if(r===tO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===nO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===GY)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===WY)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===$Y)return t.BYTE;if(r===VY)return t.SHORT;if(r===$0)return t.UNSIGNED_SHORT;if(r===eO)return t.INT;if(r===Qh)return t.UNSIGNED_INT;if(r===gc)return t.FLOAT;if(r===sg)return t.HALF_FLOAT;if(r===qY)return t.ALPHA;if(r===KY)return t.RGB;if(r===Do)return t.RGBA;if(r===G0)return t.DEPTH_COMPONENT;if(r===W0)return t.DEPTH_STENCIL;if(r===XY)return t.RED;if(r===rO)return t.RED_INTEGER;if(r===iO)return t.RG;if(r===aO)return t.RG_INTEGER;if(r===sO)return t.RGBA_INTEGER;if(r===s1||r===o1||r===l1||r===c1)if(s===qn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===s1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===o1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===l1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===c1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===s1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===o1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===l1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===c1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Q3||r===J3||r===eP||r===tP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===Q3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===J3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===eP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===tP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===nP||r===rP||r===iP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===nP||r===rP)return s===qn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===iP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===aP||r===sP||r===oP||r===lP||r===cP||r===uP||r===dP||r===hP||r===fP||r===pP||r===mP||r===gP||r===xP||r===bP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===aP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===sP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===oP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===lP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===cP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===uP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===dP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===hP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===fP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===pP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===mP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===gP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===xP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===bP)return s===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===yP||r===vP||r===_P)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===yP)return s===qn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===vP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===_P)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===wP||r===SP||r===MP||r===EP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===wP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===SP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===MP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===EP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===V0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const jDe=`
  3860. void main() {
  3861. gl_Position = vec4( position, 1.0 );
  3862. }`,ODe=`
  3863. uniform sampler2DArray depthColor;
  3864. uniform float depthWidth;
  3865. uniform float depthHeight;
  3866. void main() {
  3867. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3868. if ( coord.x >= 1.0 ) {
  3869. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3870. } else {
  3871. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3872. }
  3873. }`;class LDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new gZ(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 Lc({vertexShader:jDe,fragmentShader:ODe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new xl(new hO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let IDe=class extends pf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",c=1,u=null,d=null,f=null,g=null,m=null,b=null;const y=typeof XRWebGLBinding<"u",v=new LDe,x={},M=n.getContextAttributes();let S=null,A=null;const T=[],k=[],N=new cn;let I=null;const C=new Ys;C.viewport=new Yr;const D=new Ys;D.viewport=new Yr;const F=[C,D],O=new eke;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pe){let be=T[pe];return be===void 0&&(be=new IC,T[pe]=be),be.getTargetRaySpace()},this.getControllerGrip=function(pe){let be=T[pe];return be===void 0&&(be=new IC,T[pe]=be),be.getGripSpace()},this.getHand=function(pe){let be=T[pe];return be===void 0&&(be=new IC,T[pe]=be),be.getHandSpace()};function W(pe){const be=k.indexOf(pe.inputSource);if(be===-1)return;const Ne=T[be];Ne!==void 0&&(Ne.update(pe.inputSource,pe.frame,u||s),Ne.dispatchEvent({type:pe.type,data:pe.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",G);for(let pe=0;pe<T.length;pe++){const be=k[pe];be!==null&&(k[pe]=null,T[pe].disconnect(be))}q=null,R=null,v.reset();for(const pe in x)delete x[pe];e.setRenderTarget(S),m=null,g=null,f=null,i=null,A=null,fe.stop(),r.isPresenting=!1,e.setPixelRatio(I),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pe){a=pe,r.isPresenting===!0&&Yt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pe){o=pe,r.isPresenting===!0&&Yt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(pe){u=pe},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(pe){if(i=pe,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",G),M.xrCompatible!==!0&&await n.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(N),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ne=null,ie=null,xe=null;M.depth&&(xe=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ne=M.stencil?W0:G0,ie=M.stencil?V0:Qh);const Re={colorFormat:n.RGBA8,depthFormat:xe,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(Re),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new ef(g.textureWidth,g.textureHeight,{format:Do,type:gl,depthTexture:new mZ(g.textureWidth,g.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Ne),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Ne={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,Ne),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new ef(m.framebufferWidth,m.framebufferHeight,{format:Do,type:gl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(o),fe.setContext(i),fe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function G(pe){for(let be=0;be<pe.removed.length;be++){const Ne=pe.removed[be],ie=k.indexOf(Ne);ie>=0&&(k[ie]=null,T[ie].disconnect(Ne))}for(let be=0;be<pe.added.length;be++){const Ne=pe.added[be];let ie=k.indexOf(Ne);if(ie===-1){for(let Re=0;Re<T.length;Re++)if(Re>=k.length){k.push(Ne),ie=Re;break}else if(k[Re]===null){k[Re]=Ne,ie=Re;break}if(ie===-1)break}const xe=T[ie];xe&&xe.connect(Ne)}}const ee=new Je,Z=new Je;function Q(pe,be,Ne){ee.setFromMatrixPosition(be.matrixWorld),Z.setFromMatrixPosition(Ne.matrixWorld);const ie=ee.distanceTo(Z),xe=be.projectionMatrix.elements,Re=Ne.projectionMatrix.elements,he=xe[14]/(xe[10]-1),ht=xe[14]/(xe[10]+1),H=(xe[9]+1)/xe[5],B=(xe[9]-1)/xe[5],re=(xe[8]-1)/xe[0],V=(Re[8]+1)/Re[0],J=he*re,se=he*V,Ae=ie/(-re+V),Pe=Ae*-re;if(be.matrixWorld.decompose(pe.position,pe.quaternion,pe.scale),pe.translateX(Pe),pe.translateZ(Ae),pe.matrixWorld.compose(pe.position,pe.quaternion,pe.scale),pe.matrixWorldInverse.copy(pe.matrixWorld).invert(),xe[10]===-1)pe.projectionMatrix.copy(be.projectionMatrix),pe.projectionMatrixInverse.copy(be.projectionMatrixInverse);else{const Se=he+Ae,z=ht+Ae,L=J-Pe,ne=se+(ie-Pe),ve=H*ht/z*Se,we=B*ht/z*Se;pe.projectionMatrix.makePerspective(L,ne,ve,we,Se,z),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert()}}function U(pe,be){be===null?pe.matrixWorld.copy(pe.matrix):pe.matrixWorld.multiplyMatrices(be.matrixWorld,pe.matrix),pe.matrixWorldInverse.copy(pe.matrixWorld).invert()}this.updateCamera=function(pe){if(i===null)return;let be=pe.near,Ne=pe.far;v.texture!==null&&(v.depthNear>0&&(be=v.depthNear),v.depthFar>0&&(Ne=v.depthFar)),O.near=D.near=C.near=be,O.far=D.far=C.far=Ne,(q!==O.near||R!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,R=O.far),O.layers.mask=pe.layers.mask|6,C.layers.mask=O.layers.mask&3,D.layers.mask=O.layers.mask&5;const ie=pe.parent,xe=O.cameras;U(O,ie);for(let Re=0;Re<xe.length;Re++)U(xe[Re],ie);xe.length===2?Q(O,C,D):O.projectionMatrix.copy(C.projectionMatrix),$(pe,O,ie)};function $(pe,be,Ne){Ne===null?pe.matrix.copy(be.matrixWorld):(pe.matrix.copy(Ne.matrixWorld),pe.matrix.invert(),pe.matrix.multiply(be.matrixWorld)),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.updateMatrixWorld(!0),pe.projectionMatrix.copy(be.projectionMatrix),pe.projectionMatrixInverse.copy(be.projectionMatrixInverse),pe.isPerspectiveCamera&&(pe.fov=AP*2*Math.atan(1/pe.projectionMatrix.elements[5]),pe.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(pe){c=pe,g!==null&&(g.fixedFoveation=pe),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=pe)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(O)},this.getCameraTexture=function(pe){return x[pe]};let X=null;function te(pe,be){if(d=be.getViewerPose(u||s),b=be,d!==null){const Ne=d.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let ie=!1;Ne.length!==O.cameras.length&&(O.cameras.length=0,ie=!0);for(let ht=0;ht<Ne.length;ht++){const H=Ne[ht];let B=null;if(m!==null)B=m.getViewport(H);else{const V=f.getViewSubImage(g,H);B=V.viewport,ht===0&&(e.setRenderTargetTextures(A,V.colorTexture,V.depthStencilTexture),e.setRenderTarget(A))}let re=F[ht];re===void 0&&(re=new Ys,re.layers.enable(ht),re.viewport=new Yr,F[ht]=re),re.matrix.fromArray(H.transform.matrix),re.matrix.decompose(re.position,re.quaternion,re.scale),re.projectionMatrix.fromArray(H.projectionMatrix),re.projectionMatrixInverse.copy(re.projectionMatrix).invert(),re.viewport.set(B.x,B.y,B.width,B.height),ht===0&&(O.matrix.copy(re.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),ie===!0&&O.cameras.push(re)}const xe=i.enabledFeatures;if(xe&&xe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const ht=f.getDepthInformation(Ne[0]);ht&&ht.isValid&&ht.texture&&v.init(ht,i.renderState)}if(xe&&xe.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let ht=0;ht<Ne.length;ht++){const H=Ne[ht].camera;if(H){let B=x[H];B||(B=new gZ,x[H]=B);const re=f.getCameraImage(H);B.sourceTexture=re}}}}for(let Ne=0;Ne<T.length;Ne++){const ie=k[Ne],xe=T[Ne];ie!==null&&xe!==void 0&&xe.update(ie,be,u||s)}X&&X(pe,be),be.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:be}),b=null}const fe=new vZ;fe.setAnimationLoop(te),this.setAnimationLoop=function(pe){X=pe},this.dispose=function(){}}};const Kd=new hd,FDe=new ri;function UDe(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function r(v,x){x.color.getRGB(v.fogColor.value,dZ(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function i(v,x,M,S,A){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),f(v,x)):x.isMeshPhongMaterial?(a(v,x),d(v,x)):x.isMeshStandardMaterial?(a(v,x),g(v,x),x.isMeshPhysicalMaterial&&m(v,x,A)):x.isMeshMatcapMaterial?(a(v,x),b(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),y(v,x)):x.isMeshNormalMaterial?a(v,x):x.isLineBasicMaterial?(s(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?c(v,x,M,S):x.isSpriteMaterial?u(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===qa&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===qa&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x),S=M.envMap,A=M.envMapRotation;S&&(v.envMap.value=S,Kd.copy(A),Kd.x*=-1,Kd.y*=-1,Kd.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Kd.y*=-1,Kd.z*=-1),v.envMapRotation.value.setFromMatrix4(FDe.makeRotationFromEuler(Kd)),v.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap&&(v.lightMap.value=x.lightMap,v.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,v.lightMapTransform)),x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function s(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function c(v,x,M,S){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=S*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function u(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function d(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function f(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function g(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),x.envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===qa&&v.clearcoatNormalScale.value.negate())),x.dispersion>0&&(v.dispersion.value=x.dispersion),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function b(v,x){x.matcap&&(v.matcap.value=x.matcap)}function y(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function zDe(t,e,n,r){let i={},a={},s=[];const o=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&&(b(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",v));const T=S.program;r.updateUBOMapping(M,T);const k=e.render.frame;a[M.id]!==k&&(g(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),T=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return zr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const S=i[M.id],A=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,N=A.length;k<N;k++){const I=Array.isArray(A[k])?A[k]:[A[k]];for(let C=0,D=I.length;C<D;C++){const F=I[C];if(m(F,k,C,T)===!0){const O=F.__offset,q=Array.isArray(F.value)?F.value:[F.value];let R=0;for(let W=0;W<q.length;W++){const K=q[W],G=y(K);typeof K=="number"||typeof K=="boolean"?(F.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,O+R,F.__data)):K.isMatrix3?(F.__data[0]=K.elements[0],F.__data[1]=K.elements[1],F.__data[2]=K.elements[2],F.__data[3]=0,F.__data[4]=K.elements[3],F.__data[5]=K.elements[4],F.__data[6]=K.elements[5],F.__data[7]=0,F.__data[8]=K.elements[6],F.__data[9]=K.elements[7],F.__data[10]=K.elements[8],F.__data[11]=0):(K.toArray(F.__data,R),R+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,S,A,T){const k=M.value,N=S+"_"+A;if(T[N]===void 0)return typeof k=="number"||typeof k=="boolean"?T[N]=k:T[N]=k.clone(),!0;{const I=T[N];if(typeof k=="number"||typeof k=="boolean"){if(I!==k)return T[N]=k,!0}else if(I.equals(k)===!1)return I.copy(k),!0}return!1}function b(M){const S=M.uniforms;let A=0;const T=16;for(let N=0,I=S.length;N<I;N++){const C=Array.isArray(S[N])?S[N]:[S[N]];for(let D=0,F=C.length;D<F;D++){const O=C[D],q=Array.isArray(O.value)?O.value:[O.value];for(let R=0,W=q.length;R<W;R++){const K=q[R],G=y(K),ee=A%T,Z=ee%G.boundary,Q=ee+Z;A+=Z,Q!==0&&T-Q<G.storage&&(A+=T-Q),O.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=A,A+=G.storage}}}const k=A%T;return k>0&&(A+=T-k),M.__size=A,M.__cache={},this}function y(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?Yt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Yt("WebGLRenderer: Unsupported uniform value type.",M),S}function v(M){const S=M.target;S.removeEventListener("dispose",v);const A=s.indexOf(S.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:c,update:u,dispose:x}}const BDe=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 Xl=null;function HDe(){return Xl===null&&(Xl=new HNe(BDe,32,32,iO,sg),Xl.minFilter=ro,Xl.magFilter=ro,Xl.wrapS=mc,Xl.wrapT=mc,Xl.generateMipmaps=!1,Xl.needsUpdate=!0),Xl}let $De=class{constructor(e={}){const{canvas:n=fNe(),context:r=null,depth:i=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=s;const b=new Set([sO,aO,rO]),y=new Set([gl,Qh,$0,V0,tO,nO]),v=new Uint32Array(4),x=new Int32Array(4);let M=null,S=null;const A=[],T=[];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=Yu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let N=!1;this._outputColorSpace=qs;let I=0,C=0,D=null,F=-1,O=null;const q=new Yr,R=new Yr;let W=null;const K=new _n(0);let G=0,ee=n.width,Z=n.height,Q=1,U=null,$=null;const X=new Yr(0,0,ee,Z),te=new Yr(0,0,ee,Z);let fe=!1;const pe=new dO;let be=!1,Ne=!1;const ie=new ri,xe=new Je,Re=new Yr,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ht=!1;function H(){return D===null?Q:1}let B=r;function re(ae,Me){return n.getContext(ae,Me)}try{const ae={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${Qj}`),n.addEventListener("webglcontextlost",Ce,!1),n.addEventListener("webglcontextrestored",_e,!1),n.addEventListener("webglcontextcreationerror",ce,!1),B===null){const Me="webgl2";if(B=re(Me,ae),B===null)throw re(Me)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ae){throw ae("WebGLRenderer: "+ae.message),ae}let V,J,se,Ae,Pe,Se,z,L,ne,ve,we,ye,nt,Be,ue,Ve,Fe,oe,et,He,Ke,ct,de,Ye;function ge(){V=new ZPe(B),V.init(),ct=new DDe(B,V),J=new HPe(B,V,e,ct),se=new PDe(B,V),J.reversedDepthBuffer&&g&&se.buffers.depth.setReversed(!0),Ae=new eRe(B),Pe=new bDe,Se=new RDe(B,V,se,Pe,J,ct,Ae),z=new VPe(k),L=new YPe(k),ne=new ike(B),de=new zPe(B,ne),ve=new QPe(B,ne,Ae,de),we=new nRe(B,ve,ne,Ae),et=new tRe(B,J,Se),Ve=new $Pe(Pe),ye=new xDe(k,z,L,V,J,de,Ve),nt=new UDe(k,Pe),Be=new vDe,ue=new ADe(V),oe=new UPe(k,z,L,se,we,m,c),Fe=new NDe(k,we,J),Ye=new zDe(B,Ae,J,se),He=new BPe(B,V,Ae),Ke=new JPe(B,V,Ae),Ae.programs=ye.programs,k.capabilities=J,k.extensions=V,k.properties=Pe,k.renderLists=Be,k.shadowMap=Fe,k.state=se,k.info=Ae}ge();const Ue=new IDe(k,B);this.xr=Ue,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){const ae=V.get("WEBGL_lose_context");ae&&ae.loseContext()},this.forceContextRestore=function(){const ae=V.get("WEBGL_lose_context");ae&&ae.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(ae){ae!==void 0&&(Q=ae,this.setSize(ee,Z,!1))},this.getSize=function(ae){return ae.set(ee,Z)},this.setSize=function(ae,Me,Ie=!0){if(Ue.isPresenting){Yt("WebGLRenderer: Can't change size while VR device is presenting.");return}ee=ae,Z=Me,n.width=Math.floor(ae*Q),n.height=Math.floor(Me*Q),Ie===!0&&(n.style.width=ae+"px",n.style.height=Me+"px"),this.setViewport(0,0,ae,Me)},this.getDrawingBufferSize=function(ae){return ae.set(ee*Q,Z*Q).floor()},this.setDrawingBufferSize=function(ae,Me,Ie){ee=ae,Z=Me,Q=Ie,n.width=Math.floor(ae*Ie),n.height=Math.floor(Me*Ie),this.setViewport(0,0,ae,Me)},this.getCurrentViewport=function(ae){return ae.copy(q)},this.getViewport=function(ae){return ae.copy(X)},this.setViewport=function(ae,Me,Ie,Oe){ae.isVector4?X.set(ae.x,ae.y,ae.z,ae.w):X.set(ae,Me,Ie,Oe),se.viewport(q.copy(X).multiplyScalar(Q).round())},this.getScissor=function(ae){return ae.copy(te)},this.setScissor=function(ae,Me,Ie,Oe){ae.isVector4?te.set(ae.x,ae.y,ae.z,ae.w):te.set(ae,Me,Ie,Oe),se.scissor(R.copy(te).multiplyScalar(Q).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(ae){se.setScissorTest(fe=ae)},this.setOpaqueSort=function(ae){U=ae},this.setTransparentSort=function(ae){$=ae},this.getClearColor=function(ae){return ae.copy(oe.getClearColor())},this.setClearColor=function(){oe.setClearColor(...arguments)},this.getClearAlpha=function(){return oe.getClearAlpha()},this.setClearAlpha=function(){oe.setClearAlpha(...arguments)},this.clear=function(ae=!0,Me=!0,Ie=!0){let Oe=0;if(ae){let Te=!1;if(D!==null){const ot=D.texture.format;Te=b.has(ot)}if(Te){const ot=D.texture.type,ft=y.has(ot),yt=oe.getClearColor(),bt=oe.getClearAlpha(),Lt=yt.r,Tt=yt.g,mt=yt.b;ft?(v[0]=Lt,v[1]=Tt,v[2]=mt,v[3]=bt,B.clearBufferuiv(B.COLOR,0,v)):(x[0]=Lt,x[1]=Tt,x[2]=mt,x[3]=bt,B.clearBufferiv(B.COLOR,0,x))}else Oe|=B.COLOR_BUFFER_BIT}Me&&(Oe|=B.DEPTH_BUFFER_BIT),Ie&&(Oe|=B.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B.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",Ce,!1),n.removeEventListener("webglcontextrestored",_e,!1),n.removeEventListener("webglcontextcreationerror",ce,!1),oe.dispose(),Be.dispose(),ue.dispose(),Pe.dispose(),z.dispose(),L.dispose(),we.dispose(),de.dispose(),Ye.dispose(),ye.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",On),Ue.removeEventListener("sessionend",Mi),si.stop()};function Ce(ae){ae.preventDefault(),B6("WebGLRenderer: Context Lost."),N=!0}function _e(){B6("WebGLRenderer: Context Restored."),N=!1;const ae=Ae.autoReset,Me=Fe.enabled,Ie=Fe.autoUpdate,Oe=Fe.needsUpdate,Te=Fe.type;ge(),Ae.autoReset=ae,Fe.enabled=Me,Fe.autoUpdate=Ie,Fe.needsUpdate=Oe,Fe.type=Te}function ce(ae){zr("WebGLRenderer: A WebGL context could not be created. Reason: ",ae.statusMessage)}function st(ae){const Me=ae.target;Me.removeEventListener("dispose",st),xt(Me)}function xt(ae){St(ae),Pe.remove(ae)}function St(ae){const Me=Pe.get(ae).programs;Me!==void 0&&(Me.forEach(function(Ie){ye.releaseProgram(Ie)}),ae.isShaderMaterial&&ye.releaseShaderCache(ae))}this.renderBufferDirect=function(ae,Me,Ie,Oe,Te,ot){Me===null&&(Me=he);const ft=Te.isMesh&&Te.matrixWorld.determinant()<0,yt=me(ae,Me,Ie,Oe,Te);se.setMaterial(Oe,ft);let bt=Ie.index,Lt=1;if(Oe.wireframe===!0){if(bt=ve.getWireframeAttribute(Ie),bt===void 0)return;Lt=2}const Tt=Ie.drawRange,mt=Ie.attributes.position;let Xt=Tt.start*Lt,Ut=(Tt.start+Tt.count)*Lt;ot!==null&&(Xt=Math.max(Xt,ot.start*Lt),Ut=Math.min(Ut,(ot.start+ot.count)*Lt)),bt!==null?(Xt=Math.max(Xt,0),Ut=Math.min(Ut,bt.count)):mt!=null&&(Xt=Math.max(Xt,0),Ut=Math.min(Ut,mt.count));const an=Ut-Xt;if(an<0||an===1/0)return;de.setup(Te,Oe,yt,Ie,bt);let hn,bn=He;if(bt!==null&&(hn=ne.get(bt),bn=Ke,bn.setIndex(hn)),Te.isMesh)Oe.wireframe===!0?(se.setLineWidth(Oe.wireframeLinewidth*H()),bn.setMode(B.LINES)):bn.setMode(B.TRIANGLES);else if(Te.isLine){let Ft=Oe.linewidth;Ft===void 0&&(Ft=1),se.setLineWidth(Ft*H()),Te.isLineSegments?bn.setMode(B.LINES):Te.isLineLoop?bn.setMode(B.LINE_LOOP):bn.setMode(B.LINE_STRIP)}else Te.isPoints?bn.setMode(B.POINTS):Te.isSprite&&bn.setMode(B.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)q0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bn.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(V.get("WEBGL_multi_draw"))bn.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const Ft=Te._multiDrawStarts,Jt=Te._multiDrawCounts,tn=Te._multiDrawCount,Ar=bt?ne.get(bt).bytesPerElement:1,Or=Pe.get(Oe).currentProgram.getUniforms();for(let Dn=0;Dn<tn;Dn++)Or.setValue(B,"_gl_DrawID",Dn),bn.render(Ft[Dn]/Ar,Jt[Dn])}else if(Te.isInstancedMesh)bn.renderInstances(Xt,an,Te.count);else if(Ie.isInstancedBufferGeometry){const Ft=Ie._maxInstanceCount!==void 0?Ie._maxInstanceCount:1/0,Jt=Math.min(Ie.instanceCount,Ft);bn.renderInstances(Xt,an,Jt)}else bn.render(Xt,an)};function Qt(ae,Me,Ie){ae.transparent===!0&&ae.side===rl&&ae.forceSinglePass===!1?(ae.side=qa,ae.needsUpdate=!0,jr(ae,Me,Ie),ae.side=dd,ae.needsUpdate=!0,jr(ae,Me,Ie),ae.side=rl):jr(ae,Me,Ie)}this.compile=function(ae,Me,Ie=null){Ie===null&&(Ie=ae),S=ue.get(Ie),S.init(Me),T.push(S),Ie.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Me.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),ae!==Ie&&ae.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Me.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),S.setupLights();const Oe=new Set;return ae.traverse(function(Te){if(!(Te.isMesh||Te.isPoints||Te.isLine||Te.isSprite))return;const ot=Te.material;if(ot)if(Array.isArray(ot))for(let ft=0;ft<ot.length;ft++){const yt=ot[ft];Qt(yt,Ie,Te),Oe.add(yt)}else Qt(ot,Ie,Te),Oe.add(ot)}),S=T.pop(),Oe},this.compileAsync=function(ae,Me,Ie=null){const Oe=this.compile(ae,Me,Ie);return new Promise(Te=>{function ot(){if(Oe.forEach(function(ft){Pe.get(ft).currentProgram.isReady()&&Oe.delete(ft)}),Oe.size===0){Te(ae);return}setTimeout(ot,10)}V.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let Ot=null;function Vt(ae){Ot&&Ot(ae)}function On(){si.stop()}function Mi(){si.start()}const si=new vZ;si.setAnimationLoop(Vt),typeof self<"u"&&si.setContext(self),this.setAnimationLoop=function(ae){Ot=ae,Ue.setAnimationLoop(ae),ae===null?si.stop():si.start()},Ue.addEventListener("sessionstart",On),Ue.addEventListener("sessionend",Mi),this.render=function(ae,Me){if(Me!==void 0&&Me.isCamera!==!0){zr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(ae.matrixWorldAutoUpdate===!0&&ae.updateMatrixWorld(),Me.parent===null&&Me.matrixWorldAutoUpdate===!0&&Me.updateMatrixWorld(),Ue.enabled===!0&&Ue.isPresenting===!0&&(Ue.cameraAutoUpdate===!0&&Ue.updateCamera(Me),Me=Ue.getCamera()),ae.isScene===!0&&ae.onBeforeRender(k,ae,Me,D),S=ue.get(ae,T.length),S.init(Me),T.push(S),ie.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),pe.setFromProjectionMatrix(ie,ol,Me.reversedDepth),Ne=this.localClippingEnabled,be=Ve.init(this.clippingPlanes,Ne),M=Be.get(ae,A.length),M.init(),A.push(M),Ue.enabled===!0&&Ue.isPresenting===!0){const ot=k.xr.getDepthSensingMesh();ot!==null&&Ei(ot,Me,-1/0,k.sortObjects)}Ei(ae,Me,0,k.sortObjects),M.finish(),k.sortObjects===!0&&M.sort(U,$),ht=Ue.enabled===!1||Ue.isPresenting===!1||Ue.hasDepthSensing()===!1,ht&&oe.addToRenderList(M,ae),this.info.render.frame++,be===!0&&Ve.beginShadows();const Ie=S.state.shadowsArray;Fe.render(Ie,ae,Me),be===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=M.opaque,Te=M.transmissive;if(S.setupLights(),Me.isArrayCamera){const ot=Me.cameras;if(Te.length>0)for(let ft=0,yt=ot.length;ft<yt;ft++){const bt=ot[ft];ra(Oe,Te,ae,bt)}ht&&oe.render(ae);for(let ft=0,yt=ot.length;ft<yt;ft++){const bt=ot[ft];zi(M,ae,bt,bt.viewport)}}else Te.length>0&&ra(Oe,Te,ae,Me),ht&&oe.render(ae),zi(M,ae,Me);D!==null&&C===0&&(Se.updateMultisampleRenderTarget(D),Se.updateRenderTargetMipmap(D)),ae.isScene===!0&&ae.onAfterRender(k,ae,Me),de.resetDefaultState(),F=-1,O=null,T.pop(),T.length>0?(S=T[T.length-1],be===!0&&Ve.setGlobalState(k.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?M=A[A.length-1]:M=null};function Ei(ae,Me,Ie,Oe){if(ae.visible===!1)return;if(ae.layers.test(Me.layers)){if(ae.isGroup)Ie=ae.renderOrder;else if(ae.isLOD)ae.autoUpdate===!0&&ae.update(Me);else if(ae.isLight)S.pushLight(ae),ae.castShadow&&S.pushShadow(ae);else if(ae.isSprite){if(!ae.frustumCulled||pe.intersectsSprite(ae)){Oe&&Re.setFromMatrixPosition(ae.matrixWorld).applyMatrix4(ie);const ft=we.update(ae),yt=ae.material;yt.visible&&M.push(ae,ft,yt,Ie,Re.z,null)}}else if((ae.isMesh||ae.isLine||ae.isPoints)&&(!ae.frustumCulled||pe.intersectsObject(ae))){const ft=we.update(ae),yt=ae.material;if(Oe&&(ae.boundingSphere!==void 0?(ae.boundingSphere===null&&ae.computeBoundingSphere(),Re.copy(ae.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),Re.copy(ft.boundingSphere.center)),Re.applyMatrix4(ae.matrixWorld).applyMatrix4(ie)),Array.isArray(yt)){const bt=ft.groups;for(let Lt=0,Tt=bt.length;Lt<Tt;Lt++){const mt=bt[Lt],Xt=yt[mt.materialIndex];Xt&&Xt.visible&&M.push(ae,ft,Xt,Ie,Re.z,mt)}}else yt.visible&&M.push(ae,ft,yt,Ie,Re.z,null)}}const ot=ae.children;for(let ft=0,yt=ot.length;ft<yt;ft++)Ei(ot[ft],Me,Ie,Oe)}function zi(ae,Me,Ie,Oe){const{opaque:Te,transmissive:ot,transparent:ft}=ae;S.setupLightsView(Ie),be===!0&&Ve.setGlobalState(k.clippingPlanes,Ie),Oe&&se.viewport(q.copy(Oe)),Te.length>0&&Hr(Te,Me,Ie),ot.length>0&&Hr(ot,Me,Ie),ft.length>0&&Hr(ft,Me,Ie),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function ra(ae,Me,Ie,Oe){if((Ie.isScene===!0?Ie.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Oe.id]===void 0&&(S.state.transmissionRenderTarget[Oe.id]=new ef(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")||V.has("EXT_color_buffer_float")?sg:gl,minFilter:xh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Cn.workingColorSpace}));const ot=S.state.transmissionRenderTarget[Oe.id],ft=Oe.viewport||q;ot.setSize(ft.z*k.transmissionResolutionScale,ft.w*k.transmissionResolutionScale);const yt=k.getRenderTarget(),bt=k.getActiveCubeFace(),Lt=k.getActiveMipmapLevel();k.setRenderTarget(ot),k.getClearColor(K),G=k.getClearAlpha(),G<1&&k.setClearColor(16777215,.5),k.clear(),ht&&oe.render(Ie);const Tt=k.toneMapping;k.toneMapping=Yu;const mt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),S.setupLightsView(Oe),be===!0&&Ve.setGlobalState(k.clippingPlanes,Oe),Hr(ae,Ie,Oe),Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot),V.has("WEBGL_multisampled_render_to_texture")===!1){let Xt=!1;for(let Ut=0,an=Me.length;Ut<an;Ut++){const hn=Me[Ut],{object:bn,geometry:Ft,material:Jt,group:tn}=hn;if(Jt.side===rl&&bn.layers.test(Oe.layers)){const Ar=Jt.side;Jt.side=qa,Jt.needsUpdate=!0,br(bn,Ie,Oe,Ft,Jt,tn),Jt.side=Ar,Jt.needsUpdate=!0,Xt=!0}}Xt===!0&&(Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot))}k.setRenderTarget(yt,bt,Lt),k.setClearColor(K,G),mt!==void 0&&(Oe.viewport=mt),k.toneMapping=Tt}function Hr(ae,Me,Ie){const Oe=Me.isScene===!0?Me.overrideMaterial:null;for(let Te=0,ot=ae.length;Te<ot;Te++){const ft=ae[Te],{object:yt,geometry:bt,group:Lt}=ft;let Tt=ft.material;Tt.allowOverride===!0&&Oe!==null&&(Tt=Oe),yt.layers.test(Ie.layers)&&br(yt,Me,Ie,bt,Tt,Lt)}}function br(ae,Me,Ie,Oe,Te,ot){ae.onBeforeRender(k,Me,Ie,Oe,Te,ot),ae.modelViewMatrix.multiplyMatrices(Ie.matrixWorldInverse,ae.matrixWorld),ae.normalMatrix.getNormalMatrix(ae.modelViewMatrix),Te.onBeforeRender(k,Me,Ie,Oe,ae,ot),Te.transparent===!0&&Te.side===rl&&Te.forceSinglePass===!1?(Te.side=qa,Te.needsUpdate=!0,k.renderBufferDirect(Ie,Me,Oe,Te,ae,ot),Te.side=dd,Te.needsUpdate=!0,k.renderBufferDirect(Ie,Me,Oe,Te,ae,ot),Te.side=rl):k.renderBufferDirect(Ie,Me,Oe,Te,ae,ot),ae.onAfterRender(k,Me,Ie,Oe,Te,ot)}function jr(ae,Me,Ie){Me.isScene!==!0&&(Me=he);const Oe=Pe.get(ae),Te=S.state.lights,ot=S.state.shadowsArray,ft=Te.state.version,yt=ye.getParameters(ae,Te.state,ot,Me,Ie),bt=ye.getProgramCacheKey(yt);let Lt=Oe.programs;Oe.environment=ae.isMeshStandardMaterial?Me.environment:null,Oe.fog=Me.fog,Oe.envMap=(ae.isMeshStandardMaterial?L:z).get(ae.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&ae.envMap===null?Me.environmentRotation:ae.envMapRotation,Lt===void 0&&(ae.addEventListener("dispose",st),Lt=new Map,Oe.programs=Lt);let Tt=Lt.get(bt);if(Tt!==void 0){if(Oe.currentProgram===Tt&&Oe.lightsStateVersion===ft)return $c(ae,yt),Tt}else yt.uniforms=ye.getUniforms(ae),ae.onBeforeCompile(yt,k),Tt=ye.acquireProgram(yt,bt),Lt.set(bt,Tt),Oe.uniforms=yt.uniforms;const mt=Oe.uniforms;return(!ae.isShaderMaterial&&!ae.isRawShaderMaterial||ae.clipping===!0)&&(mt.clippingPlanes=Ve.uniform),$c(ae,yt),Oe.needsLights=rt(ae),Oe.lightsStateVersion=ft,Oe.needsLights&&(mt.ambientLightColor.value=Te.state.ambient,mt.lightProbe.value=Te.state.probe,mt.directionalLights.value=Te.state.directional,mt.directionalLightShadows.value=Te.state.directionalShadow,mt.spotLights.value=Te.state.spot,mt.spotLightShadows.value=Te.state.spotShadow,mt.rectAreaLights.value=Te.state.rectArea,mt.ltc_1.value=Te.state.rectAreaLTC1,mt.ltc_2.value=Te.state.rectAreaLTC2,mt.pointLights.value=Te.state.point,mt.pointLightShadows.value=Te.state.pointShadow,mt.hemisphereLights.value=Te.state.hemi,mt.directionalShadowMap.value=Te.state.directionalShadowMap,mt.directionalShadowMatrix.value=Te.state.directionalShadowMatrix,mt.spotShadowMap.value=Te.state.spotShadowMap,mt.spotLightMatrix.value=Te.state.spotLightMatrix,mt.spotLightMap.value=Te.state.spotLightMap,mt.pointShadowMap.value=Te.state.pointShadowMap,mt.pointShadowMatrix.value=Te.state.pointShadowMatrix),Oe.currentProgram=Tt,Oe.uniformsList=null,Tt}function mo(ae){if(ae.uniformsList===null){const Me=ae.currentProgram.getUniforms();ae.uniformsList=f1.seqWithValue(Me.seq,ae.uniforms)}return ae.uniformsList}function $c(ae,Me){const Ie=Pe.get(ae);Ie.outputColorSpace=Me.outputColorSpace,Ie.batching=Me.batching,Ie.batchingColor=Me.batchingColor,Ie.instancing=Me.instancing,Ie.instancingColor=Me.instancingColor,Ie.instancingMorph=Me.instancingMorph,Ie.skinning=Me.skinning,Ie.morphTargets=Me.morphTargets,Ie.morphNormals=Me.morphNormals,Ie.morphColors=Me.morphColors,Ie.morphTargetsCount=Me.morphTargetsCount,Ie.numClippingPlanes=Me.numClippingPlanes,Ie.numIntersection=Me.numClipIntersection,Ie.vertexAlphas=Me.vertexAlphas,Ie.vertexTangents=Me.vertexTangents,Ie.toneMapping=Me.toneMapping}function me(ae,Me,Ie,Oe,Te){Me.isScene!==!0&&(Me=he),Se.resetTextureUnits();const ot=Me.fog,ft=Oe.isMeshStandardMaterial?Me.environment:null,yt=D===null?k.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Nm,bt=(Oe.isMeshStandardMaterial?L:z).get(Oe.envMap||ft),Lt=Oe.vertexColors===!0&&!!Ie.attributes.color&&Ie.attributes.color.itemSize===4,Tt=!!Ie.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),mt=!!Ie.morphAttributes.position,Xt=!!Ie.morphAttributes.normal,Ut=!!Ie.morphAttributes.color;let an=Yu;Oe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(an=k.toneMapping);const hn=Ie.morphAttributes.position||Ie.morphAttributes.normal||Ie.morphAttributes.color,bn=hn!==void 0?hn.length:0,Ft=Pe.get(Oe),Jt=S.state.lights;if(be===!0&&(Ne===!0||ae!==O)){const Ti=ae===O&&Oe.id===F;Ve.setState(Oe,ae,Ti)}let tn=!1;Oe.version===Ft.__version?(Ft.needsLights&&Ft.lightsStateVersion!==Jt.state.version||Ft.outputColorSpace!==yt||Te.isBatchedMesh&&Ft.batching===!1||!Te.isBatchedMesh&&Ft.batching===!0||Te.isBatchedMesh&&Ft.batchingColor===!0&&Te.colorTexture===null||Te.isBatchedMesh&&Ft.batchingColor===!1&&Te.colorTexture!==null||Te.isInstancedMesh&&Ft.instancing===!1||!Te.isInstancedMesh&&Ft.instancing===!0||Te.isSkinnedMesh&&Ft.skinning===!1||!Te.isSkinnedMesh&&Ft.skinning===!0||Te.isInstancedMesh&&Ft.instancingColor===!0&&Te.instanceColor===null||Te.isInstancedMesh&&Ft.instancingColor===!1&&Te.instanceColor!==null||Te.isInstancedMesh&&Ft.instancingMorph===!0&&Te.morphTexture===null||Te.isInstancedMesh&&Ft.instancingMorph===!1&&Te.morphTexture!==null||Ft.envMap!==bt||Oe.fog===!0&&Ft.fog!==ot||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==Ve.numPlanes||Ft.numIntersection!==Ve.numIntersection)||Ft.vertexAlphas!==Lt||Ft.vertexTangents!==Tt||Ft.morphTargets!==mt||Ft.morphNormals!==Xt||Ft.morphColors!==Ut||Ft.toneMapping!==an||Ft.morphTargetsCount!==bn)&&(tn=!0):(tn=!0,Ft.__version=Oe.version);let Ar=Ft.currentProgram;tn===!0&&(Ar=jr(Oe,Me,Te));let Or=!1,Dn=!1,go=!1;const Ln=Ar.getUniforms(),Ai=Ft.uniforms;if(se.useProgram(Ar.program)&&(Or=!0,Dn=!0,go=!0),Oe.id!==F&&(F=Oe.id,Dn=!0),Or||O!==ae){se.buffers.depth.getReversed()&&ae.reversedDepth!==!0&&(ae._reversedDepth=!0,ae.updateProjectionMatrix()),Ln.setValue(B,"projectionMatrix",ae.projectionMatrix),Ln.setValue(B,"viewMatrix",ae.matrixWorldInverse);const Bi=Ln.map.cameraPosition;Bi!==void 0&&Bi.setValue(B,xe.setFromMatrixPosition(ae.matrixWorld)),J.logarithmicDepthBuffer&&Ln.setValue(B,"logDepthBufFC",2/(Math.log(ae.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&Ln.setValue(B,"isOrthographic",ae.isOrthographicCamera===!0),O!==ae&&(O=ae,Dn=!0,go=!0)}if(Te.isSkinnedMesh){Ln.setOptional(B,Te,"bindMatrix"),Ln.setOptional(B,Te,"bindMatrixInverse");const Ti=Te.skeleton;Ti&&(Ti.boneTexture===null&&Ti.computeBoneTexture(),Ln.setValue(B,"boneTexture",Ti.boneTexture,Se))}Te.isBatchedMesh&&(Ln.setOptional(B,Te,"batchingTexture"),Ln.setValue(B,"batchingTexture",Te._matricesTexture,Se),Ln.setOptional(B,Te,"batchingIdTexture"),Ln.setValue(B,"batchingIdTexture",Te._indirectTexture,Se),Ln.setOptional(B,Te,"batchingColorTexture"),Te._colorsTexture!==null&&Ln.setValue(B,"batchingColorTexture",Te._colorsTexture,Se));const oi=Ie.morphAttributes;if((oi.position!==void 0||oi.normal!==void 0||oi.color!==void 0)&&et.update(Te,Ie,Ar),(Dn||Ft.receiveShadow!==Te.receiveShadow)&&(Ft.receiveShadow=Te.receiveShadow,Ln.setValue(B,"receiveShadow",Te.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Ai.envMap.value=bt,Ai.flipEnvMap.value=bt.isCubeTexture&&bt.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Me.environment!==null&&(Ai.envMapIntensity.value=Me.environmentIntensity),Ai.dfgLUT!==void 0&&(Ai.dfgLUT.value=HDe()),Dn&&(Ln.setValue(B,"toneMappingExposure",k.toneMappingExposure),Ft.needsLights&&$e(Ai,go),ot&&Oe.fog===!0&&nt.refreshFogUniforms(Ai,ot),nt.refreshMaterialUniforms(Ai,Oe,Q,Z,S.state.transmissionRenderTarget[ae.id]),f1.upload(B,mo(Ft),Ai,Se)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(f1.upload(B,mo(Ft),Ai,Se),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&Ln.setValue(B,"center",Te.center),Ln.setValue(B,"modelViewMatrix",Te.modelViewMatrix),Ln.setValue(B,"normalMatrix",Te.normalMatrix),Ln.setValue(B,"modelMatrix",Te.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Ti=Oe.uniformsGroups;for(let Bi=0,Vo=Ti.length;Bi<Vo;Bi++){const Al=Ti[Bi];Ye.update(Al,Ar),Ye.bind(Al,Ar)}}return Ar}function $e(ae,Me){ae.ambientLightColor.needsUpdate=Me,ae.lightProbe.needsUpdate=Me,ae.directionalLights.needsUpdate=Me,ae.directionalLightShadows.needsUpdate=Me,ae.pointLights.needsUpdate=Me,ae.pointLightShadows.needsUpdate=Me,ae.spotLights.needsUpdate=Me,ae.spotLightShadows.needsUpdate=Me,ae.rectAreaLights.needsUpdate=Me,ae.hemisphereLights.needsUpdate=Me}function rt(ae){return ae.isMeshLambertMaterial||ae.isMeshToonMaterial||ae.isMeshPhongMaterial||ae.isMeshStandardMaterial||ae.isShadowMaterial||ae.isShaderMaterial&&ae.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(ae,Me,Ie){const Oe=Pe.get(ae);Oe.__autoAllocateDepthBuffer=ae.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),Pe.get(ae.texture).__webglTexture=Me,Pe.get(ae.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Ie,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ae,Me){const Ie=Pe.get(ae);Ie.__webglFramebuffer=Me,Ie.__useDefaultFramebuffer=Me===void 0};const it=B.createFramebuffer();this.setRenderTarget=function(ae,Me=0,Ie=0){D=ae,I=Me,C=Ie;let Oe=!0,Te=null,ot=!1,ft=!1;if(ae){const bt=Pe.get(ae);if(bt.__useDefaultFramebuffer!==void 0)se.bindFramebuffer(B.FRAMEBUFFER,null),Oe=!1;else if(bt.__webglFramebuffer===void 0)Se.setupRenderTarget(ae);else if(bt.__hasExternalTextures)Se.rebindTextures(ae,Pe.get(ae.texture).__webglTexture,Pe.get(ae.depthTexture).__webglTexture);else if(ae.depthBuffer){const mt=ae.depthTexture;if(bt.__boundDepthTexture!==mt){if(mt!==null&&Pe.has(mt)&&(ae.width!==mt.image.width||ae.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(ae)}}const Lt=ae.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(ft=!0);const Tt=Pe.get(ae).__webglFramebuffer;ae.isWebGLCubeRenderTarget?(Array.isArray(Tt[Me])?Te=Tt[Me][Ie]:Te=Tt[Me],ot=!0):ae.samples>0&&Se.useMultisampledRTT(ae)===!1?Te=Pe.get(ae).__webglMultisampledFramebuffer:Array.isArray(Tt)?Te=Tt[Ie]:Te=Tt,q.copy(ae.viewport),R.copy(ae.scissor),W=ae.scissorTest}else q.copy(X).multiplyScalar(Q).floor(),R.copy(te).multiplyScalar(Q).floor(),W=fe;if(Ie!==0&&(Te=it),se.bindFramebuffer(B.FRAMEBUFFER,Te)&&Oe&&se.drawBuffers(ae,Te),se.viewport(q),se.scissor(R),se.setScissorTest(W),ot){const bt=Pe.get(ae.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+Me,bt.__webglTexture,Ie)}else if(ft){const bt=Me;for(let Lt=0;Lt<ae.textures.length;Lt++){const Tt=Pe.get(ae.textures[Lt]);B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0+Lt,Tt.__webglTexture,Ie,bt)}}else if(ae!==null&&Ie!==0){const bt=Pe.get(ae.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,bt.__webglTexture,Ie)}F=-1},this.readRenderTargetPixels=function(ae,Me,Ie,Oe,Te,ot,ft,yt=0){if(!(ae&&ae.isWebGLRenderTarget)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=Pe.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt){se.bindFramebuffer(B.FRAMEBUFFER,bt);try{const Lt=ae.textures[yt],Tt=Lt.format,mt=Lt.type;if(!J.textureFormatReadable(Tt)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!J.textureTypeReadable(mt)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Me>=0&&Me<=ae.width-Oe&&Ie>=0&&Ie<=ae.height-Te&&(ae.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+yt),B.readPixels(Me,Ie,Oe,Te,ct.convert(Tt),ct.convert(mt),ot))}finally{const Lt=D!==null?Pe.get(D).__webglFramebuffer:null;se.bindFramebuffer(B.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(ae,Me,Ie,Oe,Te,ot,ft,yt=0){if(!(ae&&ae.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=Pe.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt)if(Me>=0&&Me<=ae.width-Oe&&Ie>=0&&Ie<=ae.height-Te){se.bindFramebuffer(B.FRAMEBUFFER,bt);const Lt=ae.textures[yt],Tt=Lt.format,mt=Lt.type;if(!J.textureFormatReadable(Tt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Xt=B.createBuffer();B.bindBuffer(B.PIXEL_PACK_BUFFER,Xt),B.bufferData(B.PIXEL_PACK_BUFFER,ot.byteLength,B.STREAM_READ),ae.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+yt),B.readPixels(Me,Ie,Oe,Te,ct.convert(Tt),ct.convert(mt),0);const Ut=D!==null?Pe.get(D).__webglFramebuffer:null;se.bindFramebuffer(B.FRAMEBUFFER,Ut);const an=B.fenceSync(B.SYNC_GPU_COMMANDS_COMPLETE,0);return B.flush(),await pNe(B,an,4),B.bindBuffer(B.PIXEL_PACK_BUFFER,Xt),B.getBufferSubData(B.PIXEL_PACK_BUFFER,0,ot),B.deleteBuffer(Xt),B.deleteSync(an),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ae,Me=null,Ie=0){const Oe=Math.pow(2,-Ie),Te=Math.floor(ae.image.width*Oe),ot=Math.floor(ae.image.height*Oe),ft=Me!==null?Me.x:0,yt=Me!==null?Me.y:0;Se.setTexture2D(ae,0),B.copyTexSubImage2D(B.TEXTURE_2D,Ie,0,0,ft,yt,Te,ot),se.unbindTexture()};const tt=B.createFramebuffer(),Mt=B.createFramebuffer();this.copyTextureToTexture=function(ae,Me,Ie=null,Oe=null,Te=0,ot=null){ot===null&&(Te!==0?(q0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ot=Te,Te=0):ot=0);let ft,yt,bt,Lt,Tt,mt,Xt,Ut,an;const hn=ae.isCompressedTexture?ae.mipmaps[ot]:ae.image;if(Ie!==null)ft=Ie.max.x-Ie.min.x,yt=Ie.max.y-Ie.min.y,bt=Ie.isBox3?Ie.max.z-Ie.min.z:1,Lt=Ie.min.x,Tt=Ie.min.y,mt=Ie.isBox3?Ie.min.z:0;else{const oi=Math.pow(2,-Te);ft=Math.floor(hn.width*oi),yt=Math.floor(hn.height*oi),ae.isDataArrayTexture?bt=hn.depth:ae.isData3DTexture?bt=Math.floor(hn.depth*oi):bt=1,Lt=0,Tt=0,mt=0}Oe!==null?(Xt=Oe.x,Ut=Oe.y,an=Oe.z):(Xt=0,Ut=0,an=0);const bn=ct.convert(Me.format),Ft=ct.convert(Me.type);let Jt;Me.isData3DTexture?(Se.setTexture3D(Me,0),Jt=B.TEXTURE_3D):Me.isDataArrayTexture||Me.isCompressedArrayTexture?(Se.setTexture2DArray(Me,0),Jt=B.TEXTURE_2D_ARRAY):(Se.setTexture2D(Me,0),Jt=B.TEXTURE_2D),B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,Me.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Me.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,Me.unpackAlignment);const tn=B.getParameter(B.UNPACK_ROW_LENGTH),Ar=B.getParameter(B.UNPACK_IMAGE_HEIGHT),Or=B.getParameter(B.UNPACK_SKIP_PIXELS),Dn=B.getParameter(B.UNPACK_SKIP_ROWS),go=B.getParameter(B.UNPACK_SKIP_IMAGES);B.pixelStorei(B.UNPACK_ROW_LENGTH,hn.width),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,hn.height),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Lt),B.pixelStorei(B.UNPACK_SKIP_ROWS,Tt),B.pixelStorei(B.UNPACK_SKIP_IMAGES,mt);const Ln=ae.isDataArrayTexture||ae.isData3DTexture,Ai=Me.isDataArrayTexture||Me.isData3DTexture;if(ae.isDepthTexture){const oi=Pe.get(ae),Ti=Pe.get(Me),Bi=Pe.get(oi.__renderTarget),Vo=Pe.get(Ti.__renderTarget);se.bindFramebuffer(B.READ_FRAMEBUFFER,Bi.__webglFramebuffer),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,Vo.__webglFramebuffer);for(let Al=0;Al<bt;Al++)Ln&&(B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Pe.get(ae).__webglTexture,Te,mt+Al),B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Pe.get(Me).__webglTexture,ot,an+Al)),B.blitFramebuffer(Lt,Tt,ft,yt,Xt,Ut,ft,yt,B.DEPTH_BUFFER_BIT,B.NEAREST);se.bindFramebuffer(B.READ_FRAMEBUFFER,null),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else if(Te!==0||ae.isRenderTargetTexture||Pe.has(ae)){const oi=Pe.get(ae),Ti=Pe.get(Me);se.bindFramebuffer(B.READ_FRAMEBUFFER,tt),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,Mt);for(let Bi=0;Bi<bt;Bi++)Ln?B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,oi.__webglTexture,Te,mt+Bi):B.framebufferTexture2D(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,oi.__webglTexture,Te),Ai?B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Ti.__webglTexture,ot,an+Bi):B.framebufferTexture2D(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,Ti.__webglTexture,ot),Te!==0?B.blitFramebuffer(Lt,Tt,ft,yt,Xt,Ut,ft,yt,B.COLOR_BUFFER_BIT,B.NEAREST):Ai?B.copyTexSubImage3D(Jt,ot,Xt,Ut,an+Bi,Lt,Tt,ft,yt):B.copyTexSubImage2D(Jt,ot,Xt,Ut,Lt,Tt,ft,yt);se.bindFramebuffer(B.READ_FRAMEBUFFER,null),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else Ai?ae.isDataTexture||ae.isData3DTexture?B.texSubImage3D(Jt,ot,Xt,Ut,an,ft,yt,bt,bn,Ft,hn.data):Me.isCompressedArrayTexture?B.compressedTexSubImage3D(Jt,ot,Xt,Ut,an,ft,yt,bt,bn,hn.data):B.texSubImage3D(Jt,ot,Xt,Ut,an,ft,yt,bt,bn,Ft,hn):ae.isDataTexture?B.texSubImage2D(B.TEXTURE_2D,ot,Xt,Ut,ft,yt,bn,Ft,hn.data):ae.isCompressedTexture?B.compressedTexSubImage2D(B.TEXTURE_2D,ot,Xt,Ut,hn.width,hn.height,bn,hn.data):B.texSubImage2D(B.TEXTURE_2D,ot,Xt,Ut,ft,yt,bn,Ft,hn);B.pixelStorei(B.UNPACK_ROW_LENGTH,tn),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,Ar),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Or),B.pixelStorei(B.UNPACK_SKIP_ROWS,Dn),B.pixelStorei(B.UNPACK_SKIP_IMAGES,go),ot===0&&Me.generateMipmaps&&B.generateMipmap(Jt),se.unbindTexture()},this.initRenderTarget=function(ae){Pe.get(ae).__webglFramebuffer===void 0&&Se.setupRenderTarget(ae)},this.initTexture=function(ae){ae.isCubeTexture?Se.setTextureCube(ae,0):ae.isData3DTexture?Se.setTexture3D(ae,0):ae.isDataArrayTexture||ae.isCompressedArrayTexture?Se.setTexture2DArray(ae,0):Se.setTexture2D(ae,0),se.unbindTexture()},this.resetState=function(){I=0,C=0,D=null,se.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ol}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Cn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Cn._getUnpackColorSpace()}};const LH={type:"change"},fO={type:"start"},EZ={type:"end"},r_=new lO,IH=new ku,VDe=Math.cos(70*gNe.DEG2RAD),ci=new Je,Ba=2*Math.PI,Yn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},WC=1e-6;class GDe extends nke{constructor(e,n=null){super(e,n),this.state=Yn.NONE,this.target=new Je,this.cursor=new Je,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:nm.ROTATE,MIDDLE:nm.DOLLY,RIGHT:nm.PAN},this.touches={ONE:qp.ROTATE,TWO:qp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Je,this._lastQuaternion=new Jh,this._lastTargetPosition=new Je,this._quat=new Jh().setFromUnitVectors(e.up,new Je(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new dH,this._sphericalDelta=new dH,this._scale=1,this._panOffset=new Je,this._rotateStart=new cn,this._rotateEnd=new cn,this._rotateDelta=new cn,this._panStart=new cn,this._panEnd=new cn,this._panDelta=new cn,this._dollyStart=new cn,this._dollyEnd=new cn,this._dollyDelta=new cn,this._dollyDirection=new Je,this._mouse=new cn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=qDe.bind(this),this._onPointerDown=WDe.bind(this),this._onPointerUp=KDe.bind(this),this._onContextMenu=tje.bind(this),this._onMouseWheel=ZDe.bind(this),this._onKeyDown=QDe.bind(this),this._onTouchStart=JDe.bind(this),this._onTouchMove=eje.bind(this),this._onMouseDown=XDe.bind(this),this._onMouseMove=YDe.bind(this),this._interceptControlDown=nje.bind(this),this._interceptControlUp=rje.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(LH),this.update(),this.state=Yn.NONE}update(e=null){const n=this.object.position;ci.copy(n).sub(this.target),ci.applyQuaternion(this._quat),this._spherical.setFromVector3(ci),this.autoRotate&&this.state===Yn.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+=Ba:r>Math.PI&&(r-=Ba),i<-Math.PI?i+=Ba:i>Math.PI&&(i-=Ba),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 s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=s!=this._spherical.radius}if(ci.setFromSpherical(this._spherical),ci.applyQuaternion(this._quatInverse),n.copy(this.target).add(ci),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 s=null;if(this.object.isPerspectiveCamera){const o=ci.length();s=this._clampDistance(o*this._scale);const c=o-s;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const o=new Je(this._mouse.x,this._mouse.y,0);o.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 Je(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(o),this.object.updateMatrixWorld(),s=ci.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(r_.origin.copy(this.object.position),r_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(r_.direction))<VDe?this.object.lookAt(this.target):(IH.setFromNormalAndCoplanarPoint(this.object.up,this.target),r_.intersectPlane(IH,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>WC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>WC||this._lastTargetPosition.distanceToSquared(this.target)>WC?(this.dispatchEvent(LH),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ba/60*this.autoRotateSpeed*e:Ba/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){ci.setFromMatrixColumn(n,0),ci.multiplyScalar(-e),this._panOffset.add(ci)}_panUp(e,n){this.screenSpacePanning===!0?ci.setFromMatrixColumn(n,1):(ci.setFromMatrixColumn(n,0),ci.crossVectors(this.object.up,ci)),ci.multiplyScalar(e),this._panOffset.add(ci)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ci.copy(i).sub(this.target);let a=ci.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,s=r.width,o=r.height;this._mouse.x=i/s*2-1,this._mouse.y=-(a/o)*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(Ba*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ba*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(Ba*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(-Ba*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(Ba*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(-Ba*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(Ba*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ba*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 s=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(s,o)}_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 cn,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 WDe(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 qDe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function KDe(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(EZ),this.state=Yn.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 XDe(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 nm.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Yn.DOLLY;break;case nm.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Yn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Yn.ROTATE}break;case nm.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Yn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Yn.PAN}break;default:this.state=Yn.NONE}this.state!==Yn.NONE&&this.dispatchEvent(fO)}function YDe(t){switch(this.state){case Yn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Yn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Yn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function ZDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Yn.NONE||(t.preventDefault(),this.dispatchEvent(fO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(EZ))}function QDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function JDe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case qp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Yn.TOUCH_ROTATE;break;case qp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Yn.TOUCH_PAN;break;default:this.state=Yn.NONE}break;case 2:switch(this.touches.TWO){case qp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Yn.TOUCH_DOLLY_PAN;break;case qp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Yn.TOUCH_DOLLY_ROTATE;break;default:this.state=Yn.NONE}break;default:this.state=Yn.NONE}this.state!==Yn.NONE&&this.dispatchEvent(fO)}function eje(t){switch(this._trackPointer(t),this.state){case Yn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Yn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Yn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Yn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Yn.NONE}}function tje(t){this.enabled!==!1&&t.preventDefault()}function nje(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function rje(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ije(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={},s={},o=t[0].morphTargetsRelative,c=new El;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.attributes[m]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in f.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;s[m]===void 0&&(s[m]=[]),s[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=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,m,d),u+=m}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const m=t[g].index;for(let b=0;b<m.count;++b)f.push(m.getX(b)+d);d+=t[g].attributes.position.count}c.setIndex(f)}for(const d in a){const f=FH(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 s){const f=s[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let g=0;g<f;++g){const m=[];for(let y=0;y<s[d].length;++y)m.push(s[d][y][g]);const b=FH(m);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(b)}}return c}function FH(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 s=new e(a),o=new io(s,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let g=0,m=d.count;g<m;g++)for(let b=0;b<n;b++){const y=d.getComponent(g,b);o.setComponent(g+f,b,y)}}else s.set(d.array,c);c+=d.count*n}return i!==void 0&&(o.gpuType=i),o}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 qC={exports:{}};var UH;function aje(){return UH||(UH=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function s(u,d){if(!i[u]){if(!r[u]){var f=typeof i_=="function"&&i_;if(!d&&f)return f(u,!0);if(o)return o(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(b){var y=r[u][1][b];return s(y||b)},m,m.exports,n,r,i,a)}return i[u].exports}for(var o=typeof i_=="function"&&i_,c=0;c<a.length;c++)s(a[c]);return s})({1:[function(n,r,i){var a=n("./utils"),s=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,m,b,y,v=[],x=0,M=c.length,S=M,A=a.getTypeOf(c)!=="string";x<c.length;)S=M-x,f=A?(u=c[x++],d=x<M?c[x++]:0,x<M?c[x++]:0):(u=c.charCodeAt(x++),d=x<M?c.charCodeAt(x++):0,x<M?c.charCodeAt(x++):0),g=u>>2,m=(3&u)<<4|d>>4,b=1<S?(15&d)<<2|f>>6:64,y=2<S?63&f:64,v.push(o.charAt(g)+o.charAt(m)+o.charAt(b)+o.charAt(y));return v.join("")},i.decode=function(c){var u,d,f,g,m,b,y=0,v=0,x="data:";if(c.substr(0,x.length)===x)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)===o.charAt(64)&&S--,c.charAt(c.length-2)===o.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(M=s.uint8array?new Uint8Array(0|S):new Array(0|S);y<c.length;)u=o.indexOf(c.charAt(y++))<<2|(g=o.indexOf(c.charAt(y++)))>>4,d=(15&g)<<4|(m=o.indexOf(c.charAt(y++)))>>2,f=(3&m)<<6|(b=o.indexOf(c.charAt(y++))),M[v++]=u,m!==64&&(M[v++]=d),b!==64&&(M[v++]=f);return M}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),s=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,g,m,b){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=m,this.compressedContent=b}u.prototype={getContentWorker:function(){var d=new s(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 s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,g){return d.pipe(new o).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),s=(function(){for(var o,c=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;c[u]=o}return c})();r.exports=function(o,c){return o!==void 0&&o.length?a.getTypeOf(o)!=="string"?(function(u,d,f,g){var m=s,b=g+f;u^=-1;for(var y=g;y<b;y++)u=u>>>8^m[255&(u^d[y])];return-1^u})(0|c,o,o.length,0):(function(u,d,f,g){var m=s,b=g+f;u^=-1;for(var y=g;y<b;y++)u=u>>>8^m[255&(u^d.charCodeAt(y))];return-1^u})(0|c,o,o.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",s=n("pako"),o=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.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 s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(m,b){var y,v="";for(y=0;y<b;y++)v+=String.fromCharCode(255&m),m>>>=8;return v}function s(m,b,y,v,x,M){var S,A,T=m.file,k=m.compression,N=M!==u.utf8encode,I=o.transformTo("string",M(T.name)),C=o.transformTo("string",u.utf8encode(T.name)),D=T.comment,F=o.transformTo("string",M(D)),O=o.transformTo("string",u.utf8encode(D)),q=C.length!==T.name.length,R=O.length!==D.length,W="",K="",G="",ee=T.dir,Z=T.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};b&&!y||(Q.crc32=m.crc32,Q.compressedSize=m.compressedSize,Q.uncompressedSize=m.uncompressedSize);var U=0;b&&(U|=8),N||!q&&!R||(U|=2048);var $=0,X=0;ee&&($|=16),x==="UNIX"?(X=798,$|=(function(fe,pe){var be=fe;return fe||(be=pe?16893:33204),(65535&be)<<16})(T.unixPermissions,ee)):(X=20,$|=(function(fe){return 63&(fe||0)})(T.dosPermissions)),S=Z.getUTCHours(),S<<=6,S|=Z.getUTCMinutes(),S<<=5,S|=Z.getUTCSeconds()/2,A=Z.getUTCFullYear()-1980,A<<=4,A|=Z.getUTCMonth()+1,A<<=5,A|=Z.getUTCDate(),q&&(K=a(1,1)+a(d(I),4)+C,W+="up"+a(K.length,2)+K),R&&(G=a(1,1)+a(d(F),4)+O,W+="uc"+a(G.length,2)+G);var te="";return te+=`
  3874. \0`,te+=a(U,2),te+=k.magic,te+=a(S,2),te+=a(A,2),te+=a(Q.crc32,4),te+=a(Q.compressedSize,4),te+=a(Q.uncompressedSize,4),te+=a(I.length,2),te+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+te+I+W,dirRecord:f.CENTRAL_FILE_HEADER+a(X,2)+te+a(F.length,2)+"\0\0\0\0"+a($,4)+a(v,4)+I+W+F}}var o=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(m,b,y,v){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=y,this.encodeFileName=v,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(g,c),g.prototype.push=function(m){var b=m.meta.percent||0,y=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(b+100*(y-v-1))/y:100}}))},g.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var b=this.streamFiles&&!m.file.dir;if(b){var y=s(m,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(m){this.accumulate=!1;var b=this.streamFiles&&!m.file.dir,y=s(m,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),b)this.push({data:(function(v){return f.DATA_DESCRIPTOR+a(v.crc32,4)+a(v.compressedSize,4)+a(v.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var m=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var y=this.bytesWritten-m,v=(function(x,M,S,A,T){var k=o.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(x,2)+a(x,2)+a(M,4)+a(S,4)+a(k.length,2)+k})(this.dirRecords.length,y,m,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(m){this._sources.push(m);var b=this;return m.on("data",function(y){b.processChunk(y)}),m.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),m.on("error",function(y){b.error(y)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(m){var b=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var y=0;y<b.length;y++)try{b[y].error(m)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,b=0;b<m.length;b++)m[b].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(o,c,u){var d=new s(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{o.forEach(function(g,m){f++;var b=(function(M,S){var A=M||S,T=a[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(m.options.compression,c.compression),y=m.options.compressionOptions||c.compressionOptions||{},v=m.dir,x=m.date;m._compressWorker(b,y).withStreamInfo("file",{name:g,dir:v,date:x,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,o){return new a().loadAsync(s,o)},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"),s=n("./external"),o=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new s.Promise(function(m,b){var y=g.decompressed.getContentWorker().pipe(new u);y.on("error",function(v){b(v)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var b=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(y){var v=new c(m);return v.load(y),v}).then(function(y){var v=[s.Promise.resolve(y)],x=y.files;if(m.checkCRC32)for(var M=0;M<x.length;M++)v.push(f(x[M]));return s.Promise.all(v)}).then(function(y){for(var v=y.shift(),x=v.files,M=0;M<x.length;M++){var S=x[M],A=S.fileNameStr,T=a.resolve(S.fileNameStr);b.file(T,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:m.createFolders}),S.dir||(b.file(T).unsafeOriginalName=A)}return v.zipComment.length&&(b.comment=v.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),s=n("../stream/GenericWorker");function o(c,u){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(o,s),o.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()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function s(o,c,u){a.call(this,c),this._helper=o;var d=this;o.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(T,k,N){var I,C=o.getTypeOf(k),D=o.extend(N||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(T=x(T)),D.createFolders&&(I=v(T))&&M.call(this,I,!0);var F=C==="string"&&D.binary===!1&&D.base64===!1;N&&N.binary!==void 0||(D.binary=!F),(k instanceof f&&k.uncompressedSize===0||D.dir||!k||k.length===0)&&(D.base64=!1,D.binary=!0,k="",D.compression="STORE",C="string");var O=null;O=k instanceof f||k instanceof c?k:b.isNode&&b.isStream(k)?new y(T,k):o.prepareContent(T,k,D.binary,D.optimizedBinaryString,D.base64);var q=new g(T,O,D);this.files[T]=q}var s=n("./utf8"),o=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),b=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),v=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var k=T.lastIndexOf("/");return 0<k?T.substring(0,k):""},x=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},M=function(T,k){return k=k!==void 0?k:d.createFolders,T=x(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:k}),this.files[T]};function S(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var k,N,I;for(k in this.files)I=this.files[k],(N=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&T(N,I)},filter:function(T){var k=[];return this.forEach(function(N,I){T(N,I)&&k.push(I)}),k},file:function(T,k,N){if(arguments.length!==1)return T=this.root+T,a.call(this,T,k,N),this;if(S(T)){var I=T;return this.filter(function(D,F){return!F.dir&&I.test(D)})}var C=this.files[this.root+T];return C&&!C.dir?C:null},folder:function(T){if(!T)return this;if(S(T))return this.filter(function(C,D){return D.dir&&T.test(C)});var k=this.root+T,N=M.call(this,k),I=this.clone();return I.root=N.name,I},remove:function(T){T=this.root+T;var k=this.files[T];if(k||(T.slice(-1)!=="/"&&(T+="/"),k=this.files[T]),k&&!k.dir)delete this.files[T];else for(var N=this.filter(function(C,D){return D.name.slice(0,T.length)===T}),I=0;I<N.length;I++)delete this.files[N[I].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var k,N={};try{if((N=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");o.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var I=N.comment||this.comment||"";k=m.generateWorker(this,N,I)}catch(C){(k=new c("error")).error(C)}return new u(k,N.type||"string",N.mimeType)},generateAsync:function(T,k){return this.generateInternalStream(T).accumulate(k)},generateNodeStream:function(T,k){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(k)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o);for(var c=0;c<this.data.length;c++)o[c]=255&o[c]}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.readData(4);return c===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var c,u=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=o,u},readString:function(o){return a.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),s=n("../support"),o=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=a.getTypeOf(f);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new u(f):s.uint8array?new d(a.transformTo("uint8array",f)):new o(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"),s=n("../utils");function o(c){a.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(o,a),o.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),s=n("../crc32");function o(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,a),o.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(o,s),o.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}s.prototype.processChunk.call(this,c)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.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(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.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=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(s){this.name=s||"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(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(c){o.processChunk(c)}),s.on("end",function(){o.end()}),s.on("error",function(c){o.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 s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},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 s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),s=n("./ConvertWorker"),o=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(b,y){return new d.Promise(function(v,x){var M=[],S=b._internalType,A=b._outputType,T=b._mimeType;b.on("data",function(k,N){M.push(k),y&&y(N)}).on("error",function(k){M=[],x(k)}).on("end",function(){try{var k=(function(N,I,C){switch(N){case"blob":return a.newBlob(a.transformTo("arraybuffer",I),C);case"base64":return c.encode(I);default:return a.transformTo(N,I)}})(A,(function(N,I){var C,D=0,F=null,O=0;for(C=0;C<I.length;C++)O+=I[C].length;switch(N){case"string":return I.join("");case"array":return Array.prototype.concat.apply([],I);case"uint8array":for(F=new Uint8Array(O),C=0;C<I.length;C++)F.set(I[C],D),D+=I[C].length;return F;case"nodebuffer":return Buffer.concat(I);default:throw new Error("concat : unsupported type '"+N+"'")}})(S,M),T);v(k)}catch(N){x(N)}M=[]}).resume()})}function m(b,y,v){var x=y;switch(y){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=y,this._mimeType=v,a.checkSupport(x),this._worker=b.pipe(new s(x)),b.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}m.prototype={accumulate:function(b){return g(this,b)},on:function(b,y){var v=this;return b==="data"?this._worker.on(b,function(x){y.call(v,x.data,x.meta)}):this._worker.on(b,function(){a.delay(y,arguments,v)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},b)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),i.blob=s.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"),s=n("./support"),o=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}i.utf8encode=function(m){return s.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(b){var y,v,x,M,S,A=b.length,T=0;for(M=0;M<A;M++)(64512&(v=b.charCodeAt(M)))==55296&&M+1<A&&(64512&(x=b.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),T+=v<128?1:v<2048?2:v<65536?3:4;for(y=s.uint8array?new Uint8Array(T):new Array(T),M=S=0;S<T;M++)(64512&(v=b.charCodeAt(M)))==55296&&M+1<A&&(64512&(x=b.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),v<128?y[S++]=v:(v<2048?y[S++]=192|v>>>6:(v<65536?y[S++]=224|v>>>12:(y[S++]=240|v>>>18,y[S++]=128|v>>>12&63),y[S++]=128|v>>>6&63),y[S++]=128|63&v);return y})(m)},i.utf8decode=function(m){return s.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(b){var y,v,x,M,S=b.length,A=new Array(2*S);for(y=v=0;y<S;)if((x=b[y++])<128)A[v++]=x;else if(4<(M=u[x]))A[v++]=65533,y+=M-1;else{for(x&=M===2?31:M===3?15:7;1<M&&y<S;)x=x<<6|63&b[y++],M--;1<M?A[v++]=65533:x<65536?A[v++]=x:(x-=65536,A[v++]=55296|x>>10&1023,A[v++]=56320|1023&x)}return A.length!==v&&(A.subarray?A=A.subarray(0,v):A.length=v),a.applyFromCharCode(A)})(m=a.transformTo(s.uint8array?"uint8array":"array",m))},a.inherits(f,c),f.prototype.processChunk=function(m){var b=a.transformTo(s.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var y=b;(b=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),b.set(y,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var v=(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})(b),x=b;v!==b.length&&(s.uint8array?(x=b.subarray(0,v),this.leftOver=b.subarray(v,b.length)):(x=b.slice(0,v),this.leftOver=b.slice(v,b.length))),this.push({data:i.utf8decode(x),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(g,c),g.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),s=n("./base64"),o=n("./nodejsUtils"),c=n("./external");function u(y){return y}function d(y,v){for(var x=0;x<y.length;++x)v[x]=255&y.charCodeAt(x);return v}n("setimmediate"),i.newBlob=function(y,v){i.checkSupport("blob");try{return new Blob([y],{type:v})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(y),x.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,v,x){var M=[],S=0,A=y.length;if(A<=x)return String.fromCharCode.apply(null,y);for(;S<A;)v==="array"||v==="nodebuffer"?M.push(String.fromCharCode.apply(null,y.slice(S,Math.min(S+x,A)))):M.push(String.fromCharCode.apply(null,y.subarray(S,Math.min(S+x,A)))),S+=x;return M.join("")},stringifyByChar:function(y){for(var v="",x=0;x<y.length;x++)v+=String.fromCharCode(y[x]);return v},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,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(y){var v=65536,x=i.getTypeOf(y),M=!0;if(x==="uint8array"?M=f.applyCanBeUsed.uint8array:x==="nodebuffer"&&(M=f.applyCanBeUsed.nodebuffer),M)for(;1<v;)try{return f.stringifyByChunk(y,x,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(y)}function m(y,v){for(var x=0;x<y.length;x++)v[x]=y[x];return v}i.applyFromCharCode=g;var b={};b.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return b.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,o.allocBuffer(y.length))}},b.array={string:g,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(y)}},b.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(new Uint8Array(y))}},b.uint8array={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return o.newBufferFrom(y)}},b.nodebuffer={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return b.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,v){if(v=v||"",!y)return v;i.checkSupport(y);var x=i.getTypeOf(v);return b[x][y](v)},i.resolve=function(y){for(var v=y.split("/"),x=[],M=0;M<v.length;M++){var S=v[M];S==="."||S===""&&M!==0&&M!==v.length-1||(S===".."?x.pop():x.push(S))}return x.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(y)?"nodebuffer":a.uint8array&&y instanceof Uint8Array?"uint8array":a.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!a[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var v,x,M="";for(x=0;x<(y||"").length;x++)M+="\\x"+((v=y.charCodeAt(x))<16?"0":"")+v.toString(16).toUpperCase();return M},i.delay=function(y,v,x){setImmediate(function(){y.apply(x||null,v||[])})},i.inherits=function(y,v){function x(){}x.prototype=v.prototype,y.prototype=new x},i.extend=function(){var y,v,x={};for(y=0;y<arguments.length;y++)for(v in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],v)&&x[v]===void 0&&(x[v]=arguments[y][v]);return x},i.prepareContent=function(y,v,x,M,S){return c.Promise.resolve(v).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(T,k){var N=new FileReader;N.onload=function(I){T(I.target.result)},N.onerror=function(I){k(I.target.error)},N.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(S?A=s.decode(A):x&&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 '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(f)+")")}},isSignature:function(f,g){var m=this.reader.index;this.reader.setIndex(f);var b=this.reader.readString(4)===g;return this.reader.setIndex(m),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",m=s.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,m,b=this.zip64EndOfCentralSize-44;0<b;)f=this.reader.readInt(2),g=this.reader.readInt(4),m=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.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(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.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(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.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(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var b=g-m;if(0<b)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(m,b){this.options=m,this.loadOptions=b}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var b,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(v){for(var x in d)if(Object.prototype.hasOwnProperty.call(d,x)&&d[x].magic===v)return d[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,b,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var b=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(b),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var b,y,v,x=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<x;)b=m.readInt(2),y=m.readInt(2),v=m.readData(y),this.extraFields[b]={id:b,length:y,value:v};m.setIndex(x)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var y=s.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var x=s.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var b=a(m.value);return b.readInt(1)!==1||c(this.fileName)!==b.readInt(4)?null:u.utf8decode(b.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var b=a(m.value);return b.readInt(1)!==1||c(this.fileComment)!==b.readInt(4)?null:u.utf8decode(b.readData(m.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(b,y,v){this.name=b,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=y,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var s=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(b){var y=null,v="string";try{if(!b)throw new Error("No output type specified.");var x=(v=b.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),y=this._decompressWorker();var M=!this._dataBinary;M&&!x&&(y=y.pipe(new c.Utf8EncodeWorker)),!M&&x&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(S){(y=new d("error")).error(S)}return new s(y,v,"")},async:function(b,y){return this.internalStream(b).accumulate(y)},nodeStream:function(b,y){return this.internalStream(b||"nodebuffer").toNodejsStream(y)},_compressWorker:function(b,y){if(this._data instanceof u&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(v,b,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var s,o,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(b),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),s=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var y=a.document.createElement("script");y.onreadystatechange=function(){b(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},a.document.documentElement.appendChild(y)}:function(){setTimeout(b,0)};else{var g=new a.MessageChannel;g.port1.onmessage=b,s=function(){g.port2.postMessage(0)}}var m=[];function b(){var y,v;o=!0;for(var x=m.length;x;){for(v=m,m=[],y=-1;++y<x;)v[y]();x=m.length}o=!1}r.exports=function(y){m.push(y)!==1||o||s()}}).call(this,typeof hv<"u"?hv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function s(){}var o={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,x!==s&&y(this,x)}function g(x,M,S){this.promise=x,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function m(x,M,S){a(function(){var A;try{A=M(S)}catch(T){return o.reject(x,T)}A===x?o.reject(x,new TypeError("Cannot resolve promise with itself")):o.resolve(x,A)})}function b(x){var M=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof M=="function")return function(){M.apply(x,arguments)}}function y(x,M){var S=!1;function A(N){S||(S=!0,o.reject(x,N))}function T(N){S||(S=!0,o.resolve(x,N))}var k=v(function(){M(T,A)});k.status==="error"&&A(k.value)}function v(x,M){var S={};try{S.value=x(M),S.status="success"}catch(A){S.status="error",S.value=A}return S}(r.exports=f).prototype.finally=function(x){if(typeof x!="function")return this;var M=this.constructor;return this.then(function(S){return M.resolve(x()).then(function(){return S})},function(S){return M.resolve(x()).then(function(){throw S})})},f.prototype.catch=function(x){return this.then(null,x)},f.prototype.then=function(x,M){if(typeof x!="function"&&this.state===u||typeof M!="function"&&this.state===c)return this;var S=new this.constructor(s);return this.state!==d?m(S,this.state===u?x:M,this.outcome):this.queue.push(new g(S,x,M)),S},g.prototype.callFulfilled=function(x){o.resolve(this.promise,x)},g.prototype.otherCallFulfilled=function(x){m(this.promise,this.onFulfilled,x)},g.prototype.callRejected=function(x){o.reject(this.promise,x)},g.prototype.otherCallRejected=function(x){m(this.promise,this.onRejected,x)},o.resolve=function(x,M){var S=v(b,M);if(S.status==="error")return o.reject(x,S.value);var A=S.value;if(A)y(x,A);else{x.state=u,x.outcome=M;for(var T=-1,k=x.queue.length;++T<k;)x.queue[T].callFulfilled(M)}return x},o.reject=function(x,M){x.state=c,x.outcome=M;for(var S=-1,A=x.queue.length;++S<A;)x.queue[S].callRejected(M);return x},f.resolve=function(x){return x instanceof this?x:o.resolve(new this(s),x)},f.reject=function(x){var M=new this(s);return o.reject(M,x)},f.all=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=x.length,A=!1;if(!S)return this.resolve([]);for(var T=new Array(S),k=0,N=-1,I=new this(s);++N<S;)C(x[N],N);return I;function C(D,F){M.resolve(D).then(function(O){T[F]=O,++k!==S||A||(A=!0,o.resolve(I,T))},function(O){A||(A=!0,o.reject(I,O))})}},f.race=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=x.length,A=!1;if(!S)return this.resolve([]);for(var T=-1,k=new this(s);++T<S;)N=x[T],M.resolve(N).then(function(I){A||(A=!0,o.resolve(k,I))},function(I){A||(A=!0,o.reject(k,I))});var N;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"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,m=0,b=8;function y(x){if(!(this instanceof y))return new y(x);this.options=s.assign({level:g,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},x||{});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"?o.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 v(x,M){var S=new y(M);if(S.push(x,!0),S.err)throw S.msg||c[S.err];return S.result}y.prototype.push=function(x,M){var S,A,T=this.strm,k=this.options.chunkSize;if(this.ended)return!1;A=M===~~M?M:M===!0?4:0,typeof x=="string"?T.input=o.string2buf(x):d.call(x)==="[object ArrayBuffer]"?T.input=new Uint8Array(x):T.input=x,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(k),T.next_out=0,T.avail_out=k),(S=a.deflate(T,A))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(T.output,T.next_out))):this.onData(s.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.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),!(T.avail_out=0))},y.prototype.onData=function(x){this.chunks.push(x)},y.prototype.onEnd=function(x){x===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},i.Deflate=y,i.deflate=v,i.deflateRaw=function(x,M){return(M=M||{}).raw=!0,v(x,M)},i.gzip=function(x,M){return(M=M||{}).gzip=!0,v(x,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"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(y);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},y||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||y&&y.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var x=a.inflateInit2(this.strm,v.windowBits);if(x!==c.Z_OK)throw new Error(u[x]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function b(y,v){var x=new m(v);if(x.push(y,!0),x.err)throw x.msg||u[x.err];return x.result}m.prototype.push=function(y,v){var x,M,S,A,T,k,N=this.strm,I=this.options.chunkSize,C=this.options.dictionary,D=!1;if(this.ended)return!1;M=v===~~v?v:v===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?N.input=o.binstring2buf(y):g.call(y)==="[object ArrayBuffer]"?N.input=new Uint8Array(y):N.input=y,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new s.Buf8(I),N.next_out=0,N.avail_out=I),(x=a.inflate(N,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&C&&(k=typeof C=="string"?o.string2buf(C):g.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,x=a.inflateSetDictionary(this.strm,k)),x===c.Z_BUF_ERROR&&D===!0&&(x=c.Z_OK,D=!1),x!==c.Z_STREAM_END&&x!==c.Z_OK)return this.onEnd(x),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&x!==c.Z_STREAM_END&&(N.avail_in!==0||M!==c.Z_FINISH&&M!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=o.utf8border(N.output,N.next_out),A=N.next_out-S,T=o.buf2string(N.output,S),N.next_out=A,N.avail_out=I-A,A&&s.arraySet(N.output,N.output,S,A,0),this.onData(T)):this.onData(s.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(D=!0)}while((0<N.avail_in||N.avail_out===0)&&x!==c.Z_STREAM_END);return x===c.Z_STREAM_END&&(M=c.Z_FINISH),M===c.Z_FINISH?(x=a.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===c.Z_OK):M!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(N.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=m,i.inflate=b,i.inflateRaw=function(y,v){return(v=v||{}).raw=!0,b(y,v)},i.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var s={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var m=0;m<f;m++)c[g+m]=u[d+m]},flattenChunks:function(c){var u,d,f,g,m,b;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(b=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)m=c[u],b.set(m,g),g+=m.length;return b}},o={arraySet:function(c,u,d,f,g){for(var m=0;m<f;m++)c[g+m]=u[d+m]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&o||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var m="",b=0;b<g;b++)m+=String.fromCharCode(f[b]);return m}c[254]=c[254]=1,i.string2buf=function(f){var g,m,b,y,v,x=f.length,M=0;for(y=0;y<x;y++)(64512&(m=f.charCodeAt(y)))==55296&&y+1<x&&(64512&(b=f.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),M+=m<128?1:m<2048?2:m<65536?3:4;for(g=new a.Buf8(M),y=v=0;v<M;y++)(64512&(m=f.charCodeAt(y)))==55296&&y+1<x&&(64512&(b=f.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),m<128?g[v++]=m:(m<2048?g[v++]=192|m>>>6:(m<65536?g[v++]=224|m>>>12:(g[v++]=240|m>>>18,g[v++]=128|m>>>12&63),g[v++]=128|m>>>6&63),g[v++]=128|63&m);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new a.Buf8(f.length),m=0,b=g.length;m<b;m++)g[m]=f.charCodeAt(m);return g},i.buf2string=function(f,g){var m,b,y,v,x=g||f.length,M=new Array(2*x);for(m=b=0;m<x;)if((y=f[m++])<128)M[b++]=y;else if(4<(v=c[y]))M[b++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<x;)y=y<<6|63&f[m++],v--;1<v?M[b++]=65533:y<65536?M[b++]=y:(y-=65536,M[b++]=55296|y>>10&1023,M[b++]=56320|1023&y)}return d(M,b)},i.utf8border=function(f,g){var m;for((g=g||f.length)>f.length&&(g=f.length),m=g-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?g:m+c[f[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,s,o,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;d=d+(u=u+s[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 s,o=[],c=0;c<256;c++){s=c;for(var u=0;u<8;u++)s=1&s?3988292384^s>>>1:s>>>1;o[c]=s}return o})();r.exports=function(s,o,c,u){var d=a,f=u+c;s^=-1;for(var g=u;g<f;g++)s=s>>>8^d[255&(s^o[g])];return-1^s}},{}],46:[function(n,r,i){var a,s=n("../utils/common"),o=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,m=0,b=-2,y=-1,v=4,x=2,M=8,S=9,A=286,T=30,k=19,N=2*A+1,I=15,C=3,D=258,F=D+C+1,O=42,q=113,R=1,W=2,K=3,G=4;function ee(H,B){return H.msg=d[B],B}function Z(H){return(H<<1)-(4<H?9:0)}function Q(H){for(var B=H.length;0<=--B;)H[B]=0}function U(H){var B=H.state,re=B.pending;re>H.avail_out&&(re=H.avail_out),re!==0&&(s.arraySet(H.output,B.pending_buf,B.pending_out,re,H.next_out),H.next_out+=re,B.pending_out+=re,H.total_out+=re,H.avail_out-=re,B.pending-=re,B.pending===0&&(B.pending_out=0))}function $(H,B){o._tr_flush_block(H,0<=H.block_start?H.block_start:-1,H.strstart-H.block_start,B),H.block_start=H.strstart,U(H.strm)}function X(H,B){H.pending_buf[H.pending++]=B}function te(H,B){H.pending_buf[H.pending++]=B>>>8&255,H.pending_buf[H.pending++]=255&B}function fe(H,B){var re,V,J=H.max_chain_length,se=H.strstart,Ae=H.prev_length,Pe=H.nice_match,Se=H.strstart>H.w_size-F?H.strstart-(H.w_size-F):0,z=H.window,L=H.w_mask,ne=H.prev,ve=H.strstart+D,we=z[se+Ae-1],ye=z[se+Ae];H.prev_length>=H.good_match&&(J>>=2),Pe>H.lookahead&&(Pe=H.lookahead);do if(z[(re=B)+Ae]===ye&&z[re+Ae-1]===we&&z[re]===z[se]&&z[++re]===z[se+1]){se+=2,re++;do;while(z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&z[++se]===z[++re]&&se<ve);if(V=D-(ve-se),se=ve-D,Ae<V){if(H.match_start=B,Pe<=(Ae=V))break;we=z[se+Ae-1],ye=z[se+Ae]}}while((B=ne[B&L])>Se&&--J!=0);return Ae<=H.lookahead?Ae:H.lookahead}function pe(H){var B,re,V,J,se,Ae,Pe,Se,z,L,ne=H.w_size;do{if(J=H.window_size-H.lookahead-H.strstart,H.strstart>=ne+(ne-F)){for(s.arraySet(H.window,H.window,ne,ne,0),H.match_start-=ne,H.strstart-=ne,H.block_start-=ne,B=re=H.hash_size;V=H.head[--B],H.head[B]=ne<=V?V-ne:0,--re;);for(B=re=ne;V=H.prev[--B],H.prev[B]=ne<=V?V-ne:0,--re;);J+=ne}if(H.strm.avail_in===0)break;if(Ae=H.strm,Pe=H.window,Se=H.strstart+H.lookahead,z=J,L=void 0,L=Ae.avail_in,z<L&&(L=z),re=L===0?0:(Ae.avail_in-=L,s.arraySet(Pe,Ae.input,Ae.next_in,L,Se),Ae.state.wrap===1?Ae.adler=c(Ae.adler,Pe,L,Se):Ae.state.wrap===2&&(Ae.adler=u(Ae.adler,Pe,L,Se)),Ae.next_in+=L,Ae.total_in+=L,L),H.lookahead+=re,H.lookahead+H.insert>=C)for(se=H.strstart-H.insert,H.ins_h=H.window[se],H.ins_h=(H.ins_h<<H.hash_shift^H.window[se+1])&H.hash_mask;H.insert&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[se+C-1])&H.hash_mask,H.prev[se&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=se,se++,H.insert--,!(H.lookahead+H.insert<C)););}while(H.lookahead<F&&H.strm.avail_in!==0)}function be(H,B){for(var re,V;;){if(H.lookahead<F){if(pe(H),H.lookahead<F&&B===f)return R;if(H.lookahead===0)break}if(re=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),re!==0&&H.strstart-re<=H.w_size-F&&(H.match_length=fe(H,re)),H.match_length>=C)if(V=o._tr_tally(H,H.strstart-H.match_start,H.match_length-C),H.lookahead-=H.match_length,H.match_length<=H.max_lazy_match&&H.lookahead>=C){for(H.match_length--;H.strstart++,H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart,--H.match_length!=0;);H.strstart++}else H.strstart+=H.match_length,H.match_length=0,H.ins_h=H.window[H.strstart],H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+1])&H.hash_mask;else V=o._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++;if(V&&($(H,!1),H.strm.avail_out===0))return R}return H.insert=H.strstart<C-1?H.strstart:C-1,B===g?($(H,!0),H.strm.avail_out===0?K:G):H.last_lit&&($(H,!1),H.strm.avail_out===0)?R:W}function Ne(H,B){for(var re,V,J;;){if(H.lookahead<F){if(pe(H),H.lookahead<F&&B===f)return R;if(H.lookahead===0)break}if(re=0,H.lookahead>=C&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),H.prev_length=H.match_length,H.prev_match=H.match_start,H.match_length=C-1,re!==0&&H.prev_length<H.max_lazy_match&&H.strstart-re<=H.w_size-F&&(H.match_length=fe(H,re),H.match_length<=5&&(H.strategy===1||H.match_length===C&&4096<H.strstart-H.match_start)&&(H.match_length=C-1)),H.prev_length>=C&&H.match_length<=H.prev_length){for(J=H.strstart+H.lookahead-C,V=o._tr_tally(H,H.strstart-1-H.prev_match,H.prev_length-C),H.lookahead-=H.prev_length-1,H.prev_length-=2;++H.strstart<=J&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+C-1])&H.hash_mask,re=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),--H.prev_length!=0;);if(H.match_available=0,H.match_length=C-1,H.strstart++,V&&($(H,!1),H.strm.avail_out===0))return R}else if(H.match_available){if((V=o._tr_tally(H,0,H.window[H.strstart-1]))&&$(H,!1),H.strstart++,H.lookahead--,H.strm.avail_out===0)return R}else H.match_available=1,H.strstart++,H.lookahead--}return H.match_available&&(V=o._tr_tally(H,0,H.window[H.strstart-1]),H.match_available=0),H.insert=H.strstart<C-1?H.strstart:C-1,B===g?($(H,!0),H.strm.avail_out===0?K:G):H.last_lit&&($(H,!1),H.strm.avail_out===0)?R:W}function ie(H,B,re,V,J){this.good_length=H,this.max_lazy=B,this.nice_length=re,this.max_chain=V,this.func=J}function xe(){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 s.Buf16(2*N),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*k+1)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(I+1),this.heap=new s.Buf16(2*A+1),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*A+1),Q(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Re(H){var B;return H&&H.state?(H.total_in=H.total_out=0,H.data_type=x,(B=H.state).pending=0,B.pending_out=0,B.wrap<0&&(B.wrap=-B.wrap),B.status=B.wrap?O:q,H.adler=B.wrap===2?0:1,B.last_flush=f,o._tr_init(B),m):ee(H,b)}function he(H){var B=Re(H);return B===m&&(function(re){re.window_size=2*re.w_size,Q(re.head),re.max_lazy_match=a[re.level].max_lazy,re.good_match=a[re.level].good_length,re.nice_match=a[re.level].nice_length,re.max_chain_length=a[re.level].max_chain,re.strstart=0,re.block_start=0,re.lookahead=0,re.insert=0,re.match_length=re.prev_length=C-1,re.match_available=0,re.ins_h=0})(H.state),B}function ht(H,B,re,V,J,se){if(!H)return b;var Ae=1;if(B===y&&(B=6),V<0?(Ae=0,V=-V):15<V&&(Ae=2,V-=16),J<1||S<J||re!==M||V<8||15<V||B<0||9<B||se<0||v<se)return ee(H,b);V===8&&(V=9);var Pe=new xe;return(H.state=Pe).strm=H,Pe.wrap=Ae,Pe.gzhead=null,Pe.w_bits=V,Pe.w_size=1<<Pe.w_bits,Pe.w_mask=Pe.w_size-1,Pe.hash_bits=J+7,Pe.hash_size=1<<Pe.hash_bits,Pe.hash_mask=Pe.hash_size-1,Pe.hash_shift=~~((Pe.hash_bits+C-1)/C),Pe.window=new s.Buf8(2*Pe.w_size),Pe.head=new s.Buf16(Pe.hash_size),Pe.prev=new s.Buf16(Pe.w_size),Pe.lit_bufsize=1<<J+6,Pe.pending_buf_size=4*Pe.lit_bufsize,Pe.pending_buf=new s.Buf8(Pe.pending_buf_size),Pe.d_buf=1*Pe.lit_bufsize,Pe.l_buf=3*Pe.lit_bufsize,Pe.level=B,Pe.strategy=se,Pe.method=re,he(H)}a=[new ie(0,0,0,0,function(H,B){var re=65535;for(re>H.pending_buf_size-5&&(re=H.pending_buf_size-5);;){if(H.lookahead<=1){if(pe(H),H.lookahead===0&&B===f)return R;if(H.lookahead===0)break}H.strstart+=H.lookahead,H.lookahead=0;var V=H.block_start+re;if((H.strstart===0||H.strstart>=V)&&(H.lookahead=H.strstart-V,H.strstart=V,$(H,!1),H.strm.avail_out===0)||H.strstart-H.block_start>=H.w_size-F&&($(H,!1),H.strm.avail_out===0))return R}return H.insert=0,B===g?($(H,!0),H.strm.avail_out===0?K:G):(H.strstart>H.block_start&&($(H,!1),H.strm.avail_out),R)}),new ie(4,4,8,4,be),new ie(4,5,16,8,be),new ie(4,6,32,32,be),new ie(4,4,16,16,Ne),new ie(8,16,32,32,Ne),new ie(8,16,128,128,Ne),new ie(8,32,128,256,Ne),new ie(32,128,258,1024,Ne),new ie(32,258,258,4096,Ne)],i.deflateInit=function(H,B){return ht(H,B,M,15,8,0)},i.deflateInit2=ht,i.deflateReset=he,i.deflateResetKeep=Re,i.deflateSetHeader=function(H,B){return H&&H.state?H.state.wrap!==2?b:(H.state.gzhead=B,m):b},i.deflate=function(H,B){var re,V,J,se;if(!H||!H.state||5<B||B<0)return H?ee(H,b):b;if(V=H.state,!H.output||!H.input&&H.avail_in!==0||V.status===666&&B!==g)return ee(H,H.avail_out===0?-5:b);if(V.strm=H,re=V.last_flush,V.last_flush=B,V.status===O)if(V.wrap===2)H.adler=0,X(V,31),X(V,139),X(V,8),V.gzhead?(X(V,(V.gzhead.text?1:0)+(V.gzhead.hcrc?2:0)+(V.gzhead.extra?4:0)+(V.gzhead.name?8:0)+(V.gzhead.comment?16:0)),X(V,255&V.gzhead.time),X(V,V.gzhead.time>>8&255),X(V,V.gzhead.time>>16&255),X(V,V.gzhead.time>>24&255),X(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),X(V,255&V.gzhead.os),V.gzhead.extra&&V.gzhead.extra.length&&(X(V,255&V.gzhead.extra.length),X(V,V.gzhead.extra.length>>8&255)),V.gzhead.hcrc&&(H.adler=u(H.adler,V.pending_buf,V.pending,0)),V.gzindex=0,V.status=69):(X(V,0),X(V,0),X(V,0),X(V,0),X(V,0),X(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),X(V,3),V.status=q);else{var Ae=M+(V.w_bits-8<<4)<<8;Ae|=(2<=V.strategy||V.level<2?0:V.level<6?1:V.level===6?2:3)<<6,V.strstart!==0&&(Ae|=32),Ae+=31-Ae%31,V.status=q,te(V,Ae),V.strstart!==0&&(te(V,H.adler>>>16),te(V,65535&H.adler)),H.adler=1}if(V.status===69)if(V.gzhead.extra){for(J=V.pending;V.gzindex<(65535&V.gzhead.extra.length)&&(V.pending!==V.pending_buf_size||(V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),U(H),J=V.pending,V.pending!==V.pending_buf_size));)X(V,255&V.gzhead.extra[V.gzindex]),V.gzindex++;V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),V.gzindex===V.gzhead.extra.length&&(V.gzindex=0,V.status=73)}else V.status=73;if(V.status===73)if(V.gzhead.name){J=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),U(H),J=V.pending,V.pending===V.pending_buf_size)){se=1;break}se=V.gzindex<V.gzhead.name.length?255&V.gzhead.name.charCodeAt(V.gzindex++):0,X(V,se)}while(se!==0);V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),se===0&&(V.gzindex=0,V.status=91)}else V.status=91;if(V.status===91)if(V.gzhead.comment){J=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),U(H),J=V.pending,V.pending===V.pending_buf_size)){se=1;break}se=V.gzindex<V.gzhead.comment.length?255&V.gzhead.comment.charCodeAt(V.gzindex++):0,X(V,se)}while(se!==0);V.gzhead.hcrc&&V.pending>J&&(H.adler=u(H.adler,V.pending_buf,V.pending-J,J)),se===0&&(V.status=103)}else V.status=103;if(V.status===103&&(V.gzhead.hcrc?(V.pending+2>V.pending_buf_size&&U(H),V.pending+2<=V.pending_buf_size&&(X(V,255&H.adler),X(V,H.adler>>8&255),H.adler=0,V.status=q)):V.status=q),V.pending!==0){if(U(H),H.avail_out===0)return V.last_flush=-1,m}else if(H.avail_in===0&&Z(B)<=Z(re)&&B!==g)return ee(H,-5);if(V.status===666&&H.avail_in!==0)return ee(H,-5);if(H.avail_in!==0||V.lookahead!==0||B!==f&&V.status!==666){var Pe=V.strategy===2?(function(Se,z){for(var L;;){if(Se.lookahead===0&&(pe(Se),Se.lookahead===0)){if(z===f)return R;break}if(Se.match_length=0,L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++,L&&($(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,z===g?($(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&($(Se,!1),Se.strm.avail_out===0)?R:W})(V,B):V.strategy===3?(function(Se,z){for(var L,ne,ve,we,ye=Se.window;;){if(Se.lookahead<=D){if(pe(Se),Se.lookahead<=D&&z===f)return R;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=C&&0<Se.strstart&&(ne=ye[ve=Se.strstart-1])===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]){we=Se.strstart+D;do;while(ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ve<we);Se.match_length=D-(we-ve),Se.match_length>Se.lookahead&&(Se.match_length=Se.lookahead)}if(Se.match_length>=C?(L=o._tr_tally(Se,1,Se.match_length-C),Se.lookahead-=Se.match_length,Se.strstart+=Se.match_length,Se.match_length=0):(L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++),L&&($(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,z===g?($(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&($(Se,!1),Se.strm.avail_out===0)?R:W})(V,B):a[V.level].func(V,B);if(Pe!==K&&Pe!==G||(V.status=666),Pe===R||Pe===K)return H.avail_out===0&&(V.last_flush=-1),m;if(Pe===W&&(B===1?o._tr_align(V):B!==5&&(o._tr_stored_block(V,0,0,!1),B===3&&(Q(V.head),V.lookahead===0&&(V.strstart=0,V.block_start=0,V.insert=0))),U(H),H.avail_out===0))return V.last_flush=-1,m}return B!==g?m:V.wrap<=0?1:(V.wrap===2?(X(V,255&H.adler),X(V,H.adler>>8&255),X(V,H.adler>>16&255),X(V,H.adler>>24&255),X(V,255&H.total_in),X(V,H.total_in>>8&255),X(V,H.total_in>>16&255),X(V,H.total_in>>24&255)):(te(V,H.adler>>>16),te(V,65535&H.adler)),U(H),0<V.wrap&&(V.wrap=-V.wrap),V.pending!==0?m:1)},i.deflateEnd=function(H){var B;return H&&H.state?(B=H.state.status)!==O&&B!==69&&B!==73&&B!==91&&B!==103&&B!==q&&B!==666?ee(H,b):(H.state=null,B===q?ee(H,-3):m):b},i.deflateSetDictionary=function(H,B){var re,V,J,se,Ae,Pe,Se,z,L=B.length;if(!H||!H.state||(se=(re=H.state).wrap)===2||se===1&&re.status!==O||re.lookahead)return b;for(se===1&&(H.adler=c(H.adler,B,L,0)),re.wrap=0,L>=re.w_size&&(se===0&&(Q(re.head),re.strstart=0,re.block_start=0,re.insert=0),z=new s.Buf8(re.w_size),s.arraySet(z,B,L-re.w_size,re.w_size,0),B=z,L=re.w_size),Ae=H.avail_in,Pe=H.next_in,Se=H.input,H.avail_in=L,H.next_in=0,H.input=B,pe(re);re.lookahead>=C;){for(V=re.strstart,J=re.lookahead-(C-1);re.ins_h=(re.ins_h<<re.hash_shift^re.window[V+C-1])&re.hash_mask,re.prev[V&re.w_mask]=re.head[re.ins_h],re.head[re.ins_h]=V,V++,--J;);re.strstart=V,re.lookahead=C-1,pe(re)}return re.strstart+=re.lookahead,re.block_start=re.strstart,re.insert=re.lookahead,re.lookahead=0,re.match_length=re.prev_length=C-1,re.match_available=0,H.next_in=Pe,H.input=Se,H.avail_in=Ae,re.wrap=se,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,s){var o,c,u,d,f,g,m,b,y,v,x,M,S,A,T,k,N,I,C,D,F,O,q,R,W;o=a.state,c=a.next_in,R=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(s-a.avail_out),g=d+(a.avail_out-257),m=o.dmax,b=o.wsize,y=o.whave,v=o.wnext,x=o.window,M=o.hold,S=o.bits,A=o.lencode,T=o.distcode,k=(1<<o.lenbits)-1,N=(1<<o.distbits)-1;e:do{S<15&&(M+=R[c++]<<S,S+=8,M+=R[c++]<<S,S+=8),I=A[M&k];t:for(;;){if(M>>>=C=I>>>24,S-=C,(C=I>>>16&255)===0)W[d++]=65535&I;else{if(!(16&C)){if((64&C)==0){I=A[(65535&I)+(M&(1<<C)-1)];continue t}if(32&C){o.mode=12;break e}a.msg="invalid literal/length code",o.mode=30;break e}D=65535&I,(C&=15)&&(S<C&&(M+=R[c++]<<S,S+=8),D+=M&(1<<C)-1,M>>>=C,S-=C),S<15&&(M+=R[c++]<<S,S+=8,M+=R[c++]<<S,S+=8),I=T[M&N];n:for(;;){if(M>>>=C=I>>>24,S-=C,!(16&(C=I>>>16&255))){if((64&C)==0){I=T[(65535&I)+(M&(1<<C)-1)];continue n}a.msg="invalid distance code",o.mode=30;break e}if(F=65535&I,S<(C&=15)&&(M+=R[c++]<<S,(S+=8)<C&&(M+=R[c++]<<S,S+=8)),m<(F+=M&(1<<C)-1)){a.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=C,S-=C,(C=d-f)<F){if(y<(C=F-C)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break e}if(q=x,(O=0)===v){if(O+=b-C,C<D){for(D-=C;W[d++]=x[O++],--C;);O=d-F,q=W}}else if(v<C){if(O+=b+v-C,(C-=v)<D){for(D-=C;W[d++]=x[O++],--C;);if(O=0,v<D){for(D-=C=v;W[d++]=x[O++],--C;);O=d-F,q=W}}}else if(O+=v-C,C<D){for(D-=C;W[d++]=x[O++],--C;);O=d-F,q=W}for(;2<D;)W[d++]=q[O++],W[d++]=q[O++],W[d++]=q[O++],D-=3;D&&(W[d++]=q[O++],1<D&&(W[d++]=q[O++]))}else{for(O=d-F;W[d++]=W[O++],W[d++]=W[O++],W[d++]=W[O++],2<(D-=3););D&&(W[d++]=W[O++],1<D&&(W[d++]=W[O++]))}break}}break}}while(c<u&&d<g);c-=D=S>>3,M&=(1<<(S-=D<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<g?g-d+257:257-(d-g),o.hold=M,o.bits=S}},{}],49:[function(n,r,i){var a=n("../utils/common"),s=n("./adler32"),o=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,m=-2,b=1,y=852,v=592;function x(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<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(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=b,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(y),q.distcode=q.distdyn=new a.Buf32(v),q.sane=1,q.back=-1,g):m}function A(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,S(O)):m}function T(O,q){var R,W;return O&&O.state?(W=O.state,q<0?(R=0,q=-q):(R=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?m:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=R,W.wbits=q,A(O))):m}function k(O,q){var R,W;return O?(W=new M,(O.state=W).window=null,(R=T(O,q))!==g&&(O.state=null),R):m}var N,I,C=!0;function D(O){if(C){var q;for(N=new a.Buf32(512),I=new a.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,N,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,I,0,O.work,{bits:5}),C=!1}O.lencode=N,O.lenbits=9,O.distcode=I,O.distbits=5}function F(O,q,R,W){var K,G=O.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),W>=G.wsize?(a.arraySet(G.window,q,R-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(K=G.wsize-G.wnext)&&(K=W),a.arraySet(G.window,q,R-W,K,G.wnext),(W-=K)?(a.arraySet(G.window,q,R-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=S,i.inflateInit=function(O){return k(O,15)},i.inflateInit2=k,i.inflate=function(O,q){var R,W,K,G,ee,Z,Q,U,$,X,te,fe,pe,be,Ne,ie,xe,Re,he,ht,H,B,re,V,J=0,se=new a.Buf8(4),Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return m;(R=O.state).mode===12&&(R.mode=13),ee=O.next_out,K=O.output,Q=O.avail_out,G=O.next_in,W=O.input,Z=O.avail_in,U=R.hold,$=R.bits,X=Z,te=Q,B=g;e:for(;;)switch(R.mode){case b:if(R.wrap===0){R.mode=13;break}for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(2&R.wrap&&U===35615){se[R.check=0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0),$=U=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&U)<<8)+(U>>8))%31){O.msg="incorrect header check",R.mode=30;break}if((15&U)!=8){O.msg="unknown compression method",R.mode=30;break}if($-=4,H=8+(15&(U>>>=4)),R.wbits===0)R.wbits=H;else if(H>R.wbits){O.msg="invalid window size",R.mode=30;break}R.dmax=1<<H,O.adler=R.check=1,R.mode=512&U?10:12,$=U=0;break;case 2:for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(R.flags=U,(255&R.flags)!=8){O.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){O.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=U>>8&1),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),$=U=0,R.mode=3;case 3:for(;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.head&&(R.head.time=U),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,se[2]=U>>>16&255,se[3]=U>>>24&255,R.check=o(R.check,se,4,0)),$=U=0,R.mode=4;case 4:for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.head&&(R.head.xflags=255&U,R.head.os=U>>8),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),$=U=0,R.mode=5;case 5:if(1024&R.flags){for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.length=U,R.head&&(R.head.extra_len=U),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),$=U=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Z<(fe=R.length)&&(fe=Z),fe&&(R.head&&(H=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),a.arraySet(R.head.extra,W,G,fe,H)),512&R.flags&&(R.check=o(R.check,W,fe,G)),Z-=fe,G+=fe,R.length-=fe),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Z===0)break e;for(fe=0;H=W[G+fe++],R.head&&H&&R.length<65536&&(R.head.name+=String.fromCharCode(H)),H&&fe<Z;);if(512&R.flags&&(R.check=o(R.check,W,fe,G)),Z-=fe,G+=fe,H)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Z===0)break e;for(fe=0;H=W[G+fe++],R.head&&H&&R.length<65536&&(R.head.comment+=String.fromCharCode(H)),H&&fe<Z;);if(512&R.flags&&(R.check=o(R.check,W,fe,G)),Z-=fe,G+=fe,H)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;$<16;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(U!==(65535&R.check)){O.msg="header crc mismatch",R.mode=30;break}$=U=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),O.adler=R.check=0,R.mode=12;break;case 10:for(;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}O.adler=R.check=x(U),$=U=0,R.mode=11;case 11:if(R.havedict===0)return O.next_out=ee,O.avail_out=Q,O.next_in=G,O.avail_in=Z,R.hold=U,R.bits=$,2;O.adler=R.check=1,R.mode=12;case 12:if(q===5||q===6)break e;case 13:if(R.last){U>>>=7&$,$-=7&$,R.mode=27;break}for(;$<3;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}switch(R.last=1&U,$-=1,3&(U>>>=1)){case 0:R.mode=14;break;case 1:if(D(R),R.mode=20,q!==6)break;U>>>=2,$-=2;break e;case 2:R.mode=17;break;case 3:O.msg="invalid block type",R.mode=30}U>>>=2,$-=2;break;case 14:for(U>>>=7&$,$-=7&$;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if((65535&U)!=(U>>>16^65535)){O.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&U,$=U=0,R.mode=15,q===6)break e;case 15:R.mode=16;case 16:if(fe=R.length){if(Z<fe&&(fe=Z),Q<fe&&(fe=Q),fe===0)break e;a.arraySet(K,W,G,fe,ee),Z-=fe,G+=fe,Q-=fe,ee+=fe,R.length-=fe;break}R.mode=12;break;case 17:for(;$<14;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(R.nlen=257+(31&U),U>>>=5,$-=5,R.ndist=1+(31&U),U>>>=5,$-=5,R.ncode=4+(15&U),U>>>=4,$-=4,286<R.nlen||30<R.ndist){O.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;$<3;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.lens[Ae[R.have++]]=7&U,U>>>=3,$-=3}for(;R.have<19;)R.lens[Ae[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,re={bits:R.lenbits},B=u(0,R.lens,0,19,R.lencode,0,R.work,re),R.lenbits=re.bits,B){O.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;ie=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,xe=65535&J,!((Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(xe<16)U>>>=Ne,$-=Ne,R.lens[R.have++]=xe;else{if(xe===16){for(V=Ne+2;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(U>>>=Ne,$-=Ne,R.have===0){O.msg="invalid bit length repeat",R.mode=30;break}H=R.lens[R.have-1],fe=3+(3&U),U>>>=2,$-=2}else if(xe===17){for(V=Ne+3;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}$-=Ne,H=0,fe=3+(7&(U>>>=Ne)),U>>>=3,$-=3}else{for(V=Ne+7;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}$-=Ne,H=0,fe=11+(127&(U>>>=Ne)),U>>>=7,$-=7}if(R.have+fe>R.nlen+R.ndist){O.msg="invalid bit length repeat",R.mode=30;break}for(;fe--;)R.lens[R.have++]=H}}if(R.mode===30)break;if(R.lens[256]===0){O.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,re={bits:R.lenbits},B=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,re),R.lenbits=re.bits,B){O.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,re={bits:R.distbits},B=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,re),R.distbits=re.bits,B){O.msg="invalid distances set",R.mode=30;break}if(R.mode=20,q===6)break e;case 20:R.mode=21;case 21:if(6<=Z&&258<=Q){O.next_out=ee,O.avail_out=Q,O.next_in=G,O.avail_in=Z,R.hold=U,R.bits=$,c(O,te),ee=O.next_out,K=O.output,Q=O.avail_out,G=O.next_in,W=O.input,Z=O.avail_in,U=R.hold,$=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;ie=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,xe=65535&J,!((Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(ie&&(240&ie)==0){for(Re=Ne,he=ie,ht=xe;ie=(J=R.lencode[ht+((U&(1<<Re+he)-1)>>Re)])>>>16&255,xe=65535&J,!(Re+(Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}U>>>=Re,$-=Re,R.back+=Re}if(U>>>=Ne,$-=Ne,R.back+=Ne,R.length=xe,ie===0){R.mode=26;break}if(32&ie){R.back=-1,R.mode=12;break}if(64&ie){O.msg="invalid literal/length code",R.mode=30;break}R.extra=15&ie,R.mode=22;case 22:if(R.extra){for(V=R.extra;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.length+=U&(1<<R.extra)-1,U>>>=R.extra,$-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;ie=(J=R.distcode[U&(1<<R.distbits)-1])>>>16&255,xe=65535&J,!((Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if((240&ie)==0){for(Re=Ne,he=ie,ht=xe;ie=(J=R.distcode[ht+((U&(1<<Re+he)-1)>>Re)])>>>16&255,xe=65535&J,!(Re+(Ne=J>>>24)<=$);){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}U>>>=Re,$-=Re,R.back+=Re}if(U>>>=Ne,$-=Ne,R.back+=Ne,64&ie){O.msg="invalid distance code",R.mode=30;break}R.offset=xe,R.extra=15&ie,R.mode=24;case 24:if(R.extra){for(V=R.extra;$<V;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}R.offset+=U&(1<<R.extra)-1,U>>>=R.extra,$-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){O.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Q===0)break e;if(fe=te-Q,R.offset>fe){if((fe=R.offset-fe)>R.whave&&R.sane){O.msg="invalid distance too far back",R.mode=30;break}pe=fe>R.wnext?(fe-=R.wnext,R.wsize-fe):R.wnext-fe,fe>R.length&&(fe=R.length),be=R.window}else be=K,pe=ee-R.offset,fe=R.length;for(Q<fe&&(fe=Q),Q-=fe,R.length-=fe;K[ee++]=be[pe++],--fe;);R.length===0&&(R.mode=21);break;case 26:if(Q===0)break e;K[ee++]=R.length,Q--,R.mode=21;break;case 27:if(R.wrap){for(;$<32;){if(Z===0)break e;Z--,U|=W[G++]<<$,$+=8}if(te-=Q,O.total_out+=te,R.total+=te,te&&(O.adler=R.check=R.flags?o(R.check,K,te,ee-te):s(R.check,K,te,ee-te)),te=Q,(R.flags?U:x(U))!==R.check){O.msg="incorrect data check",R.mode=30;break}$=U=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;$<32;){if(Z===0)break e;Z--,U+=W[G++]<<$,$+=8}if(U!==(4294967295&R.total)){O.msg="incorrect length check",R.mode=30;break}$=U=0}R.mode=29;case 29:B=1;break e;case 30:B=-3;break e;case 31:return-4;case 32:default:return m}return O.next_out=ee,O.avail_out=Q,O.next_in=G,O.avail_in=Z,R.hold=U,R.bits=$,(R.wsize||te!==O.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&F(O,O.output,O.next_out,te-O.avail_out)?(R.mode=31,-4):(X-=O.avail_in,te-=O.avail_out,O.total_in+=X,O.total_out+=te,R.total+=te,R.wrap&&te&&(O.adler=R.check=R.flags?o(R.check,K,te,O.next_out-te):s(R.check,K,te,O.next_out-te)),O.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(X==0&&te===0||q===4)&&B===g&&(B=-5),B)},i.inflateEnd=function(O){if(!O||!O.state)return m;var q=O.state;return q.window&&(q.window=null),O.state=null,g},i.inflateGetHeader=function(O,q){var R;return O&&O.state?(2&(R=O.state).wrap)==0?m:((R.head=q).done=!1,g):m},i.inflateSetDictionary=function(O,q){var R,W=q.length;return O&&O.state?(R=O.state).wrap!==0&&R.mode!==11?m:R.mode===11&&s(1,q,W,0)!==R.check?-3:F(O,q,W,W)?(R.mode=31,-4):(R.havedict=1,g):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),s=[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],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,m,b,y,v,x){var M,S,A,T,k,N,I,C,D,F=x.bits,O=0,q=0,R=0,W=0,K=0,G=0,ee=0,Z=0,Q=0,U=0,$=null,X=0,te=new a.Buf16(16),fe=new a.Buf16(16),pe=null,be=0;for(O=0;O<=15;O++)te[O]=0;for(q=0;q<m;q++)te[f[g+q]]++;for(K=F,W=15;1<=W&&te[W]===0;W--);if(W<K&&(K=W),W===0)return b[y++]=20971520,b[y++]=20971520,x.bits=1,0;for(R=1;R<W&&te[R]===0;R++);for(K<R&&(K=R),O=Z=1;O<=15;O++)if(Z<<=1,(Z-=te[O])<0)return-1;if(0<Z&&(d===0||W!==1))return-1;for(fe[1]=0,O=1;O<15;O++)fe[O+1]=fe[O]+te[O];for(q=0;q<m;q++)f[g+q]!==0&&(v[fe[f[g+q]]++]=q);if(N=d===0?($=pe=v,19):d===1?($=s,X-=257,pe=o,be-=257,256):($=c,pe=u,-1),O=R,k=y,ee=q=U=0,A=-1,T=(Q=1<<(G=K))-1,d===1&&852<Q||d===2&&592<Q)return 1;for(;;){for(I=O-ee,D=v[q]<N?(C=0,v[q]):v[q]>N?(C=pe[be+v[q]],$[X+v[q]]):(C=96,0),M=1<<O-ee,R=S=1<<G;b[k+(U>>ee)+(S-=M)]=I<<24|C<<16|D|0,S!==0;);for(M=1<<O-1;U&M;)M>>=1;if(M!==0?(U&=M-1,U+=M):U=0,q++,--te[O]==0){if(O===W)break;O=f[g+v[q]]}if(K<O&&(U&T)!==A){for(ee===0&&(ee=K),k+=R,Z=1<<(G=O-ee);G+ee<W&&!((Z-=te[G+ee])<=0);)G++,Z<<=1;if(Q+=1<<G,d===1&&852<Q||d===2&&592<Q)return 1;b[A=U&T]=K<<24|G<<16|k-y|0}}return U!==0&&(b[k+U]=O-ee<<24|64<<16|0),x.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),s=0,o=1;function c(J){for(var se=J.length;0<=--se;)J[se]=0}var u=0,d=29,f=256,g=f+1+d,m=30,b=19,y=2*g+1,v=15,x=16,M=7,S=256,A=16,T=17,k=18,N=[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],I=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(g+2));c(F);var O=new Array(2*m);c(O);var q=new Array(512);c(q);var R=new Array(256);c(R);var W=new Array(d);c(W);var K,G,ee,Z=new Array(m);function Q(J,se,Ae,Pe,Se){this.static_tree=J,this.extra_bits=se,this.extra_base=Ae,this.elems=Pe,this.max_length=Se,this.has_stree=J&&J.length}function U(J,se){this.dyn_tree=J,this.max_code=0,this.stat_desc=se}function $(J){return J<256?q[J]:q[256+(J>>>7)]}function X(J,se){J.pending_buf[J.pending++]=255&se,J.pending_buf[J.pending++]=se>>>8&255}function te(J,se,Ae){J.bi_valid>x-Ae?(J.bi_buf|=se<<J.bi_valid&65535,X(J,J.bi_buf),J.bi_buf=se>>x-J.bi_valid,J.bi_valid+=Ae-x):(J.bi_buf|=se<<J.bi_valid&65535,J.bi_valid+=Ae)}function fe(J,se,Ae){te(J,Ae[2*se],Ae[2*se+1])}function pe(J,se){for(var Ae=0;Ae|=1&J,J>>>=1,Ae<<=1,0<--se;);return Ae>>>1}function be(J,se,Ae){var Pe,Se,z=new Array(v+1),L=0;for(Pe=1;Pe<=v;Pe++)z[Pe]=L=L+Ae[Pe-1]<<1;for(Se=0;Se<=se;Se++){var ne=J[2*Se+1];ne!==0&&(J[2*Se]=pe(z[ne]++,ne))}}function Ne(J){var se;for(se=0;se<g;se++)J.dyn_ltree[2*se]=0;for(se=0;se<m;se++)J.dyn_dtree[2*se]=0;for(se=0;se<b;se++)J.bl_tree[2*se]=0;J.dyn_ltree[2*S]=1,J.opt_len=J.static_len=0,J.last_lit=J.matches=0}function ie(J){8<J.bi_valid?X(J,J.bi_buf):0<J.bi_valid&&(J.pending_buf[J.pending++]=J.bi_buf),J.bi_buf=0,J.bi_valid=0}function xe(J,se,Ae,Pe){var Se=2*se,z=2*Ae;return J[Se]<J[z]||J[Se]===J[z]&&Pe[se]<=Pe[Ae]}function Re(J,se,Ae){for(var Pe=J.heap[Ae],Se=Ae<<1;Se<=J.heap_len&&(Se<J.heap_len&&xe(se,J.heap[Se+1],J.heap[Se],J.depth)&&Se++,!xe(se,Pe,J.heap[Se],J.depth));)J.heap[Ae]=J.heap[Se],Ae=Se,Se<<=1;J.heap[Ae]=Pe}function he(J,se,Ae){var Pe,Se,z,L,ne=0;if(J.last_lit!==0)for(;Pe=J.pending_buf[J.d_buf+2*ne]<<8|J.pending_buf[J.d_buf+2*ne+1],Se=J.pending_buf[J.l_buf+ne],ne++,Pe===0?fe(J,Se,se):(fe(J,(z=R[Se])+f+1,se),(L=N[z])!==0&&te(J,Se-=W[z],L),fe(J,z=$(--Pe),Ae),(L=I[z])!==0&&te(J,Pe-=Z[z],L)),ne<J.last_lit;);fe(J,S,se)}function ht(J,se){var Ae,Pe,Se,z=se.dyn_tree,L=se.stat_desc.static_tree,ne=se.stat_desc.has_stree,ve=se.stat_desc.elems,we=-1;for(J.heap_len=0,J.heap_max=y,Ae=0;Ae<ve;Ae++)z[2*Ae]!==0?(J.heap[++J.heap_len]=we=Ae,J.depth[Ae]=0):z[2*Ae+1]=0;for(;J.heap_len<2;)z[2*(Se=J.heap[++J.heap_len]=we<2?++we:0)]=1,J.depth[Se]=0,J.opt_len--,ne&&(J.static_len-=L[2*Se+1]);for(se.max_code=we,Ae=J.heap_len>>1;1<=Ae;Ae--)Re(J,z,Ae);for(Se=ve;Ae=J.heap[1],J.heap[1]=J.heap[J.heap_len--],Re(J,z,1),Pe=J.heap[1],J.heap[--J.heap_max]=Ae,J.heap[--J.heap_max]=Pe,z[2*Se]=z[2*Ae]+z[2*Pe],J.depth[Se]=(J.depth[Ae]>=J.depth[Pe]?J.depth[Ae]:J.depth[Pe])+1,z[2*Ae+1]=z[2*Pe+1]=Se,J.heap[1]=Se++,Re(J,z,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],(function(ye,nt){var Be,ue,Ve,Fe,oe,et,He=nt.dyn_tree,Ke=nt.max_code,ct=nt.stat_desc.static_tree,de=nt.stat_desc.has_stree,Ye=nt.stat_desc.extra_bits,ge=nt.stat_desc.extra_base,Ue=nt.stat_desc.max_length,Ce=0;for(Fe=0;Fe<=v;Fe++)ye.bl_count[Fe]=0;for(He[2*ye.heap[ye.heap_max]+1]=0,Be=ye.heap_max+1;Be<y;Be++)Ue<(Fe=He[2*He[2*(ue=ye.heap[Be])+1]+1]+1)&&(Fe=Ue,Ce++),He[2*ue+1]=Fe,Ke<ue||(ye.bl_count[Fe]++,oe=0,ge<=ue&&(oe=Ye[ue-ge]),et=He[2*ue],ye.opt_len+=et*(Fe+oe),de&&(ye.static_len+=et*(ct[2*ue+1]+oe)));if(Ce!==0){do{for(Fe=Ue-1;ye.bl_count[Fe]===0;)Fe--;ye.bl_count[Fe]--,ye.bl_count[Fe+1]+=2,ye.bl_count[Ue]--,Ce-=2}while(0<Ce);for(Fe=Ue;Fe!==0;Fe--)for(ue=ye.bl_count[Fe];ue!==0;)Ke<(Ve=ye.heap[--Be])||(He[2*Ve+1]!==Fe&&(ye.opt_len+=(Fe-He[2*Ve+1])*He[2*Ve],He[2*Ve+1]=Fe),ue--)}})(J,se),be(z,we,J.bl_count)}function H(J,se,Ae){var Pe,Se,z=-1,L=se[1],ne=0,ve=7,we=4;for(L===0&&(ve=138,we=3),se[2*(Ae+1)+1]=65535,Pe=0;Pe<=Ae;Pe++)Se=L,L=se[2*(Pe+1)+1],++ne<ve&&Se===L||(ne<we?J.bl_tree[2*Se]+=ne:Se!==0?(Se!==z&&J.bl_tree[2*Se]++,J.bl_tree[2*A]++):ne<=10?J.bl_tree[2*T]++:J.bl_tree[2*k]++,z=Se,we=(ne=0)===L?(ve=138,3):Se===L?(ve=6,3):(ve=7,4))}function B(J,se,Ae){var Pe,Se,z=-1,L=se[1],ne=0,ve=7,we=4;for(L===0&&(ve=138,we=3),Pe=0;Pe<=Ae;Pe++)if(Se=L,L=se[2*(Pe+1)+1],!(++ne<ve&&Se===L)){if(ne<we)for(;fe(J,Se,J.bl_tree),--ne!=0;);else Se!==0?(Se!==z&&(fe(J,Se,J.bl_tree),ne--),fe(J,A,J.bl_tree),te(J,ne-3,2)):ne<=10?(fe(J,T,J.bl_tree),te(J,ne-3,3)):(fe(J,k,J.bl_tree),te(J,ne-11,7));z=Se,we=(ne=0)===L?(ve=138,3):Se===L?(ve=6,3):(ve=7,4)}}c(Z);var re=!1;function V(J,se,Ae,Pe){te(J,(u<<1)+(Pe?1:0),3),(function(Se,z,L,ne){ie(Se),X(Se,L),X(Se,~L),a.arraySet(Se.pending_buf,Se.window,z,L,Se.pending),Se.pending+=L})(J,se,Ae)}i._tr_init=function(J){re||((function(){var se,Ae,Pe,Se,z,L=new Array(v+1);for(Se=Pe=0;Se<d-1;Se++)for(W[Se]=Pe,se=0;se<1<<N[Se];se++)R[Pe++]=Se;for(R[Pe-1]=Se,Se=z=0;Se<16;Se++)for(Z[Se]=z,se=0;se<1<<I[Se];se++)q[z++]=Se;for(z>>=7;Se<m;Se++)for(Z[Se]=z<<7,se=0;se<1<<I[Se]-7;se++)q[256+z++]=Se;for(Ae=0;Ae<=v;Ae++)L[Ae]=0;for(se=0;se<=143;)F[2*se+1]=8,se++,L[8]++;for(;se<=255;)F[2*se+1]=9,se++,L[9]++;for(;se<=279;)F[2*se+1]=7,se++,L[7]++;for(;se<=287;)F[2*se+1]=8,se++,L[8]++;for(be(F,g+1,L),se=0;se<m;se++)O[2*se+1]=5,O[2*se]=pe(se,5);K=new Q(F,N,f+1,g,v),G=new Q(O,I,0,m,v),ee=new Q(new Array(0),C,0,b,M)})(),re=!0),J.l_desc=new U(J.dyn_ltree,K),J.d_desc=new U(J.dyn_dtree,G),J.bl_desc=new U(J.bl_tree,ee),J.bi_buf=0,J.bi_valid=0,Ne(J)},i._tr_stored_block=V,i._tr_flush_block=function(J,se,Ae,Pe){var Se,z,L=0;0<J.level?(J.strm.data_type===2&&(J.strm.data_type=(function(ne){var ve,we=4093624447;for(ve=0;ve<=31;ve++,we>>>=1)if(1&we&&ne.dyn_ltree[2*ve]!==0)return s;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return o;for(ve=32;ve<f;ve++)if(ne.dyn_ltree[2*ve]!==0)return o;return s})(J)),ht(J,J.l_desc),ht(J,J.d_desc),L=(function(ne){var ve;for(H(ne,ne.dyn_ltree,ne.l_desc.max_code),H(ne,ne.dyn_dtree,ne.d_desc.max_code),ht(ne,ne.bl_desc),ve=b-1;3<=ve&&ne.bl_tree[2*D[ve]+1]===0;ve--);return ne.opt_len+=3*(ve+1)+5+5+4,ve})(J),Se=J.opt_len+3+7>>>3,(z=J.static_len+3+7>>>3)<=Se&&(Se=z)):Se=z=Ae+5,Ae+4<=Se&&se!==-1?V(J,se,Ae,Pe):J.strategy===4||z===Se?(te(J,2+(Pe?1:0),3),he(J,F,O)):(te(J,4+(Pe?1:0),3),(function(ne,ve,we,ye){var nt;for(te(ne,ve-257,5),te(ne,we-1,5),te(ne,ye-4,4),nt=0;nt<ye;nt++)te(ne,ne.bl_tree[2*D[nt]+1],3);B(ne,ne.dyn_ltree,ve-1),B(ne,ne.dyn_dtree,we-1)})(J,J.l_desc.max_code+1,J.d_desc.max_code+1,L+1),he(J,J.dyn_ltree,J.dyn_dtree)),Ne(J),Pe&&ie(J)},i._tr_tally=function(J,se,Ae){return J.pending_buf[J.d_buf+2*J.last_lit]=se>>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&se,J.pending_buf[J.l_buf+J.last_lit]=255&Ae,J.last_lit++,se===0?J.dyn_ltree[2*Ae]++:(J.matches++,se--,J.dyn_ltree[2*(R[Ae]+f+1)]++,J.dyn_dtree[2*$(se)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){te(J,2,3),fe(J,S,F),(function(se){se.bi_valid===16?(X(se,se.bi_buf),se.bi_buf=0,se.bi_valid=0):8<=se.bi_valid&&(se.pending_buf[se.pending++]=255&se.bi_buf,se.bi_buf>>=8,se.bi_valid-=8)})(J)}},{"../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(s,o){if(!s.setImmediate){var c,u,d,f,g=1,m={},b=!1,y=s.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(s);v=v&&v.setTimeout?v:s,c={}.toString.call(s.process)==="[object process]"?function(A){process.nextTick(function(){M(A)})}:(function(){if(s.postMessage&&!s.importScripts){var A=!0,T=s.onmessage;return s.onmessage=function(){A=!1},s.postMessage("","*"),s.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",S,!1):s.attachEvent("onmessage",S),function(A){s.postMessage(f+A,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){M(A.data)},function(A){d.port2.postMessage(A)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(A){var T=y.createElement("script");T.onreadystatechange=function(){M(A),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(A){setTimeout(M,0,A)},v.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),k=0;k<T.length;k++)T[k]=arguments[k+1];var N={callback:A,args:T};return m[g]=N,c(g),g++},v.clearImmediate=x}function x(A){delete m[A]}function M(A){if(b)setTimeout(M,0,A);else{var T=m[A];if(T){b=!0;try{(function(k){var N=k.callback,I=k.args;switch(I.length){case 0:N();break;case 1:N(I[0]);break;case 2:N(I[0],I[1]);break;case 3:N(I[0],I[1],I[2]);break;default:N.apply(o,I)}})(T)}finally{x(A),b=!1}}}}function S(A){A.source===s&&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 hv<"u"?hv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(qC)),qC.exports}var sje=aje();const oje=fo(sje);function lje(t){const e=new ri;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 zH=lje;async function BH(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],a=[],s=[],o=i.getElementsByTagName("vertex");for(let u=0;u<o.length;u++){const d=o[u];a.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const c=i.getElementsByTagName("triangle");for(let u=0;u<c.length;u++){const d=c[u];s.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function cje(t){const e=await oje.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(d){const f=d.startsWith("/")?d.slice(1):d,g=e.files[f];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const s=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!s){const d=Object.keys(e.files).find(f=>f.endsWith(".model"));if(d){const f=await a(d);if(f){const g=await BH(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await a(s);if(!o)return{objects:n,buildItems:r};const c=o.getElementsByTagName("object");for(let d=0;d<c.length;d++){const f=c[d],g=f.getAttribute("id");if(!g)continue;const m=[],b=f.getElementsByTagName("mesh");for(let v=0;v<b.length;v++){const x=b[v],M=[],S=[],A=x.getElementsByTagName("vertex");for(let k=0;k<A.length;k++){const N=A[k];M.push(parseFloat(N.getAttribute("x")||"0"),parseFloat(N.getAttribute("y")||"0"),parseFloat(N.getAttribute("z")||"0"))}const T=x.getElementsByTagName("triangle");for(let k=0;k<T.length;k++){const N=T[k];S.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}M.length>0&&S.length>0&&m.push({vertices:M,triangles:S})}const y=f.getElementsByTagName("component");for(let v=0;v<y.length;v++){const x=y[v],M=x.getAttribute("p:path")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(M){const S=await a(M);if(S){const A=await BH(S),T=x.getAttribute("transform"),k=zH(T);for(const N of A)if(T){const I=[];for(let C=0;C<N.vertices.length;C+=3){const D=new Je(N.vertices[C],N.vertices[C+1],N.vertices[C+2]);D.applyMatrix4(k),I.push(D.x,D.y,D.z)}m.push({vertices:I,triangles:N.triangles})}else m.push(N)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const u=o.getElementsByTagName("build");if(u.length>0){const d=u[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const g=d[f],m=g.getAttribute("objectid");if(!m)continue;const b=zH(g.getAttribute("transform"));r.push({objectId:m,transform:b})}}return{objects:n,buildItems:r}}function HH(t){const e=new El,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 io(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function uje({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),a=E.useRef(null),s=E.useRef(null),o=E.useRef(null),[c,u]=E.useState(!0),[d,f]=E.useState(null);E.useEffect(()=>{if(!r.current)return;const b=r.current,y=b.clientWidth,v=b.clientHeight,x=new BNe;x.background=new _n(1710618),a.current=x;const M=new Ys(45,y/v,.1,1e4);M.position.set(150,150,150),s.current=M;const S=new $De({antialias:!0});S.setSize(y,v),S.setPixelRatio(window.devicePixelRatio),b.appendChild(S.domElement),i.current=S;const A=new GDe(M,S.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new JNe(16777215,.6);x.add(T);const k=new uH(16777215,.8);k.position.set(100,100,100),x.add(k);const N=new uH(16777215,.4);N.position.set(-100,50,-100),x.add(N);const I=Math.max(e.x,e.y),C=Math.ceil(I/16),D=new tke(I,C,4473924,3355443);x.add(D);const F=new hO(e.x,e.y),O=new cO({color:44610,transparent:!0,opacity:.15,side:rl}),q=new xl(F,O);q.rotation.x=-Math.PI/2,q.position.y=-.5,x.add(q);let R;const W=()=>{R=requestAnimationFrame(W),A.update(),S.render(x,M)};W(),fetch(t).then(G=>{if(!G.ok)throw new Error("Failed to load file");return G.arrayBuffer()}).then(cje).then(({objects:G,buildItems:ee})=>{if(G.size===0)throw new Error("No meshes found in 3MF file");const Z=new KNe({color:44610,shininess:30,flatShading:!1}),Q=new Lx,U=[];if(ee.length>0)for(const ie of ee){const xe=G.get(ie.objectId);if(xe)for(const Re of xe.meshes){const he=[];for(let H=0;H<Re.vertices.length;H+=3){const B=new Je(Re.vertices[H],Re.vertices[H+1],Re.vertices[H+2]);B.applyMatrix4(ie.transform),he.push(B.x,B.y,B.z)}const ht=HH({vertices:he,triangles:Re.triangles});U.push(ht)}}else for(const ie of G.values())for(const xe of ie.meshes){const Re=HH(xe);U.push(Re)}if(U.length>0){const ie=U.length===1?U[0]:ije(U,!1);if(ie){const xe=new xl(ie,Z);Q.add(xe)}if(U.length>1)for(const xe of U)xe.dispose()}const $=new tf().setFromObject(Q),X=$.getCenter(new Je);Q.position.y=-$.min.y,ee.length===0&&(Q.position.x=-X.x,Q.position.z=-X.z),x.add(Q);const te=new tf().setFromObject(Q),fe=te.getCenter(new Je),pe=te.getSize(new Je),Ne=Math.max(pe.x,pe.y,pe.z)*1.8;M.position.set(fe.x+Ne*.7,fe.y+Ne*.5,fe.z+Ne*.7),A.target.copy(fe),A.update(),u(!1)}).catch(G=>{f(G.message),u(!1)});const K=()=>{if(!b)return;const G=b.clientWidth,ee=b.clientHeight;M.aspect=G/ee,M.updateProjectionMatrix(),S.setSize(G,ee)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(R),A.dispose(),S.dispose(),b.removeChild(S.domElement)}},[t,e]);const g=()=>{s.current&&o.current&&(s.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=b=>{s.current&&s.current.position.multiplyScalar(b)};return l.jsxs("div",{className:`relative ${n}`,children:[l.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),c&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx("p",{className:"text-red-400",children:d})}),!c&&!d&&l.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:l.jsx(Hue,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:l.jsx(Gue,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:g,children:l.jsx(Km,{className:"w-4 h-4"})})]})]})}const HM="159",pp={ROTATE:0,DOLLY:1,PAN:2},mp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dje=0,$H=1,hje=2,AZ=1,fje=2,ac=3,fd=0,Ka=1,dc=2,Zu=0,am=1,VH=2,GH=3,WH=4,pje=5,ch=100,mje=101,gje=102,qH=103,KH=104,xje=200,bje=201,yje=202,vje=203,NP=204,kP=205,_je=206,wje=207,Sje=208,Mje=209,Eje=210,Aje=211,Tje=212,Cje=213,Nje=214,kje=0,Pje=1,Rje=2,Dw=3,Dje=4,jje=5,Oje=6,Lje=7,pO=0,Ije=1,Fje=2,Qu=0,Uje=1,zje=2,Bje=3,Hje=4,$je=5,TZ=300,Pm=301,Rm=302,PP=303,RP=304,$M=306,DP=1e3,ko=1001,jP=1002,Zi=1003,XH=1004,KC=1005,Zs=1006,Vje=1007,K0=1008,Ju=1009,Gje=1010,Wje=1011,mO=1012,CZ=1013,Hu=1014,xc=1015,X0=1016,NZ=1017,kZ=1018,Nh=1020,qje=1021,Qs=1023,Kje=1024,Xje=1025,kh=1026,Dm=1027,Yje=1028,PZ=1029,Zje=1030,RZ=1031,DZ=1033,XC=33776,YC=33777,ZC=33778,QC=33779,YH=35840,ZH=35841,QH=35842,JH=35843,jZ=36196,e$=37492,t$=37496,n$=37808,r$=37809,i$=37810,a$=37811,s$=37812,o$=37813,l$=37814,c$=37815,u$=37816,d$=37817,h$=37818,f$=37819,p$=37820,m$=37821,JC=36492,g$=36494,x$=36495,Qje=36283,b$=36284,y$=36285,v$=36286,OZ=3e3,Ph=3001,Jje=3200,eOe=3201,LZ=0,tOe=1,Js="",Qi="srgb",Ic="srgb-linear",gO="display-p3",VM="display-p3-linear",jw="linear",lr="srgb",Ow="rec709",Lw="p3",gp=7680,_$=519,nOe=512,rOe=513,iOe=514,IZ=515,aOe=516,sOe=517,oOe=518,lOe=519,OP=35044,w$="300 es",LP=1035,ll=2e3,Y0=2001;class mf{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,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const oa=["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 S$=1234567;const Kx=Math.PI/180,Z0=180/Math.PI;function Mc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(oa[t&255]+oa[t>>8&255]+oa[t>>16&255]+oa[t>>24&255]+"-"+oa[e&255]+oa[e>>8&255]+"-"+oa[e>>16&15|64]+oa[e>>24&255]+"-"+oa[n&63|128]+oa[n>>8&255]+"-"+oa[n>>16&255]+oa[n>>24&255]+oa[r&255]+oa[r>>8&255]+oa[r>>16&255]+oa[r>>24&255]).toLowerCase()}function Ji(t,e,n){return Math.max(e,Math.min(n,t))}function xO(t,e){return(t%e+e)%e}function cOe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function uOe(t,e,n){return t!==e?(n-t)/(e-t):0}function Xx(t,e,n){return(1-n)*t+n*e}function dOe(t,e,n,r){return Xx(t,e,1-Math.exp(-n*r))}function hOe(t,e=1){return e-Math.abs(xO(t,e*2)-e)}function fOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function pOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function mOe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function gOe(t,e){return t+Math.random()*(e-t)}function xOe(t){return t*(.5-Math.random())}function bOe(t){t!==void 0&&(S$=t);let e=S$+=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 yOe(t){return t*Kx}function vOe(t){return t*Z0}function IP(t){return(t&t-1)===0&&t!==0}function _Oe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Iw(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function wOe(t,e,n,r,i){const a=Math.cos,s=Math.sin,o=a(n/2),c=s(n/2),u=a((e+r)/2),d=s((e+r)/2),f=a((e-r)/2),g=s((e-r)/2),m=a((r-e)/2),b=s((r-e)/2);switch(i){case"XYX":t.set(o*d,c*f,c*g,o*u);break;case"YZY":t.set(c*g,o*d,c*f,o*u);break;case"ZXZ":t.set(c*f,c*g,o*d,o*u);break;case"XZX":t.set(o*d,c*b,c*m,o*u);break;case"YXY":t.set(c*m,o*d,c*b,o*u);break;case"ZYZ":t.set(c*b,c*m,o*d,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function il(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 Kn(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 FZ={DEG2RAD:Kx,RAD2DEG:Z0,generateUUID:Mc,clamp:Ji,euclideanModulo:xO,mapLinear:cOe,inverseLerp:uOe,lerp:Xx,damp:dOe,pingpong:hOe,smoothstep:fOe,smootherstep:pOe,randInt:mOe,randFloat:gOe,randFloatSpread:xOe,seededRandom:bOe,degToRad:yOe,radToDeg:vOe,isPowerOfTwo:IP,ceilPowerOfTwo:_Oe,floorPowerOfTwo:Iw,setQuaternionFromProperEuler:wOe,normalize:Kn,denormalize:il};class Zt{constructor(e=0,n=0){Zt.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(Ji(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,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,n,r,i,a,s,o,c,u){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,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,s=r[0],o=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],b=r[8],y=i[0],v=i[3],x=i[6],M=i[1],S=i[4],A=i[7],T=i[2],k=i[5],N=i[8];return a[0]=s*y+o*M+c*T,a[3]=s*v+o*S+c*k,a[6]=s*x+o*A+c*N,a[1]=u*y+d*M+f*T,a[4]=u*v+d*S+f*k,a[7]=u*x+d*A+f*N,a[2]=g*y+m*M+b*T,a[5]=g*v+m*S+b*k,a[8]=g*x+m*A+b*N,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],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*o*u-r*a*d+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*s-o*u,g=o*c-d*a,m=u*a-s*c,b=n*f+r*g+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(o*r-i*s)*y,e[3]=g*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-o*n)*y,e[6]=m*y,e[7]=(r*c-u*n)*y,e[8]=(s*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(eN.makeScale(e,n)),this}rotate(e){return this.premultiply(eN.makeRotation(-e)),this}translate(e,n){return this.premultiply(eN.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 eN=new fn;function UZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Fw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function SOe(){const t=Fw("canvas");return t.style.display="block",t}const M$={};function Yx(t){t in M$||(M$[t]=!0,console.warn(t))}const E$=new fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),A$=new fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),a_={[Ic]:{transfer:jw,primaries:Ow,toReference:t=>t,fromReference:t=>t},[Qi]:{transfer:lr,primaries:Ow,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[VM]:{transfer:jw,primaries:Lw,toReference:t=>t.applyMatrix3(A$),fromReference:t=>t.applyMatrix3(E$)},[gO]:{transfer:lr,primaries:Lw,toReference:t=>t.convertSRGBToLinear().applyMatrix3(A$),fromReference:t=>t.applyMatrix3(E$).convertLinearToSRGB()}},MOe=new Set([Ic,VM]),Xn={enabled:!0,_workingColorSpace:Ic,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(!MOe.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=a_[e].toReference,i=a_[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 a_[t].primaries},getTransfer:function(t){return t===Js?jw:a_[t].transfer}};function sm(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function tN(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let xp;class zZ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{xp===void 0&&(xp=Fw("canvas")),xp.width=e.width,xp.height=e.height;const r=xp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=xp}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=Fw("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 s=0;s<a.length;s++)a[s]=sm(a[s]/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(sm(n[r]/255)*255):n[r]=sm(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 EOe=0;class BZ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:EOe++}),this.uuid=Mc(),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 s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(nN(i[s].image)):a.push(nN(i[s]))}else a=nN(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function nN(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?zZ.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 AOe=0;class Xa extends mf{constructor(e=Xa.DEFAULT_IMAGE,n=Xa.DEFAULT_MAPPING,r=ko,i=ko,a=Zs,s=K0,o=Qs,c=Ju,u=Xa.DEFAULT_ANISOTROPY,d=Js){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:AOe++}),this.uuid=Mc(),this.name="",this.source=new BZ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Zt(0,0),this.repeat=new Zt(1,1),this.center=new Zt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Ph?Qi:Js),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!==TZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case DP:e.x=e.x-Math.floor(e.x);break;case ko:e.x=e.x<0?0:1;break;case jP:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case DP:e.y=e.y-Math.floor(e.y);break;case ko:e.y=e.y<0?0:1;break;case jP: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 Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Qi?Ph:OZ}set encoding(e){Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ph?Qi:Js}}Xa.DEFAULT_IMAGE=null;Xa.DEFAULT_MAPPING=TZ;Xa.DEFAULT_ANISOTROPY=1;class Zn{constructor(e=0,n=0,r=0,i=1){Zn.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,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],m=c[5],b=c[9],y=c[2],v=c[6],x=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(b-v)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(b+v)<.1&&Math.abs(u+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(x+1)/2,k=(d+g)/4,N=(f+y)/4,I=(b+v)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(S),i=k/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=k/i,a=I/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=I/a),this.set(r,i,a,n),this}let M=Math.sqrt((v-b)*(v-b)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(M)<.001&&(M=1),this.x=(v-b)/M,this.y=(f-y)/M,this.z=(g-d)/M,this.w=Math.acos((u+m+x-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 TOe extends mf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Zn(0,0,e,n),this.scissorTest=!1,this.viewport=new Zn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Yx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Ph?Qi:Js),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zs,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Xa(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 BZ(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 nf extends TOe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class HZ extends Xa{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=Zi,this.minFilter=Zi,this.wrapR=ko,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class COe extends Xa{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=Zi,this.minFilter=Zi,this.wrapR=ko,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class rf{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,s,o){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=a[s+0],m=a[s+1],b=a[s+2],y=a[s+3];if(o===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(f!==y||c!==g||u!==m||d!==b){let v=1-o;const x=c*g+u*m+d*b+f*y,M=x>=0?1:-1,S=1-x*x;if(S>Number.EPSILON){const T=Math.sqrt(S),k=Math.atan2(T,x*M);v=Math.sin(v*k)/T,o=Math.sin(o*k)/T}const A=o*M;if(c=c*v+g*A,u=u*v+m*A,d=d*v+b*A,f=f*v+y*A,v===1-o){const T=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=T,u*=T,d*=T,f*=T}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],m=a[s+2],b=a[s+3];return e[n]=o*b+d*f+c*m-u*g,e[n+1]=c*b+d*g+u*f-o*m,e[n+2]=u*b+d*m+o*g-c*f,e[n+3]=d*b-o*f-c*g-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),d=o(i/2),f=o(a/2),g=c(r/2),m=c(i/2),b=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*m*b,this._y=u*m*f-g*d*b,this._z=u*d*b+g*m*f,this._w=u*d*f-g*m*b;break;case"YXZ":this._x=g*d*f+u*m*b,this._y=u*m*f-g*d*b,this._z=u*d*b-g*m*f,this._w=u*d*f+g*m*b;break;case"ZXY":this._x=g*d*f-u*m*b,this._y=u*m*f+g*d*b,this._z=u*d*b+g*m*f,this._w=u*d*f-g*m*b;break;case"ZYX":this._x=g*d*f-u*m*b,this._y=u*m*f+g*d*b,this._z=u*d*b-g*m*f,this._w=u*d*f+g*m*b;break;case"YZX":this._x=g*d*f+u*m*b,this._y=u*m*f+g*d*b,this._z=u*d*b-g*m*f,this._w=u*d*f-g*m*b;break;case"XZY":this._x=g*d*f-u*m*b,this._y=u*m*f-g*d*b,this._z=u*d*b+g*m*f,this._w=u*d*f+g*m*b;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}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],s=n[1],o=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(s-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+s)/m,this._z=(a+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(a-u)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(s-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ji(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,s=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*o+i*u-a*c,this._y=i*d+s*c+a*o-r*u,this._z=a*d+s*u+r*c-i*o,this._w=s*d-r*o-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,s=this._w;let o=s*e._w+r*e._x+i*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=r,this._y=i,this._z=a,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-n;return this._w=m*s+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,o),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=s*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=a*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class je{constructor(e=0,n=0,r=0){je.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(T$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(T$.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,s=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])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),d=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-o*d,this.y=r+c*d+o*u-a*f,this.z=i+c*f+a*d-s*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,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,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 rN.copy(this).projectOnVector(e),this.sub(rN)}reflect(e){return this.sub(rN.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(Ji(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 rN=new je,T$=new rf;class ao{constructor(e=new je(1/0,1/0,1/0),n=new je(-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(So.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(So.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=So.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 s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,So):So.fromBufferAttribute(a,s),So.applyMatrix4(e.matrixWorld),this.expandByPoint(So);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),s_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),s_.copy(r.boundingBox)),s_.applyMatrix4(e.matrixWorld),this.union(s_)}const i=e.children;for(let a=0,s=i.length;a<s;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,So),So.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(Sx),o_.subVectors(this.max,Sx),bp.subVectors(e.a,Sx),yp.subVectors(e.b,Sx),vp.subVectors(e.c,Sx),yu.subVectors(yp,bp),vu.subVectors(vp,yp),Xd.subVectors(bp,vp);let n=[0,-yu.z,yu.y,0,-vu.z,vu.y,0,-Xd.z,Xd.y,yu.z,0,-yu.x,vu.z,0,-vu.x,Xd.z,0,-Xd.x,-yu.y,yu.x,0,-vu.y,vu.x,0,-Xd.y,Xd.x,0];return!iN(n,bp,yp,vp,o_)||(n=[1,0,0,0,1,0,0,0,1],!iN(n,bp,yp,vp,o_))?!1:(l_.crossVectors(yu,vu),n=[l_.x,l_.y,l_.z],iN(n,bp,yp,vp,o_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,So).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(So).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:(Yl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yl),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 Yl=[new je,new je,new je,new je,new je,new je,new je,new je],So=new je,s_=new ao,bp=new je,yp=new je,vp=new je,yu=new je,vu=new je,Xd=new je,Sx=new je,o_=new je,l_=new je,Yd=new je;function iN(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){Yd.fromArray(t,a);const o=i.x*Math.abs(Yd.x)+i.y*Math.abs(Yd.y)+i.z*Math.abs(Yd.z),c=e.dot(Yd),u=n.dot(Yd),d=r.dot(Yd);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>o)return!1}return!0}const NOe=new ao,Mx=new je,aN=new je;class ul{constructor(e=new je,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):NOe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;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;Mx.subVectors(e,this.center);const n=Mx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Mx,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):(aN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mx.copy(e.center).add(aN)),this.expandByPoint(Mx.copy(e.center).sub(aN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Zl=new je,sN=new je,c_=new je,_u=new je,oN=new je,u_=new je,lN=new je;class bO{constructor(e=new je,n=new je(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,Zl)),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=Zl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Zl.copy(this.origin).addScaledVector(this.direction,n),Zl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){sN.copy(e).add(n).multiplyScalar(.5),c_.copy(n).sub(e).normalize(),_u.copy(this.origin).sub(sN);const a=e.distanceTo(n)*.5,s=-this.direction.dot(c_),o=_u.dot(this.direction),c=-_u.dot(c_),u=_u.lengthSq(),d=Math.abs(1-s*s);let f,g,m,b;if(d>0)if(f=s*c-o,g=s*o-c,b=a*d,f>=0)if(g>=-b)if(g<=b){const y=1/d;f*=y,g*=y,m=f*(f+s*g+2*o)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;else g<=-b?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u):g<=b?(f=0,g=Math.min(Math.max(-a,-c),a),m=g*(g+2*c)+u):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+o)),m=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(sN).addScaledVector(c_,g),m}intersectSphere(e,n){Zl.subVectors(e.center,this.origin);const r=Zl.dot(this.direction),i=Zl.dot(Zl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,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,s,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Zl)!==null}intersectTriangle(e,n,r,i,a){oN.subVectors(n,e),u_.subVectors(r,e),lN.crossVectors(oN,u_);let s=this.direction.dot(lN),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;_u.subVectors(this.origin,e);const c=o*this.direction.dot(u_.crossVectors(_u,u_));if(c<0)return null;const u=o*this.direction.dot(oN.cross(_u));if(u<0||c+u>s)return null;const d=-o*_u.dot(lN);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ar{constructor(e,n,r,i,a,s,o,c,u,d,f,g,m,b,y,v){ar.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u,d,f,g,m,b,y,v)}set(e,n,r,i,a,s,o,c,u,d,f,g,m,b,y,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=a,x[5]=s,x[9]=o,x[13]=c,x[2]=u,x[6]=d,x[10]=f,x[14]=g,x[3]=m,x[7]=b,x[11]=y,x[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ar().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/_p.setFromMatrixColumn(e,0).length(),a=1/_p.setFromMatrixColumn(e,1).length(),s=1/_p.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]*s,n[9]=r[9]*s,n[10]=r[10]*s,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,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,m=s*f,b=o*d,y=o*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+b*u,n[5]=g-y*u,n[9]=-o*c,n[2]=y-g*u,n[6]=b+m*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,m=c*f,b=u*d,y=u*f;n[0]=g+y*o,n[4]=b*o-m,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=m*o-b,n[6]=y+g*o,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,m=c*f,b=u*d,y=u*f;n[0]=g-y*o,n[4]=-s*f,n[8]=b+m*o,n[1]=m+b*o,n[5]=s*d,n[9]=y-g*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,m=s*f,b=o*d,y=o*f;n[0]=c*d,n[4]=b*u-m,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=m*u-b,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,m=s*u,b=o*c,y=o*u;n[0]=c*d,n[4]=y-g*f,n[8]=b*f+m,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+b,n[10]=g-y*f}else if(e.order==="XZY"){const g=s*c,m=s*u,b=o*c,y=o*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=s*d,n[9]=m*f-b,n[2]=b*f-m,n[6]=o*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kOe,e,POe)}lookAt(e,n,r){const i=this.elements;return ds.subVectors(e,n),ds.lengthSq()===0&&(ds.z=1),ds.normalize(),wu.crossVectors(r,ds),wu.lengthSq()===0&&(Math.abs(r.z)===1?ds.x+=1e-4:ds.z+=1e-4,ds.normalize(),wu.crossVectors(r,ds)),wu.normalize(),d_.crossVectors(ds,wu),i[0]=wu.x,i[4]=d_.x,i[8]=ds.x,i[1]=wu.y,i[5]=d_.y,i[9]=ds.y,i[2]=wu.z,i[6]=d_.z,i[10]=ds.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,s=r[0],o=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],b=r[2],y=r[6],v=r[10],x=r[14],M=r[3],S=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],O=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],ee=i[3],Z=i[7],Q=i[11],U=i[15];return a[0]=s*k+o*D+c*R+u*ee,a[4]=s*N+o*F+c*W+u*Z,a[8]=s*I+o*O+c*K+u*Q,a[12]=s*C+o*q+c*G+u*U,a[1]=d*k+f*D+g*R+m*ee,a[5]=d*N+f*F+g*W+m*Z,a[9]=d*I+f*O+g*K+m*Q,a[13]=d*C+f*q+g*G+m*U,a[2]=b*k+y*D+v*R+x*ee,a[6]=b*N+y*F+v*W+x*Z,a[10]=b*I+y*O+v*K+x*Q,a[14]=b*C+y*q+v*G+x*U,a[3]=M*k+S*D+A*R+T*ee,a[7]=M*N+S*F+A*W+T*Z,a[11]=M*I+S*O+A*K+T*Q,a[15]=M*C+S*q+A*G+T*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],s=e[1],o=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],b=e[3],y=e[7],v=e[11],x=e[15];return b*(+a*c*f-i*u*f-a*o*g+r*u*g+i*o*m-r*c*m)+y*(+n*c*m-n*u*g+a*s*g-i*s*m+i*u*d-a*c*d)+v*(+n*u*f-n*o*m-a*s*f+r*s*m+a*o*d-r*u*d)+x*(-i*o*d-n*c*f+n*o*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],b=e[12],y=e[13],v=e[14],x=e[15],M=f*v*u-y*g*u+y*c*m-o*v*m-f*c*x+o*g*x,S=b*g*u-d*v*u-b*c*m+s*v*m+d*c*x-s*g*x,A=d*y*u-b*f*u+b*o*m-s*y*m-d*o*x+s*f*x,T=b*f*c-d*y*c-b*o*g+s*y*g+d*o*v-s*f*v,k=n*M+r*S+i*A+a*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/k;return e[0]=M*N,e[1]=(y*g*a-f*v*a-y*i*m+r*v*m+f*i*x-r*g*x)*N,e[2]=(o*v*a-y*c*a+y*i*u-r*v*u-o*i*x+r*c*x)*N,e[3]=(f*c*a-o*g*a-f*i*u+r*g*u+o*i*m-r*c*m)*N,e[4]=S*N,e[5]=(d*v*a-b*g*a+b*i*m-n*v*m-d*i*x+n*g*x)*N,e[6]=(b*c*a-s*v*a-b*i*u+n*v*u+s*i*x-n*c*x)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*m+n*c*m)*N,e[8]=A*N,e[9]=(b*f*a-d*y*a-b*r*m+n*y*m+d*r*x-n*f*x)*N,e[10]=(s*y*a-b*o*a+b*r*u-n*y*u-s*r*x+n*o*x)*N,e[11]=(d*o*a-s*f*a-d*r*u+n*f*u+s*r*m-n*o*m)*N,e[12]=T*N,e[13]=(d*y*i-b*f*i+b*r*g-n*y*g-d*r*v+n*f*v)*N,e[14]=(b*o*i-s*y*i-b*r*c+n*y*c+s*r*v-n*o*v)*N,e[15]=(s*f*i-d*o*i+d*r*c-n*f*c-s*r*g+n*o*g)*N,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,s=e.x,o=e.y,c=e.z,u=a*s,d=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*s,0,u*c-i*o,d*c+i*s,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,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,d=s+s,f=o+o,g=a*u,m=a*d,b=a*f,y=s*d,v=s*f,x=o*f,M=c*u,S=c*d,A=c*f,T=r.x,k=r.y,N=r.z;return i[0]=(1-(y+x))*T,i[1]=(m+A)*T,i[2]=(b-S)*T,i[3]=0,i[4]=(m-A)*k,i[5]=(1-(g+x))*k,i[6]=(v+M)*k,i[7]=0,i[8]=(b+S)*N,i[9]=(v-M)*N,i[10]=(1-(g+y))*N,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=_p.set(i[0],i[1],i[2]).length();const s=_p.set(i[4],i[5],i[6]).length(),o=_p.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],Mo.copy(this);const u=1/a,d=1/s,f=1/o;return Mo.elements[0]*=u,Mo.elements[1]*=u,Mo.elements[2]*=u,Mo.elements[4]*=d,Mo.elements[5]*=d,Mo.elements[6]*=d,Mo.elements[8]*=f,Mo.elements[9]*=f,Mo.elements[10]*=f,n.setFromRotationMatrix(Mo),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=ll){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let m,b;if(o===ll)m=-(s+a)/(s-a),b=-2*s*a/(s-a);else if(o===Y0)m=-s/(s-a),b=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=ll){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(s-a),g=(n+e)*u,m=(r+i)*d;let b,y;if(o===ll)b=(s+a)*f,y=-2*f;else if(o===Y0)b=a*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-g,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=y,c[14]=-b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const _p=new je,Mo=new ar,kOe=new je(0,0,0),POe=new je(1,1,1),wu=new je,d_=new je,ds=new je,C$=new ar,N$=new rf;class qb{constructor(e=0,n=0,r=0,i=qb.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],s=i[4],o=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Ji(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Ji(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Ji(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Ji(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(Ji(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(o,m));break;case"XZY":this._z=Math.asin(-Ji(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return C$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(C$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return N$.setFromEuler(this),this.setFromQuaternion(N$,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}}qb.DEFAULT_ORDER="XYZ";class $Z{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 ROe=0;const k$=new je,wp=new rf,Ql=new ar,h_=new je,Ex=new je,DOe=new je,jOe=new rf,P$=new je(1,0,0),R$=new je(0,1,0),D$=new je(0,0,1),OOe={type:"added"},LOe={type:"removed"};class Aa extends mf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ROe++}),this.uuid=Mc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Aa.DEFAULT_UP.clone();const e=new je,n=new qb,r=new rf,i=new je(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ar},normalMatrix:{value:new fn}}),this.matrix=new ar,this.matrixWorld=new ar,this.matrixAutoUpdate=Aa.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new $Z,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 wp.setFromAxisAngle(e,n),this.quaternion.multiply(wp),this}rotateOnWorldAxis(e,n){return wp.setFromAxisAngle(e,n),this.quaternion.premultiply(wp),this}rotateX(e){return this.rotateOnAxis(P$,e)}rotateY(e){return this.rotateOnAxis(R$,e)}rotateZ(e){return this.rotateOnAxis(D$,e)}translateOnAxis(e,n){return k$.copy(e).applyQuaternion(this.quaternion),this.position.add(k$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(P$,e)}translateY(e){return this.translateOnAxis(R$,e)}translateZ(e){return this.translateOnAxis(D$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ql.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?h_.copy(e):h_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ex.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ql.lookAt(Ex,h_,this.up):Ql.lookAt(h_,Ex,this.up),this.quaternion.setFromRotationMatrix(Ql),i&&(Ql.extractRotation(i.matrixWorld),wp.setFromRotationMatrix(Ql),this.quaternion.premultiply(wp.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(OOe)):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(LOe)),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),Ql.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ql.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ql),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 s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;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(Ex,e,DOe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ex,jOe,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,s=i.length;a<s;a++){const o=i[a];o.matrixWorldAutoUpdate===!0&&o.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(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.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(o,c){return o[c.uuid]===void 0&&(o[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 o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.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 o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),m=s(e.animations),b=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}return r.object=i,r;function s(o){const c=[];for(const u in o){const d=o[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}}Aa.DEFAULT_UP=new je(0,1,0);Aa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Aa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Eo=new je,Jl=new je,cN=new je,ec=new je,Sp=new je,Mp=new je,j$=new je,uN=new je,dN=new je,hN=new je;let f_=!1;class Ao{constructor(e=new je,n=new je,r=new je){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Eo.subVectors(e,n),i.cross(Eo);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){Eo.subVectors(i,n),Jl.subVectors(r,n),cN.subVectors(e,n);const s=Eo.dot(Eo),o=Eo.dot(Jl),c=Eo.dot(cN),u=Jl.dot(Jl),d=Jl.dot(cN),f=s*u-o*o;if(f===0)return a.set(-2,-1,-1);const g=1/f,m=(u*c-o*d)*g,b=(s*d-o*c)*g;return a.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,ec),ec.x>=0&&ec.y>=0&&ec.x+ec.y<=1}static getUV(e,n,r,i,a,s,o,c){return f_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),f_=!0),this.getInterpolation(e,n,r,i,a,s,o,c)}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,ec),c.setScalar(0),c.addScaledVector(a,ec.x),c.addScaledVector(s,ec.y),c.addScaledVector(o,ec.z),c}static isFrontFacing(e,n,r,i){return Eo.subVectors(r,n),Jl.subVectors(e,n),Eo.cross(Jl).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 Eo.subVectors(this.c,this.b),Jl.subVectors(this.a,this.b),Eo.cross(Jl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ao.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ao.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return f_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),f_=!0),Ao.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Ao.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Ao.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ao.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 s,o;Sp.subVectors(i,r),Mp.subVectors(a,r),uN.subVectors(e,r);const c=Sp.dot(uN),u=Mp.dot(uN);if(c<=0&&u<=0)return n.copy(r);dN.subVectors(e,i);const d=Sp.dot(dN),f=Mp.dot(dN);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return s=c/(c-d),n.copy(r).addScaledVector(Sp,s);hN.subVectors(e,a);const m=Sp.dot(hN),b=Mp.dot(hN);if(b>=0&&m<=b)return n.copy(a);const y=m*u-c*b;if(y<=0&&u>=0&&b<=0)return o=u/(u-b),n.copy(r).addScaledVector(Mp,o);const v=d*b-m*f;if(v<=0&&f-d>=0&&m-b>=0)return j$.subVectors(a,i),o=(f-d)/(f-d+(m-b)),n.copy(i).addScaledVector(j$,o);const x=1/(v+y+g);return s=y*x,o=g*x,n.copy(r).addScaledVector(Sp,s).addScaledVector(Mp,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const VZ={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},Su={h:0,s:0,l:0},p_={h:0,s:0,l:0};function fN(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 $t=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=Qi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xn.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Xn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Xn.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Xn.workingColorSpace){if(e=xO(e,1),n=Ji(n,0,1),r=Ji(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=fN(s,a,e+1/3),this.g=fN(s,a,e),this.b=fN(s,a,e-1/3)}return Xn.toWorkingColorSpace(this,i),this}setStyle(e,n=Qi){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 s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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(o))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(o))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],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===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=Qi){const r=VZ[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=sm(e.r),this.g=sm(e.g),this.b=sm(e.b),this}copyLinearToSRGB(e){return this.r=tN(e.r),this.g=tN(e.g),this.b=tN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Qi){return Xn.fromWorkingColorSpace(la.copy(this),e),Math.round(Ji(la.r*255,0,255))*65536+Math.round(Ji(la.g*255,0,255))*256+Math.round(Ji(la.b*255,0,255))}getHexString(e=Qi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Xn.workingColorSpace){Xn.fromWorkingColorSpace(la.copy(this),n);const r=la.r,i=la.g,a=la.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const d=(o+s)/2;if(o===s)c=0,u=0;else{const f=s-o;switch(u=d<=.5?f/(s+o):f/(2-s-o),s){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=Xn.workingColorSpace){return Xn.fromWorkingColorSpace(la.copy(this),n),e.r=la.r,e.g=la.g,e.b=la.b,e}getStyle(e=Qi){Xn.fromWorkingColorSpace(la.copy(this),e);const n=la.r,r=la.g,i=la.b;return e!==Qi?`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(Su),this.setHSL(Su.h+e,Su.s+n,Su.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(Su),e.getHSL(p_);const r=Xx(Su.h,p_.h,n),i=Xx(Su.s,p_.s,n),a=Xx(Su.l,p_.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 la=new $t;$t.NAMES=VZ;let IOe=0;class cg extends mf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:IOe++}),this.uuid=Mc(),this.name="",this.type="Material",this.blending=am,this.side=fd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=NP,this.blendDst=kP,this.blendEquation=ch,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new $t(0,0,0),this.blendAlpha=0,this.depthFunc=Dw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=_$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gp,this.stencilZFail=gp,this.stencilZPass=gp,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!==am&&(r.blending=this.blending),this.side!==fd&&(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!==NP&&(r.blendSrc=this.blendSrc),this.blendDst!==kP&&(r.blendDst=this.blendDst),this.blendEquation!==ch&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Dw&&(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!==_$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==gp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==gp&&(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 s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}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 GZ extends cg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new $t(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=pO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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 Kr=new je,m_=new Zt;class Ss{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=OP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=xc,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++)m_.fromBufferAttribute(this,n),m_.applyMatrix3(e),this.setXY(n,m_.x,m_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyMatrix3(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyMatrix4(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyNormalMatrix(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.transformDirection(e),this.setXYZ(n,Kr.x,Kr.y,Kr.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=il(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Kn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=il(n,this.array)),n}setX(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=il(n,this.array)),n}setY(e,n){return this.normalized&&(n=Kn(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=il(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Kn(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=il(n,this.array)),n}setW(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Kn(n,this.array),r=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array),a=Kn(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!==OP&&(e.usage=this.usage),e}}class WZ extends Ss{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class qZ extends Ss{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Br extends Ss{constructor(e,n,r){super(new Float32Array(e),n,r)}}let FOe=0;const Bs=new ar,pN=new Aa,Ep=new je,hs=new ao,Ax=new ao,ki=new je;class ga extends mf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:FOe++}),this.uuid=Mc(),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(UZ(e)?qZ:WZ)(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 fn().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 Bs.makeRotationFromQuaternion(e),this.applyMatrix4(Bs),this}rotateX(e){return Bs.makeRotationX(e),this.applyMatrix4(Bs),this}rotateY(e){return Bs.makeRotationY(e),this.applyMatrix4(Bs),this}rotateZ(e){return Bs.makeRotationZ(e),this.applyMatrix4(Bs),this}translate(e,n,r){return Bs.makeTranslation(e,n,r),this.applyMatrix4(Bs),this}scale(e,n,r){return Bs.makeScale(e,n,r),this.applyMatrix4(Bs),this}lookAt(e){return pN.lookAt(e),pN.updateMatrix(),this.applyMatrix4(pN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ep).negate(),this.translate(Ep.x,Ep.y,Ep.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 Br(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ao);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 je(-1/0,-1/0,-1/0),new je(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];hs.setFromBufferAttribute(a),this.morphTargetsRelative?(ki.addVectors(this.boundingBox.min,hs.min),this.boundingBox.expandByPoint(ki),ki.addVectors(this.boundingBox.max,hs.max),this.boundingBox.expandByPoint(ki)):(this.boundingBox.expandByPoint(hs.min),this.boundingBox.expandByPoint(hs.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 ul);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 je,1/0);return}if(e){const r=this.boundingSphere.center;if(hs.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Ax.setFromBufferAttribute(o),this.morphTargetsRelative?(ki.addVectors(hs.min,Ax.min),hs.expandByPoint(ki),ki.addVectors(hs.max,Ax.max),hs.expandByPoint(ki)):(hs.expandByPoint(Ax.min),hs.expandByPoint(Ax.max))}hs.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)ki.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(ki));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)ki.fromBufferAttribute(o,u),c&&(Ep.fromBufferAttribute(e,u),ki.add(Ep)),i=Math.max(i,r.distanceToSquared(ki))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,s=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ss(new Float32Array(4*o),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<o;D++)u[D]=new je,d[D]=new je;const f=new je,g=new je,m=new je,b=new Zt,y=new Zt,v=new Zt,x=new je,M=new je;function S(D,F,O){f.fromArray(i,D*3),g.fromArray(i,F*3),m.fromArray(i,O*3),b.fromArray(s,D*2),y.fromArray(s,F*2),v.fromArray(s,O*2),g.sub(f),m.sub(f),y.sub(b),v.sub(b);const q=1/(y.x*v.y-v.x*y.y);isFinite(q)&&(x.copy(g).multiplyScalar(v.y).addScaledVector(m,-y.y).multiplyScalar(q),M.copy(m).multiplyScalar(y.x).addScaledVector(g,-v.x).multiplyScalar(q),u[D].add(x),u[F].add(x),u[O].add(x),d[D].add(M),d[F].add(M),d[O].add(M))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let D=0,F=A.length;D<F;++D){const O=A[D],q=O.start,R=O.count;for(let W=q,K=q+R;W<K;W+=3)S(r[W+0],r[W+1],r[W+2])}const T=new je,k=new je,N=new je,I=new je;function C(D){N.fromArray(a,D*3),I.copy(N);const F=u[D];T.copy(F),T.sub(N.multiplyScalar(N.dot(F))).normalize(),k.crossVectors(I,F);const q=k.dot(d[D])<0?-1:1;c[D*4]=T.x,c[D*4+1]=T.y,c[D*4+2]=T.z,c[D*4+3]=q}for(let D=0,F=A.length;D<F;++D){const O=A[D],q=O.start,R=O.count;for(let W=q,K=q+R;W<K;W+=3)C(r[W+0]),C(r[W+1]),C(r[W+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Ss(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new je,a=new je,s=new je,o=new je,c=new je,u=new je,d=new je,f=new je;if(e)for(let g=0,m=e.count;g<m;g+=3){const b=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),s.fromBufferAttribute(n,v),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),o.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),c.add(d),u.add(d),r.setXYZ(b,o.x,o.y,o.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(v,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)ki.fromBufferAttribute(e,n),ki.normalize(),e.setXYZ(n,ki.x,ki.y,ki.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let m=0,b=0;for(let y=0,v=c.length;y<v;y++){o.isInterleavedBufferAttribute?m=c[y]*o.data.stride+o.offset:m=c[y]*d;for(let x=0;x<d;x++)g[b++]=u[m++]}return new Ss(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ga,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);c.push(m)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.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 O$=new ar,Zd=new bO,g_=new ul,L$=new je,Ap=new je,Tp=new je,Cp=new je,mN=new je,x_=new je,b_=new Zt,y_=new Zt,v_=new Zt,I$=new je,F$=new je,U$=new je,__=new je,w_=new je;class jo extends Aa{constructor(e=new ga,n=new GZ){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,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){x_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=o[c],f=a[c];d!==0&&(mN.fromBufferAttribute(f,e),s?x_.addScaledVector(mN,d):x_.addScaledVector(mN.sub(n),d))}n.add(x_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),g_.copy(r.boundingSphere),g_.applyMatrix4(a),Zd.copy(e.ray).recast(e.near),!(g_.containsPoint(Zd.origin)===!1&&(Zd.intersectSphere(g_,L$)===null||Zd.origin.distanceToSquared(L$)>(e.far-e.near)**2))&&(O$.copy(a).invert(),Zd.copy(e.ray).applyMatrix4(O$),!(r.boundingBox!==null&&Zd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Zd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),S=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=S_(this,x,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=o.getX(v),S=o.getX(v+1),A=o.getX(v+2);i=S_(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),S=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let A=M,T=S;A<T;A+=3){const k=A,N=A+1,I=A+2;i=S_(this,x,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=v,S=v+1,A=v+2;i=S_(this,s,e,r,u,d,f,M,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function UOe(t,e,n,r,i,a,s,o){let c;if(e.side===Ka?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===fd,o),c===null)return null;w_.copy(o),w_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(w_);return u<n.near||u>n.far?null:{distance:u,point:w_.clone(),object:t}}function S_(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Ap),t.getVertexPosition(c,Tp),t.getVertexPosition(u,Cp);const d=UOe(t,e,n,r,Ap,Tp,Cp,__);if(d){i&&(b_.fromBufferAttribute(i,o),y_.fromBufferAttribute(i,c),v_.fromBufferAttribute(i,u),d.uv=Ao.getInterpolation(__,Ap,Tp,Cp,b_,y_,v_,new Zt)),a&&(b_.fromBufferAttribute(a,o),y_.fromBufferAttribute(a,c),v_.fromBufferAttribute(a,u),d.uv1=Ao.getInterpolation(__,Ap,Tp,Cp,b_,y_,v_,new Zt),d.uv2=d.uv1),s&&(I$.fromBufferAttribute(s,o),F$.fromBufferAttribute(s,c),U$.fromBufferAttribute(s,u),d.normal=Ao.getInterpolation(__,Ap,Tp,Cp,I$,F$,U$,new je),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:o,b:c,c:u,normal:new je,materialIndex:0};Ao.getNormal(Ap,Tp,Cp,f.normal),d.face=f}return d}class Kb extends ga{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,m=0;b("z","y","x",-1,-1,r,n,e,s,a,0),b("z","y","x",1,-1,r,n,-e,s,a,1),b("x","z","y",1,1,e,r,n,i,s,2),b("x","z","y",1,-1,e,r,-n,i,s,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Br(u,3)),this.setAttribute("normal",new Br(d,3)),this.setAttribute("uv",new Br(f,2));function b(y,v,x,M,S,A,T,k,N,I,C){const D=A/N,F=T/I,O=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let G=0,ee=0;const Z=new je;for(let Q=0;Q<K;Q++){const U=Q*F-q;for(let $=0;$<W;$++){const X=$*D-O;Z[y]=X*M,Z[v]=U*S,Z[x]=R,u.push(Z.x,Z.y,Z.z),Z[y]=0,Z[v]=0,Z[x]=k>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push($/N),f.push(1-Q/I),G+=1}}for(let Q=0;Q<I;Q++)for(let U=0;U<N;U++){const $=g+U+W*Q,X=g+U+W*(Q+1),te=g+(U+1)+W*(Q+1),fe=g+(U+1)+W*Q;c.push($,X,fe),c.push(X,te,fe),ee+=6}o.addGroup(m,ee,C),m+=ee,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kb(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function jm(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 _a(t){const e={};for(let n=0;n<t.length;n++){const r=jm(t[n]);for(const i in r)e[i]=r[i]}return e}function zOe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function KZ(t){return t.getRenderTarget()===null?t.outputColorSpace:Xn.workingColorSpace}const yO={clone:jm,merge:_a};var BOe=`void main() {
  3875. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3876. }`,HOe=`void main() {
  3877. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3878. }`;class pd extends cg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=BOe,this.fragmentShader=HOe,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=jm(e.uniforms),this.uniformsGroups=zOe(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 s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}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 XZ extends Aa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ar,this.projectionMatrix=new ar,this.projectionMatrixInverse=new ar,this.coordinateSystem=ll}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 ms extends XZ{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=Z0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Kx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Z0*2*Math.atan(Math.tan(Kx*.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,s){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=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Kx*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const o=this.filmOffset;o!==0&&(a+=e*o/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 Np=-90,kp=1;class $Oe extends Aa{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ms(Np,kp,e,n);i.layers=this.layers,this.add(i);const a=new ms(Np,kp,e,n);a.layers=this.layers,this.add(a);const s=new ms(Np,kp,e,n);s.layers=this.layers,this.add(s);const o=new ms(Np,kp,e,n);o.layers=this.layers,this.add(o);const c=new ms(Np,kp,e,n);c.layers=this.layers,this.add(c);const u=new ms(Np,kp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,c]=n;for(const u of n)this.remove(u);if(e===ll)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),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Y0)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),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.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,s,o,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class YZ extends Xa{constructor(e,n,r,i,a,s,o,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Pm,super(e,n,r,i,a,s,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class VOe extends nf{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&&(Yx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Ph?Qi:Js),this.texture=new YZ(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:Zs}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:`
  3879. varying vec3 vWorldDirection;
  3880. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3881. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3882. }
  3883. void main() {
  3884. vWorldDirection = transformDirection( position, modelMatrix );
  3885. #include <begin_vertex>
  3886. #include <project_vertex>
  3887. }
  3888. `,fragmentShader:`
  3889. uniform sampler2D tEquirect;
  3890. varying vec3 vWorldDirection;
  3891. #include <common>
  3892. void main() {
  3893. vec3 direction = normalize( vWorldDirection );
  3894. vec2 sampleUV = equirectUv( direction );
  3895. gl_FragColor = texture2D( tEquirect, sampleUV );
  3896. }
  3897. `},i=new Kb(5,5,5),a=new pd({name:"CubemapFromEquirect",uniforms:jm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ka,blending:Zu});a.uniforms.tEquirect.value=n;const s=new jo(i,a),o=n.minFilter;return n.minFilter===K0&&(n.minFilter=Zs),new $Oe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}}const gN=new je,GOe=new je,WOe=new fn;class Pu{constructor(e=new je(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=gN.subVectors(r,n).cross(GOe.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(gN),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||WOe.getNormalMatrix(e),i=this.coplanarPoint(gN).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 Qd=new ul,M_=new je;class GM{constructor(e=new Pu,n=new Pu,r=new Pu,i=new Pu,a=new Pu,s=new Pu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),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=ll){const r=this.planes,i=e.elements,a=i[0],s=i[1],o=i[2],c=i[3],u=i[4],d=i[5],f=i[6],g=i[7],m=i[8],b=i[9],y=i[10],v=i[11],x=i[12],M=i[13],S=i[14],A=i[15];if(r[0].setComponents(c-a,g-u,v-m,A-x).normalize(),r[1].setComponents(c+a,g+u,v+m,A+x).normalize(),r[2].setComponents(c+s,g+d,v+b,A+M).normalize(),r[3].setComponents(c-s,g-d,v-b,A-M).normalize(),r[4].setComponents(c-o,g-f,v-y,A-S).normalize(),n===ll)r[5].setComponents(c+o,g+f,v+y,A+S).normalize();else if(n===Y0)r[5].setComponents(o,f,y,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(),Qd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Qd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qd)}intersectsSprite(e){return Qd.center.set(0,0,0),Qd.radius=.7071067811865476,Qd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qd)}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(M_.x=i.normal.x>0?e.max.x:e.min.x,M_.y=i.normal.y>0?e.max.y:e.min.y,M_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(M_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function ZZ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),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 qOe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,m=f.byteLength,b=t.createBuffer();t.bindBuffer(d,b),t.bufferData(d,f,g),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:b,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:m}}function a(u,d,f){const g=d.array,m=d._updateRange,b=d.updateRanges;if(t.bindBuffer(f,u),m.count===-1&&b.length===0&&t.bufferSubData(f,0,g),b.length!==0){for(let y=0,v=b.length;y<v;y++){const x=b[y];n?t.bufferSubData(f,x.start*g.BYTES_PER_ELEMENT,g,x.start,x.count):t.bufferSubData(f,x.start*g.BYTES_PER_ELEMENT,g.subarray(x.start,x.start+x.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g,m.offset,m.count):t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g.subarray(m.offset,m.offset+m.count)),m.count=-1),d.onUploadCallback()}function s(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function o(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:s,remove:o,update:c}}class vO extends ga{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,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,m=[],b=[],y=[],v=[];for(let x=0;x<d;x++){const M=x*g-s;for(let S=0;S<u;S++){const A=S*f-a;b.push(A,-M,0),y.push(0,0,1),v.push(S/o),v.push(1-x/c)}}for(let x=0;x<c;x++)for(let M=0;M<o;M++){const S=M+u*x,A=M+u*(x+1),T=M+1+u*(x+1),k=M+1+u*x;m.push(S,A,k),m.push(A,T,k)}this.setIndex(m),this.setAttribute("position",new Br(b,3)),this.setAttribute("normal",new Br(y,3)),this.setAttribute("uv",new Br(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vO(e.width,e.height,e.widthSegments,e.heightSegments)}}var KOe=`#ifdef USE_ALPHAHASH
  3898. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3899. #endif`,XOe=`#ifdef USE_ALPHAHASH
  3900. const float ALPHA_HASH_SCALE = 0.05;
  3901. float hash2D( vec2 value ) {
  3902. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3903. }
  3904. float hash3D( vec3 value ) {
  3905. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3906. }
  3907. float getAlphaHashThreshold( vec3 position ) {
  3908. float maxDeriv = max(
  3909. length( dFdx( position.xyz ) ),
  3910. length( dFdy( position.xyz ) )
  3911. );
  3912. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3913. vec2 pixScales = vec2(
  3914. exp2( floor( log2( pixScale ) ) ),
  3915. exp2( ceil( log2( pixScale ) ) )
  3916. );
  3917. vec2 alpha = vec2(
  3918. hash3D( floor( pixScales.x * position.xyz ) ),
  3919. hash3D( floor( pixScales.y * position.xyz ) )
  3920. );
  3921. float lerpFactor = fract( log2( pixScale ) );
  3922. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3923. float a = min( lerpFactor, 1.0 - lerpFactor );
  3924. vec3 cases = vec3(
  3925. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3926. ( x - 0.5 * a ) / ( 1.0 - a ),
  3927. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3928. );
  3929. float threshold = ( x < ( 1.0 - a ) )
  3930. ? ( ( x < a ) ? cases.x : cases.y )
  3931. : cases.z;
  3932. return clamp( threshold , 1.0e-6, 1.0 );
  3933. }
  3934. #endif`,YOe=`#ifdef USE_ALPHAMAP
  3935. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3936. #endif`,ZOe=`#ifdef USE_ALPHAMAP
  3937. uniform sampler2D alphaMap;
  3938. #endif`,QOe=`#ifdef USE_ALPHATEST
  3939. if ( diffuseColor.a < alphaTest ) discard;
  3940. #endif`,JOe=`#ifdef USE_ALPHATEST
  3941. uniform float alphaTest;
  3942. #endif`,eLe=`#ifdef USE_AOMAP
  3943. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3944. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3945. #if defined( USE_CLEARCOAT )
  3946. clearcoatSpecularIndirect *= ambientOcclusion;
  3947. #endif
  3948. #if defined( USE_SHEEN )
  3949. sheenSpecularIndirect *= ambientOcclusion;
  3950. #endif
  3951. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3952. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3953. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3954. #endif
  3955. #endif`,tLe=`#ifdef USE_AOMAP
  3956. uniform sampler2D aoMap;
  3957. uniform float aoMapIntensity;
  3958. #endif`,nLe=`#ifdef USE_BATCHING
  3959. attribute float batchId;
  3960. uniform highp sampler2D batchingTexture;
  3961. mat4 getBatchingMatrix( const in float i ) {
  3962. int size = textureSize( batchingTexture, 0 ).x;
  3963. int j = int( i ) * 4;
  3964. int x = j % size;
  3965. int y = j / size;
  3966. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3967. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3968. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3969. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3970. return mat4( v1, v2, v3, v4 );
  3971. }
  3972. #endif`,rLe=`#ifdef USE_BATCHING
  3973. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3974. #endif`,iLe=`vec3 transformed = vec3( position );
  3975. #ifdef USE_ALPHAHASH
  3976. vPosition = vec3( position );
  3977. #endif`,aLe=`vec3 objectNormal = vec3( normal );
  3978. #ifdef USE_TANGENT
  3979. vec3 objectTangent = vec3( tangent.xyz );
  3980. #endif`,sLe=`float G_BlinnPhong_Implicit( ) {
  3981. return 0.25;
  3982. }
  3983. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3984. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3985. }
  3986. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3987. vec3 halfDir = normalize( lightDir + viewDir );
  3988. float dotNH = saturate( dot( normal, halfDir ) );
  3989. float dotVH = saturate( dot( viewDir, halfDir ) );
  3990. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3991. float G = G_BlinnPhong_Implicit( );
  3992. float D = D_BlinnPhong( shininess, dotNH );
  3993. return F * ( G * D );
  3994. } // validated`,oLe=`#ifdef USE_IRIDESCENCE
  3995. const mat3 XYZ_TO_REC709 = mat3(
  3996. 3.2404542, -0.9692660, 0.0556434,
  3997. -1.5371385, 1.8760108, -0.2040259,
  3998. -0.4985314, 0.0415560, 1.0572252
  3999. );
  4000. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4001. vec3 sqrtF0 = sqrt( fresnel0 );
  4002. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4003. }
  4004. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4005. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4006. }
  4007. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4008. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4009. }
  4010. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4011. float phase = 2.0 * PI * OPD * 1.0e-9;
  4012. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4013. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4014. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4015. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4016. 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 ) );
  4017. xyz /= 1.0685e-7;
  4018. vec3 rgb = XYZ_TO_REC709 * xyz;
  4019. return rgb;
  4020. }
  4021. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4022. vec3 I;
  4023. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4024. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4025. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4026. if ( cosTheta2Sq < 0.0 ) {
  4027. return vec3( 1.0 );
  4028. }
  4029. float cosTheta2 = sqrt( cosTheta2Sq );
  4030. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4031. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4032. float T121 = 1.0 - R12;
  4033. float phi12 = 0.0;
  4034. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4035. float phi21 = PI - phi12;
  4036. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4037. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4038. vec3 phi23 = vec3( 0.0 );
  4039. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4040. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4041. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4042. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4043. vec3 phi = vec3( phi21 ) + phi23;
  4044. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4045. vec3 r123 = sqrt( R123 );
  4046. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4047. vec3 C0 = R12 + Rs;
  4048. I = C0;
  4049. vec3 Cm = Rs - T121;
  4050. for ( int m = 1; m <= 2; ++ m ) {
  4051. Cm *= r123;
  4052. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4053. I += Cm * Sm;
  4054. }
  4055. return max( I, vec3( 0.0 ) );
  4056. }
  4057. #endif`,lLe=`#ifdef USE_BUMPMAP
  4058. uniform sampler2D bumpMap;
  4059. uniform float bumpScale;
  4060. vec2 dHdxy_fwd() {
  4061. vec2 dSTdx = dFdx( vBumpMapUv );
  4062. vec2 dSTdy = dFdy( vBumpMapUv );
  4063. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4064. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4065. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4066. return vec2( dBx, dBy );
  4067. }
  4068. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4069. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4070. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4071. vec3 vN = surf_norm;
  4072. vec3 R1 = cross( vSigmaY, vN );
  4073. vec3 R2 = cross( vN, vSigmaX );
  4074. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4075. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4076. return normalize( abs( fDet ) * surf_norm - vGrad );
  4077. }
  4078. #endif`,cLe=`#if NUM_CLIPPING_PLANES > 0
  4079. vec4 plane;
  4080. #pragma unroll_loop_start
  4081. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4082. plane = clippingPlanes[ i ];
  4083. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4084. }
  4085. #pragma unroll_loop_end
  4086. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4087. bool clipped = true;
  4088. #pragma unroll_loop_start
  4089. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4090. plane = clippingPlanes[ i ];
  4091. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4092. }
  4093. #pragma unroll_loop_end
  4094. if ( clipped ) discard;
  4095. #endif
  4096. #endif`,uLe=`#if NUM_CLIPPING_PLANES > 0
  4097. varying vec3 vClipPosition;
  4098. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4099. #endif`,dLe=`#if NUM_CLIPPING_PLANES > 0
  4100. varying vec3 vClipPosition;
  4101. #endif`,hLe=`#if NUM_CLIPPING_PLANES > 0
  4102. vClipPosition = - mvPosition.xyz;
  4103. #endif`,fLe=`#if defined( USE_COLOR_ALPHA )
  4104. diffuseColor *= vColor;
  4105. #elif defined( USE_COLOR )
  4106. diffuseColor.rgb *= vColor;
  4107. #endif`,pLe=`#if defined( USE_COLOR_ALPHA )
  4108. varying vec4 vColor;
  4109. #elif defined( USE_COLOR )
  4110. varying vec3 vColor;
  4111. #endif`,mLe=`#if defined( USE_COLOR_ALPHA )
  4112. varying vec4 vColor;
  4113. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4114. varying vec3 vColor;
  4115. #endif`,gLe=`#if defined( USE_COLOR_ALPHA )
  4116. vColor = vec4( 1.0 );
  4117. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4118. vColor = vec3( 1.0 );
  4119. #endif
  4120. #ifdef USE_COLOR
  4121. vColor *= color;
  4122. #endif
  4123. #ifdef USE_INSTANCING_COLOR
  4124. vColor.xyz *= instanceColor.xyz;
  4125. #endif`,xLe=`#define PI 3.141592653589793
  4126. #define PI2 6.283185307179586
  4127. #define PI_HALF 1.5707963267948966
  4128. #define RECIPROCAL_PI 0.3183098861837907
  4129. #define RECIPROCAL_PI2 0.15915494309189535
  4130. #define EPSILON 1e-6
  4131. #ifndef saturate
  4132. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4133. #endif
  4134. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4135. float pow2( const in float x ) { return x*x; }
  4136. vec3 pow2( const in vec3 x ) { return x*x; }
  4137. float pow3( const in float x ) { return x*x*x; }
  4138. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4139. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4140. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4141. highp float rand( const in vec2 uv ) {
  4142. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4143. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4144. return fract( sin( sn ) * c );
  4145. }
  4146. #ifdef HIGH_PRECISION
  4147. float precisionSafeLength( vec3 v ) { return length( v ); }
  4148. #else
  4149. float precisionSafeLength( vec3 v ) {
  4150. float maxComponent = max3( abs( v ) );
  4151. return length( v / maxComponent ) * maxComponent;
  4152. }
  4153. #endif
  4154. struct IncidentLight {
  4155. vec3 color;
  4156. vec3 direction;
  4157. bool visible;
  4158. };
  4159. struct ReflectedLight {
  4160. vec3 directDiffuse;
  4161. vec3 directSpecular;
  4162. vec3 indirectDiffuse;
  4163. vec3 indirectSpecular;
  4164. };
  4165. #ifdef USE_ALPHAHASH
  4166. varying vec3 vPosition;
  4167. #endif
  4168. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4169. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4170. }
  4171. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4172. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4173. }
  4174. mat3 transposeMat3( const in mat3 m ) {
  4175. mat3 tmp;
  4176. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4177. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4178. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4179. return tmp;
  4180. }
  4181. float luminance( const in vec3 rgb ) {
  4182. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4183. return dot( weights, rgb );
  4184. }
  4185. bool isPerspectiveMatrix( mat4 m ) {
  4186. return m[ 2 ][ 3 ] == - 1.0;
  4187. }
  4188. vec2 equirectUv( in vec3 dir ) {
  4189. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4190. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4191. return vec2( u, v );
  4192. }
  4193. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4194. return RECIPROCAL_PI * diffuseColor;
  4195. }
  4196. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4197. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4198. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4199. }
  4200. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4201. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4202. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4203. } // validated`,bLe=`#ifdef ENVMAP_TYPE_CUBE_UV
  4204. #define cubeUV_minMipLevel 4.0
  4205. #define cubeUV_minTileSize 16.0
  4206. float getFace( vec3 direction ) {
  4207. vec3 absDirection = abs( direction );
  4208. float face = - 1.0;
  4209. if ( absDirection.x > absDirection.z ) {
  4210. if ( absDirection.x > absDirection.y )
  4211. face = direction.x > 0.0 ? 0.0 : 3.0;
  4212. else
  4213. face = direction.y > 0.0 ? 1.0 : 4.0;
  4214. } else {
  4215. if ( absDirection.z > absDirection.y )
  4216. face = direction.z > 0.0 ? 2.0 : 5.0;
  4217. else
  4218. face = direction.y > 0.0 ? 1.0 : 4.0;
  4219. }
  4220. return face;
  4221. }
  4222. vec2 getUV( vec3 direction, float face ) {
  4223. vec2 uv;
  4224. if ( face == 0.0 ) {
  4225. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4226. } else if ( face == 1.0 ) {
  4227. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4228. } else if ( face == 2.0 ) {
  4229. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4230. } else if ( face == 3.0 ) {
  4231. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4232. } else if ( face == 4.0 ) {
  4233. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4234. } else {
  4235. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4236. }
  4237. return 0.5 * ( uv + 1.0 );
  4238. }
  4239. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4240. float face = getFace( direction );
  4241. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4242. mipInt = max( mipInt, cubeUV_minMipLevel );
  4243. float faceSize = exp2( mipInt );
  4244. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4245. if ( face > 2.0 ) {
  4246. uv.y += faceSize;
  4247. face -= 3.0;
  4248. }
  4249. uv.x += face * faceSize;
  4250. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4251. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4252. uv.x *= CUBEUV_TEXEL_WIDTH;
  4253. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4254. #ifdef texture2DGradEXT
  4255. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4256. #else
  4257. return texture2D( envMap, uv ).rgb;
  4258. #endif
  4259. }
  4260. #define cubeUV_r0 1.0
  4261. #define cubeUV_v0 0.339
  4262. #define cubeUV_m0 - 2.0
  4263. #define cubeUV_r1 0.8
  4264. #define cubeUV_v1 0.276
  4265. #define cubeUV_m1 - 1.0
  4266. #define cubeUV_r4 0.4
  4267. #define cubeUV_v4 0.046
  4268. #define cubeUV_m4 2.0
  4269. #define cubeUV_r5 0.305
  4270. #define cubeUV_v5 0.016
  4271. #define cubeUV_m5 3.0
  4272. #define cubeUV_r6 0.21
  4273. #define cubeUV_v6 0.0038
  4274. #define cubeUV_m6 4.0
  4275. float roughnessToMip( float roughness ) {
  4276. float mip = 0.0;
  4277. if ( roughness >= cubeUV_r1 ) {
  4278. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4279. } else if ( roughness >= cubeUV_r4 ) {
  4280. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4281. } else if ( roughness >= cubeUV_r5 ) {
  4282. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4283. } else if ( roughness >= cubeUV_r6 ) {
  4284. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4285. } else {
  4286. mip = - 2.0 * log2( 1.16 * roughness ); }
  4287. return mip;
  4288. }
  4289. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4290. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4291. float mipF = fract( mip );
  4292. float mipInt = floor( mip );
  4293. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4294. if ( mipF == 0.0 ) {
  4295. return vec4( color0, 1.0 );
  4296. } else {
  4297. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4298. return vec4( mix( color0, color1, mipF ), 1.0 );
  4299. }
  4300. }
  4301. #endif`,yLe=`vec3 transformedNormal = objectNormal;
  4302. #ifdef USE_TANGENT
  4303. vec3 transformedTangent = objectTangent;
  4304. #endif
  4305. #ifdef USE_BATCHING
  4306. mat3 bm = mat3( batchingMatrix );
  4307. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4308. transformedNormal = bm * transformedNormal;
  4309. #ifdef USE_TANGENT
  4310. transformedTangent = bm * transformedTangent;
  4311. #endif
  4312. #endif
  4313. #ifdef USE_INSTANCING
  4314. mat3 im = mat3( instanceMatrix );
  4315. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4316. transformedNormal = im * transformedNormal;
  4317. #ifdef USE_TANGENT
  4318. transformedTangent = im * transformedTangent;
  4319. #endif
  4320. #endif
  4321. transformedNormal = normalMatrix * transformedNormal;
  4322. #ifdef FLIP_SIDED
  4323. transformedNormal = - transformedNormal;
  4324. #endif
  4325. #ifdef USE_TANGENT
  4326. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4327. #ifdef FLIP_SIDED
  4328. transformedTangent = - transformedTangent;
  4329. #endif
  4330. #endif`,vLe=`#ifdef USE_DISPLACEMENTMAP
  4331. uniform sampler2D displacementMap;
  4332. uniform float displacementScale;
  4333. uniform float displacementBias;
  4334. #endif`,_Le=`#ifdef USE_DISPLACEMENTMAP
  4335. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4336. #endif`,wLe=`#ifdef USE_EMISSIVEMAP
  4337. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4338. totalEmissiveRadiance *= emissiveColor.rgb;
  4339. #endif`,SLe=`#ifdef USE_EMISSIVEMAP
  4340. uniform sampler2D emissiveMap;
  4341. #endif`,MLe="gl_FragColor = linearToOutputTexel( gl_FragColor );",ELe=`
  4342. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4343. vec3( 0.8224621, 0.177538, 0.0 ),
  4344. vec3( 0.0331941, 0.9668058, 0.0 ),
  4345. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4346. );
  4347. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4348. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4349. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4350. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4351. );
  4352. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4353. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4354. }
  4355. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4356. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4357. }
  4358. vec4 LinearTransferOETF( in vec4 value ) {
  4359. return value;
  4360. }
  4361. vec4 sRGBTransferOETF( in vec4 value ) {
  4362. 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 );
  4363. }
  4364. vec4 LinearToLinear( in vec4 value ) {
  4365. return value;
  4366. }
  4367. vec4 LinearTosRGB( in vec4 value ) {
  4368. return sRGBTransferOETF( value );
  4369. }`,ALe=`#ifdef USE_ENVMAP
  4370. #ifdef ENV_WORLDPOS
  4371. vec3 cameraToFrag;
  4372. if ( isOrthographic ) {
  4373. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4374. } else {
  4375. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4376. }
  4377. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4378. #ifdef ENVMAP_MODE_REFLECTION
  4379. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4380. #else
  4381. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4382. #endif
  4383. #else
  4384. vec3 reflectVec = vReflect;
  4385. #endif
  4386. #ifdef ENVMAP_TYPE_CUBE
  4387. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4388. #else
  4389. vec4 envColor = vec4( 0.0 );
  4390. #endif
  4391. #ifdef ENVMAP_BLENDING_MULTIPLY
  4392. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4393. #elif defined( ENVMAP_BLENDING_MIX )
  4394. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4395. #elif defined( ENVMAP_BLENDING_ADD )
  4396. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4397. #endif
  4398. #endif`,TLe=`#ifdef USE_ENVMAP
  4399. uniform float envMapIntensity;
  4400. uniform float flipEnvMap;
  4401. #ifdef ENVMAP_TYPE_CUBE
  4402. uniform samplerCube envMap;
  4403. #else
  4404. uniform sampler2D envMap;
  4405. #endif
  4406. #endif`,CLe=`#ifdef USE_ENVMAP
  4407. uniform float reflectivity;
  4408. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4409. #define ENV_WORLDPOS
  4410. #endif
  4411. #ifdef ENV_WORLDPOS
  4412. varying vec3 vWorldPosition;
  4413. uniform float refractionRatio;
  4414. #else
  4415. varying vec3 vReflect;
  4416. #endif
  4417. #endif`,NLe=`#ifdef USE_ENVMAP
  4418. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4419. #define ENV_WORLDPOS
  4420. #endif
  4421. #ifdef ENV_WORLDPOS
  4422. varying vec3 vWorldPosition;
  4423. #else
  4424. varying vec3 vReflect;
  4425. uniform float refractionRatio;
  4426. #endif
  4427. #endif`,kLe=`#ifdef USE_ENVMAP
  4428. #ifdef ENV_WORLDPOS
  4429. vWorldPosition = worldPosition.xyz;
  4430. #else
  4431. vec3 cameraToVertex;
  4432. if ( isOrthographic ) {
  4433. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4434. } else {
  4435. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4436. }
  4437. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4438. #ifdef ENVMAP_MODE_REFLECTION
  4439. vReflect = reflect( cameraToVertex, worldNormal );
  4440. #else
  4441. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4442. #endif
  4443. #endif
  4444. #endif`,PLe=`#ifdef USE_FOG
  4445. vFogDepth = - mvPosition.z;
  4446. #endif`,RLe=`#ifdef USE_FOG
  4447. varying float vFogDepth;
  4448. #endif`,DLe=`#ifdef USE_FOG
  4449. #ifdef FOG_EXP2
  4450. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4451. #else
  4452. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4453. #endif
  4454. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4455. #endif`,jLe=`#ifdef USE_FOG
  4456. uniform vec3 fogColor;
  4457. varying float vFogDepth;
  4458. #ifdef FOG_EXP2
  4459. uniform float fogDensity;
  4460. #else
  4461. uniform float fogNear;
  4462. uniform float fogFar;
  4463. #endif
  4464. #endif`,OLe=`#ifdef USE_GRADIENTMAP
  4465. uniform sampler2D gradientMap;
  4466. #endif
  4467. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4468. float dotNL = dot( normal, lightDirection );
  4469. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4470. #ifdef USE_GRADIENTMAP
  4471. return vec3( texture2D( gradientMap, coord ).r );
  4472. #else
  4473. vec2 fw = fwidth( coord ) * 0.5;
  4474. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4475. #endif
  4476. }`,LLe=`#ifdef USE_LIGHTMAP
  4477. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4478. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4479. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4480. #endif`,ILe=`#ifdef USE_LIGHTMAP
  4481. uniform sampler2D lightMap;
  4482. uniform float lightMapIntensity;
  4483. #endif`,FLe=`LambertMaterial material;
  4484. material.diffuseColor = diffuseColor.rgb;
  4485. material.specularStrength = specularStrength;`,ULe=`varying vec3 vViewPosition;
  4486. struct LambertMaterial {
  4487. vec3 diffuseColor;
  4488. float specularStrength;
  4489. };
  4490. 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 ) {
  4491. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4492. vec3 irradiance = dotNL * directLight.color;
  4493. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4494. }
  4495. 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 ) {
  4496. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4497. }
  4498. #define RE_Direct RE_Direct_Lambert
  4499. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,zLe=`uniform bool receiveShadow;
  4500. uniform vec3 ambientLightColor;
  4501. #if defined( USE_LIGHT_PROBES )
  4502. uniform vec3 lightProbe[ 9 ];
  4503. #endif
  4504. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4505. float x = normal.x, y = normal.y, z = normal.z;
  4506. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4507. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4508. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4509. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4510. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4511. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4512. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4513. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4514. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4515. return result;
  4516. }
  4517. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4518. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4519. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4520. return irradiance;
  4521. }
  4522. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4523. vec3 irradiance = ambientLightColor;
  4524. return irradiance;
  4525. }
  4526. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4527. #if defined ( LEGACY_LIGHTS )
  4528. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4529. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4530. }
  4531. return 1.0;
  4532. #else
  4533. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4534. if ( cutoffDistance > 0.0 ) {
  4535. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4536. }
  4537. return distanceFalloff;
  4538. #endif
  4539. }
  4540. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4541. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4542. }
  4543. #if NUM_DIR_LIGHTS > 0
  4544. struct DirectionalLight {
  4545. vec3 direction;
  4546. vec3 color;
  4547. };
  4548. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4549. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4550. light.color = directionalLight.color;
  4551. light.direction = directionalLight.direction;
  4552. light.visible = true;
  4553. }
  4554. #endif
  4555. #if NUM_POINT_LIGHTS > 0
  4556. struct PointLight {
  4557. vec3 position;
  4558. vec3 color;
  4559. float distance;
  4560. float decay;
  4561. };
  4562. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4563. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4564. vec3 lVector = pointLight.position - geometryPosition;
  4565. light.direction = normalize( lVector );
  4566. float lightDistance = length( lVector );
  4567. light.color = pointLight.color;
  4568. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4569. light.visible = ( light.color != vec3( 0.0 ) );
  4570. }
  4571. #endif
  4572. #if NUM_SPOT_LIGHTS > 0
  4573. struct SpotLight {
  4574. vec3 position;
  4575. vec3 direction;
  4576. vec3 color;
  4577. float distance;
  4578. float decay;
  4579. float coneCos;
  4580. float penumbraCos;
  4581. };
  4582. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4583. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4584. vec3 lVector = spotLight.position - geometryPosition;
  4585. light.direction = normalize( lVector );
  4586. float angleCos = dot( light.direction, spotLight.direction );
  4587. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4588. if ( spotAttenuation > 0.0 ) {
  4589. float lightDistance = length( lVector );
  4590. light.color = spotLight.color * spotAttenuation;
  4591. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4592. light.visible = ( light.color != vec3( 0.0 ) );
  4593. } else {
  4594. light.color = vec3( 0.0 );
  4595. light.visible = false;
  4596. }
  4597. }
  4598. #endif
  4599. #if NUM_RECT_AREA_LIGHTS > 0
  4600. struct RectAreaLight {
  4601. vec3 color;
  4602. vec3 position;
  4603. vec3 halfWidth;
  4604. vec3 halfHeight;
  4605. };
  4606. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4607. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4608. #endif
  4609. #if NUM_HEMI_LIGHTS > 0
  4610. struct HemisphereLight {
  4611. vec3 direction;
  4612. vec3 skyColor;
  4613. vec3 groundColor;
  4614. };
  4615. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4616. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4617. float dotNL = dot( normal, hemiLight.direction );
  4618. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4619. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4620. return irradiance;
  4621. }
  4622. #endif`,BLe=`#ifdef USE_ENVMAP
  4623. vec3 getIBLIrradiance( const in vec3 normal ) {
  4624. #ifdef ENVMAP_TYPE_CUBE_UV
  4625. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4626. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4627. return PI * envMapColor.rgb * envMapIntensity;
  4628. #else
  4629. return vec3( 0.0 );
  4630. #endif
  4631. }
  4632. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4633. #ifdef ENVMAP_TYPE_CUBE_UV
  4634. vec3 reflectVec = reflect( - viewDir, normal );
  4635. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4636. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4637. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4638. return envMapColor.rgb * envMapIntensity;
  4639. #else
  4640. return vec3( 0.0 );
  4641. #endif
  4642. }
  4643. #ifdef USE_ANISOTROPY
  4644. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4645. #ifdef ENVMAP_TYPE_CUBE_UV
  4646. vec3 bentNormal = cross( bitangent, viewDir );
  4647. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4648. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4649. return getIBLRadiance( viewDir, bentNormal, roughness );
  4650. #else
  4651. return vec3( 0.0 );
  4652. #endif
  4653. }
  4654. #endif
  4655. #endif`,HLe=`ToonMaterial material;
  4656. material.diffuseColor = diffuseColor.rgb;`,$Le=`varying vec3 vViewPosition;
  4657. struct ToonMaterial {
  4658. vec3 diffuseColor;
  4659. };
  4660. 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 ) {
  4661. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4662. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4663. }
  4664. 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 ) {
  4665. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4666. }
  4667. #define RE_Direct RE_Direct_Toon
  4668. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,VLe=`BlinnPhongMaterial material;
  4669. material.diffuseColor = diffuseColor.rgb;
  4670. material.specularColor = specular;
  4671. material.specularShininess = shininess;
  4672. material.specularStrength = specularStrength;`,GLe=`varying vec3 vViewPosition;
  4673. struct BlinnPhongMaterial {
  4674. vec3 diffuseColor;
  4675. vec3 specularColor;
  4676. float specularShininess;
  4677. float specularStrength;
  4678. };
  4679. 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 ) {
  4680. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4681. vec3 irradiance = dotNL * directLight.color;
  4682. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4683. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4684. }
  4685. 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 ) {
  4686. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4687. }
  4688. #define RE_Direct RE_Direct_BlinnPhong
  4689. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,WLe=`PhysicalMaterial material;
  4690. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4691. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4692. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4693. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4694. material.roughness = min( material.roughness, 1.0 );
  4695. #ifdef IOR
  4696. material.ior = ior;
  4697. #ifdef USE_SPECULAR
  4698. float specularIntensityFactor = specularIntensity;
  4699. vec3 specularColorFactor = specularColor;
  4700. #ifdef USE_SPECULAR_COLORMAP
  4701. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4702. #endif
  4703. #ifdef USE_SPECULAR_INTENSITYMAP
  4704. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4705. #endif
  4706. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4707. #else
  4708. float specularIntensityFactor = 1.0;
  4709. vec3 specularColorFactor = vec3( 1.0 );
  4710. material.specularF90 = 1.0;
  4711. #endif
  4712. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4713. #else
  4714. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4715. material.specularF90 = 1.0;
  4716. #endif
  4717. #ifdef USE_CLEARCOAT
  4718. material.clearcoat = clearcoat;
  4719. material.clearcoatRoughness = clearcoatRoughness;
  4720. material.clearcoatF0 = vec3( 0.04 );
  4721. material.clearcoatF90 = 1.0;
  4722. #ifdef USE_CLEARCOATMAP
  4723. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4724. #endif
  4725. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4726. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4727. #endif
  4728. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4729. material.clearcoatRoughness += geometryRoughness;
  4730. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4731. #endif
  4732. #ifdef USE_IRIDESCENCE
  4733. material.iridescence = iridescence;
  4734. material.iridescenceIOR = iridescenceIOR;
  4735. #ifdef USE_IRIDESCENCEMAP
  4736. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4737. #endif
  4738. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4739. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4740. #else
  4741. material.iridescenceThickness = iridescenceThicknessMaximum;
  4742. #endif
  4743. #endif
  4744. #ifdef USE_SHEEN
  4745. material.sheenColor = sheenColor;
  4746. #ifdef USE_SHEEN_COLORMAP
  4747. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4748. #endif
  4749. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4750. #ifdef USE_SHEEN_ROUGHNESSMAP
  4751. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4752. #endif
  4753. #endif
  4754. #ifdef USE_ANISOTROPY
  4755. #ifdef USE_ANISOTROPYMAP
  4756. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4757. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4758. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4759. #else
  4760. vec2 anisotropyV = anisotropyVector;
  4761. #endif
  4762. material.anisotropy = length( anisotropyV );
  4763. if( material.anisotropy == 0.0 ) {
  4764. anisotropyV = vec2( 1.0, 0.0 );
  4765. } else {
  4766. anisotropyV /= material.anisotropy;
  4767. material.anisotropy = saturate( material.anisotropy );
  4768. }
  4769. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4770. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4771. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4772. #endif`,qLe=`struct PhysicalMaterial {
  4773. vec3 diffuseColor;
  4774. float roughness;
  4775. vec3 specularColor;
  4776. float specularF90;
  4777. #ifdef USE_CLEARCOAT
  4778. float clearcoat;
  4779. float clearcoatRoughness;
  4780. vec3 clearcoatF0;
  4781. float clearcoatF90;
  4782. #endif
  4783. #ifdef USE_IRIDESCENCE
  4784. float iridescence;
  4785. float iridescenceIOR;
  4786. float iridescenceThickness;
  4787. vec3 iridescenceFresnel;
  4788. vec3 iridescenceF0;
  4789. #endif
  4790. #ifdef USE_SHEEN
  4791. vec3 sheenColor;
  4792. float sheenRoughness;
  4793. #endif
  4794. #ifdef IOR
  4795. float ior;
  4796. #endif
  4797. #ifdef USE_TRANSMISSION
  4798. float transmission;
  4799. float transmissionAlpha;
  4800. float thickness;
  4801. float attenuationDistance;
  4802. vec3 attenuationColor;
  4803. #endif
  4804. #ifdef USE_ANISOTROPY
  4805. float anisotropy;
  4806. float alphaT;
  4807. vec3 anisotropyT;
  4808. vec3 anisotropyB;
  4809. #endif
  4810. };
  4811. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4812. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4813. vec3 sheenSpecularDirect = vec3( 0.0 );
  4814. vec3 sheenSpecularIndirect = vec3(0.0 );
  4815. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4816. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4817. float x2 = x * x;
  4818. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4819. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4820. }
  4821. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4822. float a2 = pow2( alpha );
  4823. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4824. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4825. return 0.5 / max( gv + gl, EPSILON );
  4826. }
  4827. float D_GGX( const in float alpha, const in float dotNH ) {
  4828. float a2 = pow2( alpha );
  4829. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4830. return RECIPROCAL_PI * a2 / pow2( denom );
  4831. }
  4832. #ifdef USE_ANISOTROPY
  4833. 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 ) {
  4834. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4835. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4836. float v = 0.5 / ( gv + gl );
  4837. return saturate(v);
  4838. }
  4839. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4840. float a2 = alphaT * alphaB;
  4841. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4842. highp float v2 = dot( v, v );
  4843. float w2 = a2 / v2;
  4844. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4845. }
  4846. #endif
  4847. #ifdef USE_CLEARCOAT
  4848. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4849. vec3 f0 = material.clearcoatF0;
  4850. float f90 = material.clearcoatF90;
  4851. float roughness = material.clearcoatRoughness;
  4852. float alpha = pow2( roughness );
  4853. vec3 halfDir = normalize( lightDir + viewDir );
  4854. float dotNL = saturate( dot( normal, lightDir ) );
  4855. float dotNV = saturate( dot( normal, viewDir ) );
  4856. float dotNH = saturate( dot( normal, halfDir ) );
  4857. float dotVH = saturate( dot( viewDir, halfDir ) );
  4858. vec3 F = F_Schlick( f0, f90, dotVH );
  4859. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4860. float D = D_GGX( alpha, dotNH );
  4861. return F * ( V * D );
  4862. }
  4863. #endif
  4864. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4865. vec3 f0 = material.specularColor;
  4866. float f90 = material.specularF90;
  4867. float roughness = material.roughness;
  4868. float alpha = pow2( roughness );
  4869. vec3 halfDir = normalize( lightDir + viewDir );
  4870. float dotNL = saturate( dot( normal, lightDir ) );
  4871. float dotNV = saturate( dot( normal, viewDir ) );
  4872. float dotNH = saturate( dot( normal, halfDir ) );
  4873. float dotVH = saturate( dot( viewDir, halfDir ) );
  4874. vec3 F = F_Schlick( f0, f90, dotVH );
  4875. #ifdef USE_IRIDESCENCE
  4876. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4877. #endif
  4878. #ifdef USE_ANISOTROPY
  4879. float dotTL = dot( material.anisotropyT, lightDir );
  4880. float dotTV = dot( material.anisotropyT, viewDir );
  4881. float dotTH = dot( material.anisotropyT, halfDir );
  4882. float dotBL = dot( material.anisotropyB, lightDir );
  4883. float dotBV = dot( material.anisotropyB, viewDir );
  4884. float dotBH = dot( material.anisotropyB, halfDir );
  4885. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4886. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4887. #else
  4888. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4889. float D = D_GGX( alpha, dotNH );
  4890. #endif
  4891. return F * ( V * D );
  4892. }
  4893. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4894. const float LUT_SIZE = 64.0;
  4895. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4896. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4897. float dotNV = saturate( dot( N, V ) );
  4898. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4899. uv = uv * LUT_SCALE + LUT_BIAS;
  4900. return uv;
  4901. }
  4902. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4903. float l = length( f );
  4904. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4905. }
  4906. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4907. float x = dot( v1, v2 );
  4908. float y = abs( x );
  4909. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4910. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4911. float v = a / b;
  4912. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4913. return cross( v1, v2 ) * theta_sintheta;
  4914. }
  4915. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4916. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4917. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4918. vec3 lightNormal = cross( v1, v2 );
  4919. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4920. vec3 T1, T2;
  4921. T1 = normalize( V - N * dot( V, N ) );
  4922. T2 = - cross( N, T1 );
  4923. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4924. vec3 coords[ 4 ];
  4925. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4926. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4927. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4928. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4929. coords[ 0 ] = normalize( coords[ 0 ] );
  4930. coords[ 1 ] = normalize( coords[ 1 ] );
  4931. coords[ 2 ] = normalize( coords[ 2 ] );
  4932. coords[ 3 ] = normalize( coords[ 3 ] );
  4933. vec3 vectorFormFactor = vec3( 0.0 );
  4934. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4935. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4936. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4937. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4938. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4939. return vec3( result );
  4940. }
  4941. #if defined( USE_SHEEN )
  4942. float D_Charlie( float roughness, float dotNH ) {
  4943. float alpha = pow2( roughness );
  4944. float invAlpha = 1.0 / alpha;
  4945. float cos2h = dotNH * dotNH;
  4946. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4947. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4948. }
  4949. float V_Neubelt( float dotNV, float dotNL ) {
  4950. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4951. }
  4952. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4953. vec3 halfDir = normalize( lightDir + viewDir );
  4954. float dotNL = saturate( dot( normal, lightDir ) );
  4955. float dotNV = saturate( dot( normal, viewDir ) );
  4956. float dotNH = saturate( dot( normal, halfDir ) );
  4957. float D = D_Charlie( sheenRoughness, dotNH );
  4958. float V = V_Neubelt( dotNV, dotNL );
  4959. return sheenColor * ( D * V );
  4960. }
  4961. #endif
  4962. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4963. float dotNV = saturate( dot( normal, viewDir ) );
  4964. float r2 = roughness * roughness;
  4965. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4966. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4967. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4968. return saturate( DG * RECIPROCAL_PI );
  4969. }
  4970. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4971. float dotNV = saturate( dot( normal, viewDir ) );
  4972. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4973. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4974. vec4 r = roughness * c0 + c1;
  4975. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4976. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4977. return fab;
  4978. }
  4979. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4980. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4981. return specularColor * fab.x + specularF90 * fab.y;
  4982. }
  4983. #ifdef USE_IRIDESCENCE
  4984. 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 ) {
  4985. #else
  4986. 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 ) {
  4987. #endif
  4988. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4989. #ifdef USE_IRIDESCENCE
  4990. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4991. #else
  4992. vec3 Fr = specularColor;
  4993. #endif
  4994. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4995. float Ess = fab.x + fab.y;
  4996. float Ems = 1.0 - Ess;
  4997. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4998. singleScatter += FssEss;
  4999. multiScatter += Fms * Ems;
  5000. }
  5001. #if NUM_RECT_AREA_LIGHTS > 0
  5002. 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 ) {
  5003. vec3 normal = geometryNormal;
  5004. vec3 viewDir = geometryViewDir;
  5005. vec3 position = geometryPosition;
  5006. vec3 lightPos = rectAreaLight.position;
  5007. vec3 halfWidth = rectAreaLight.halfWidth;
  5008. vec3 halfHeight = rectAreaLight.halfHeight;
  5009. vec3 lightColor = rectAreaLight.color;
  5010. float roughness = material.roughness;
  5011. vec3 rectCoords[ 4 ];
  5012. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5013. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5014. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5015. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5016. vec4 t1 = texture2D( ltc_1, uv );
  5017. vec4 t2 = texture2D( ltc_2, uv );
  5018. mat3 mInv = mat3(
  5019. vec3( t1.x, 0, t1.y ),
  5020. vec3( 0, 1, 0 ),
  5021. vec3( t1.z, 0, t1.w )
  5022. );
  5023. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5024. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5025. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5026. }
  5027. #endif
  5028. 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 ) {
  5029. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5030. vec3 irradiance = dotNL * directLight.color;
  5031. #ifdef USE_CLEARCOAT
  5032. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5033. vec3 ccIrradiance = dotNLcc * directLight.color;
  5034. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5035. #endif
  5036. #ifdef USE_SHEEN
  5037. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5038. #endif
  5039. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5040. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5041. }
  5042. 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 ) {
  5043. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5044. }
  5045. 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) {
  5046. #ifdef USE_CLEARCOAT
  5047. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5048. #endif
  5049. #ifdef USE_SHEEN
  5050. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5051. #endif
  5052. vec3 singleScattering = vec3( 0.0 );
  5053. vec3 multiScattering = vec3( 0.0 );
  5054. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5055. #ifdef USE_IRIDESCENCE
  5056. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5057. #else
  5058. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5059. #endif
  5060. vec3 totalScattering = singleScattering + multiScattering;
  5061. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5062. reflectedLight.indirectSpecular += radiance * singleScattering;
  5063. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5064. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5065. }
  5066. #define RE_Direct RE_Direct_Physical
  5067. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5068. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5069. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5070. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5071. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5072. }`,KLe=`
  5073. vec3 geometryPosition = - vViewPosition;
  5074. vec3 geometryNormal = normal;
  5075. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5076. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5077. #ifdef USE_CLEARCOAT
  5078. geometryClearcoatNormal = clearcoatNormal;
  5079. #endif
  5080. #ifdef USE_IRIDESCENCE
  5081. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5082. if ( material.iridescenceThickness == 0.0 ) {
  5083. material.iridescence = 0.0;
  5084. } else {
  5085. material.iridescence = saturate( material.iridescence );
  5086. }
  5087. if ( material.iridescence > 0.0 ) {
  5088. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5089. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5090. }
  5091. #endif
  5092. IncidentLight directLight;
  5093. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5094. PointLight pointLight;
  5095. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5096. PointLightShadow pointLightShadow;
  5097. #endif
  5098. #pragma unroll_loop_start
  5099. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5100. pointLight = pointLights[ i ];
  5101. getPointLightInfo( pointLight, geometryPosition, directLight );
  5102. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5103. pointLightShadow = pointLightShadows[ i ];
  5104. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5105. #endif
  5106. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5107. }
  5108. #pragma unroll_loop_end
  5109. #endif
  5110. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5111. SpotLight spotLight;
  5112. vec4 spotColor;
  5113. vec3 spotLightCoord;
  5114. bool inSpotLightMap;
  5115. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5116. SpotLightShadow spotLightShadow;
  5117. #endif
  5118. #pragma unroll_loop_start
  5119. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5120. spotLight = spotLights[ i ];
  5121. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5122. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5123. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5124. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5125. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5126. #else
  5127. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5128. #endif
  5129. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5130. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5131. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5132. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5133. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5134. #endif
  5135. #undef SPOT_LIGHT_MAP_INDEX
  5136. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5137. spotLightShadow = spotLightShadows[ i ];
  5138. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5139. #endif
  5140. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5141. }
  5142. #pragma unroll_loop_end
  5143. #endif
  5144. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5145. DirectionalLight directionalLight;
  5146. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5147. DirectionalLightShadow directionalLightShadow;
  5148. #endif
  5149. #pragma unroll_loop_start
  5150. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5151. directionalLight = directionalLights[ i ];
  5152. getDirectionalLightInfo( directionalLight, directLight );
  5153. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5154. directionalLightShadow = directionalLightShadows[ i ];
  5155. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5156. #endif
  5157. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5158. }
  5159. #pragma unroll_loop_end
  5160. #endif
  5161. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5162. RectAreaLight rectAreaLight;
  5163. #pragma unroll_loop_start
  5164. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5165. rectAreaLight = rectAreaLights[ i ];
  5166. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5167. }
  5168. #pragma unroll_loop_end
  5169. #endif
  5170. #if defined( RE_IndirectDiffuse )
  5171. vec3 iblIrradiance = vec3( 0.0 );
  5172. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5173. #if defined( USE_LIGHT_PROBES )
  5174. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5175. #endif
  5176. #if ( NUM_HEMI_LIGHTS > 0 )
  5177. #pragma unroll_loop_start
  5178. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5179. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5180. }
  5181. #pragma unroll_loop_end
  5182. #endif
  5183. #endif
  5184. #if defined( RE_IndirectSpecular )
  5185. vec3 radiance = vec3( 0.0 );
  5186. vec3 clearcoatRadiance = vec3( 0.0 );
  5187. #endif`,XLe=`#if defined( RE_IndirectDiffuse )
  5188. #ifdef USE_LIGHTMAP
  5189. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5190. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5191. irradiance += lightMapIrradiance;
  5192. #endif
  5193. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5194. iblIrradiance += getIBLIrradiance( geometryNormal );
  5195. #endif
  5196. #endif
  5197. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5198. #ifdef USE_ANISOTROPY
  5199. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5200. #else
  5201. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5202. #endif
  5203. #ifdef USE_CLEARCOAT
  5204. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5205. #endif
  5206. #endif`,YLe=`#if defined( RE_IndirectDiffuse )
  5207. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5208. #endif
  5209. #if defined( RE_IndirectSpecular )
  5210. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5211. #endif`,ZLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5212. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5213. #endif`,QLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5214. uniform float logDepthBufFC;
  5215. varying float vFragDepth;
  5216. varying float vIsPerspective;
  5217. #endif`,JLe=`#ifdef USE_LOGDEPTHBUF
  5218. #ifdef USE_LOGDEPTHBUF_EXT
  5219. varying float vFragDepth;
  5220. varying float vIsPerspective;
  5221. #else
  5222. uniform float logDepthBufFC;
  5223. #endif
  5224. #endif`,e4e=`#ifdef USE_LOGDEPTHBUF
  5225. #ifdef USE_LOGDEPTHBUF_EXT
  5226. vFragDepth = 1.0 + gl_Position.w;
  5227. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5228. #else
  5229. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5230. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5231. gl_Position.z *= gl_Position.w;
  5232. }
  5233. #endif
  5234. #endif`,t4e=`#ifdef USE_MAP
  5235. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5236. #ifdef DECODE_VIDEO_TEXTURE
  5237. 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 );
  5238. #endif
  5239. diffuseColor *= sampledDiffuseColor;
  5240. #endif`,n4e=`#ifdef USE_MAP
  5241. uniform sampler2D map;
  5242. #endif`,r4e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5243. #if defined( USE_POINTS_UV )
  5244. vec2 uv = vUv;
  5245. #else
  5246. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5247. #endif
  5248. #endif
  5249. #ifdef USE_MAP
  5250. diffuseColor *= texture2D( map, uv );
  5251. #endif
  5252. #ifdef USE_ALPHAMAP
  5253. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5254. #endif`,i4e=`#if defined( USE_POINTS_UV )
  5255. varying vec2 vUv;
  5256. #else
  5257. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5258. uniform mat3 uvTransform;
  5259. #endif
  5260. #endif
  5261. #ifdef USE_MAP
  5262. uniform sampler2D map;
  5263. #endif
  5264. #ifdef USE_ALPHAMAP
  5265. uniform sampler2D alphaMap;
  5266. #endif`,a4e=`float metalnessFactor = metalness;
  5267. #ifdef USE_METALNESSMAP
  5268. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5269. metalnessFactor *= texelMetalness.b;
  5270. #endif`,s4e=`#ifdef USE_METALNESSMAP
  5271. uniform sampler2D metalnessMap;
  5272. #endif`,o4e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5273. vColor *= morphTargetBaseInfluence;
  5274. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5275. #if defined( USE_COLOR_ALPHA )
  5276. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5277. #elif defined( USE_COLOR )
  5278. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5279. #endif
  5280. }
  5281. #endif`,l4e=`#ifdef USE_MORPHNORMALS
  5282. objectNormal *= morphTargetBaseInfluence;
  5283. #ifdef MORPHTARGETS_TEXTURE
  5284. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5285. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5286. }
  5287. #else
  5288. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5289. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5290. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5291. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5292. #endif
  5293. #endif`,c4e=`#ifdef USE_MORPHTARGETS
  5294. uniform float morphTargetBaseInfluence;
  5295. #ifdef MORPHTARGETS_TEXTURE
  5296. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5297. uniform sampler2DArray morphTargetsTexture;
  5298. uniform ivec2 morphTargetsTextureSize;
  5299. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5300. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5301. int y = texelIndex / morphTargetsTextureSize.x;
  5302. int x = texelIndex - y * morphTargetsTextureSize.x;
  5303. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5304. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5305. }
  5306. #else
  5307. #ifndef USE_MORPHNORMALS
  5308. uniform float morphTargetInfluences[ 8 ];
  5309. #else
  5310. uniform float morphTargetInfluences[ 4 ];
  5311. #endif
  5312. #endif
  5313. #endif`,u4e=`#ifdef USE_MORPHTARGETS
  5314. transformed *= morphTargetBaseInfluence;
  5315. #ifdef MORPHTARGETS_TEXTURE
  5316. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5317. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5318. }
  5319. #else
  5320. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5321. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5322. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5323. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5324. #ifndef USE_MORPHNORMALS
  5325. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5326. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5327. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5328. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5329. #endif
  5330. #endif
  5331. #endif`,d4e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5332. #ifdef FLAT_SHADED
  5333. vec3 fdx = dFdx( vViewPosition );
  5334. vec3 fdy = dFdy( vViewPosition );
  5335. vec3 normal = normalize( cross( fdx, fdy ) );
  5336. #else
  5337. vec3 normal = normalize( vNormal );
  5338. #ifdef DOUBLE_SIDED
  5339. normal *= faceDirection;
  5340. #endif
  5341. #endif
  5342. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5343. #ifdef USE_TANGENT
  5344. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5345. #else
  5346. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5347. #if defined( USE_NORMALMAP )
  5348. vNormalMapUv
  5349. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5350. vClearcoatNormalMapUv
  5351. #else
  5352. vUv
  5353. #endif
  5354. );
  5355. #endif
  5356. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5357. tbn[0] *= faceDirection;
  5358. tbn[1] *= faceDirection;
  5359. #endif
  5360. #endif
  5361. #ifdef USE_CLEARCOAT_NORMALMAP
  5362. #ifdef USE_TANGENT
  5363. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5364. #else
  5365. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5366. #endif
  5367. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5368. tbn2[0] *= faceDirection;
  5369. tbn2[1] *= faceDirection;
  5370. #endif
  5371. #endif
  5372. vec3 nonPerturbedNormal = normal;`,h4e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5373. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5374. #ifdef FLIP_SIDED
  5375. normal = - normal;
  5376. #endif
  5377. #ifdef DOUBLE_SIDED
  5378. normal = normal * faceDirection;
  5379. #endif
  5380. normal = normalize( normalMatrix * normal );
  5381. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5382. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5383. mapN.xy *= normalScale;
  5384. normal = normalize( tbn * mapN );
  5385. #elif defined( USE_BUMPMAP )
  5386. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5387. #endif`,f4e=`#ifndef FLAT_SHADED
  5388. varying vec3 vNormal;
  5389. #ifdef USE_TANGENT
  5390. varying vec3 vTangent;
  5391. varying vec3 vBitangent;
  5392. #endif
  5393. #endif`,p4e=`#ifndef FLAT_SHADED
  5394. varying vec3 vNormal;
  5395. #ifdef USE_TANGENT
  5396. varying vec3 vTangent;
  5397. varying vec3 vBitangent;
  5398. #endif
  5399. #endif`,m4e=`#ifndef FLAT_SHADED
  5400. vNormal = normalize( transformedNormal );
  5401. #ifdef USE_TANGENT
  5402. vTangent = normalize( transformedTangent );
  5403. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5404. #endif
  5405. #endif`,g4e=`#ifdef USE_NORMALMAP
  5406. uniform sampler2D normalMap;
  5407. uniform vec2 normalScale;
  5408. #endif
  5409. #ifdef USE_NORMALMAP_OBJECTSPACE
  5410. uniform mat3 normalMatrix;
  5411. #endif
  5412. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5413. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5414. vec3 q0 = dFdx( eye_pos.xyz );
  5415. vec3 q1 = dFdy( eye_pos.xyz );
  5416. vec2 st0 = dFdx( uv.st );
  5417. vec2 st1 = dFdy( uv.st );
  5418. vec3 N = surf_norm;
  5419. vec3 q1perp = cross( q1, N );
  5420. vec3 q0perp = cross( N, q0 );
  5421. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5422. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5423. float det = max( dot( T, T ), dot( B, B ) );
  5424. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5425. return mat3( T * scale, B * scale, N );
  5426. }
  5427. #endif`,x4e=`#ifdef USE_CLEARCOAT
  5428. vec3 clearcoatNormal = nonPerturbedNormal;
  5429. #endif`,b4e=`#ifdef USE_CLEARCOAT_NORMALMAP
  5430. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5431. clearcoatMapN.xy *= clearcoatNormalScale;
  5432. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5433. #endif`,y4e=`#ifdef USE_CLEARCOATMAP
  5434. uniform sampler2D clearcoatMap;
  5435. #endif
  5436. #ifdef USE_CLEARCOAT_NORMALMAP
  5437. uniform sampler2D clearcoatNormalMap;
  5438. uniform vec2 clearcoatNormalScale;
  5439. #endif
  5440. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5441. uniform sampler2D clearcoatRoughnessMap;
  5442. #endif`,v4e=`#ifdef USE_IRIDESCENCEMAP
  5443. uniform sampler2D iridescenceMap;
  5444. #endif
  5445. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5446. uniform sampler2D iridescenceThicknessMap;
  5447. #endif`,_4e=`#ifdef OPAQUE
  5448. diffuseColor.a = 1.0;
  5449. #endif
  5450. #ifdef USE_TRANSMISSION
  5451. diffuseColor.a *= material.transmissionAlpha;
  5452. #endif
  5453. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w4e=`vec3 packNormalToRGB( const in vec3 normal ) {
  5454. return normalize( normal ) * 0.5 + 0.5;
  5455. }
  5456. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5457. return 2.0 * rgb.xyz - 1.0;
  5458. }
  5459. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5460. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5461. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5462. const float ShiftRight8 = 1. / 256.;
  5463. vec4 packDepthToRGBA( const in float v ) {
  5464. vec4 r = vec4( fract( v * PackFactors ), v );
  5465. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5466. }
  5467. float unpackRGBAToDepth( const in vec4 v ) {
  5468. return dot( v, UnpackFactors );
  5469. }
  5470. vec2 packDepthToRG( in highp float v ) {
  5471. return packDepthToRGBA( v ).yx;
  5472. }
  5473. float unpackRGToDepth( const in highp vec2 v ) {
  5474. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5475. }
  5476. vec4 pack2HalfToRGBA( vec2 v ) {
  5477. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5478. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5479. }
  5480. vec2 unpackRGBATo2Half( vec4 v ) {
  5481. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5482. }
  5483. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5484. return ( viewZ + near ) / ( near - far );
  5485. }
  5486. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5487. return depth * ( near - far ) - near;
  5488. }
  5489. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5490. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5491. }
  5492. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5493. return ( near * far ) / ( ( far - near ) * depth - far );
  5494. }`,S4e=`#ifdef PREMULTIPLIED_ALPHA
  5495. gl_FragColor.rgb *= gl_FragColor.a;
  5496. #endif`,M4e=`vec4 mvPosition = vec4( transformed, 1.0 );
  5497. #ifdef USE_BATCHING
  5498. mvPosition = batchingMatrix * mvPosition;
  5499. #endif
  5500. #ifdef USE_INSTANCING
  5501. mvPosition = instanceMatrix * mvPosition;
  5502. #endif
  5503. mvPosition = modelViewMatrix * mvPosition;
  5504. gl_Position = projectionMatrix * mvPosition;`,E4e=`#ifdef DITHERING
  5505. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5506. #endif`,A4e=`#ifdef DITHERING
  5507. vec3 dithering( vec3 color ) {
  5508. float grid_position = rand( gl_FragCoord.xy );
  5509. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5510. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5511. return color + dither_shift_RGB;
  5512. }
  5513. #endif`,T4e=`float roughnessFactor = roughness;
  5514. #ifdef USE_ROUGHNESSMAP
  5515. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5516. roughnessFactor *= texelRoughness.g;
  5517. #endif`,C4e=`#ifdef USE_ROUGHNESSMAP
  5518. uniform sampler2D roughnessMap;
  5519. #endif`,N4e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5520. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5521. #endif
  5522. #if NUM_SPOT_LIGHT_MAPS > 0
  5523. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5524. #endif
  5525. #ifdef USE_SHADOWMAP
  5526. #if NUM_DIR_LIGHT_SHADOWS > 0
  5527. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5528. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5529. struct DirectionalLightShadow {
  5530. float shadowBias;
  5531. float shadowNormalBias;
  5532. float shadowRadius;
  5533. vec2 shadowMapSize;
  5534. };
  5535. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5536. #endif
  5537. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5538. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5539. struct SpotLightShadow {
  5540. float shadowBias;
  5541. float shadowNormalBias;
  5542. float shadowRadius;
  5543. vec2 shadowMapSize;
  5544. };
  5545. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5546. #endif
  5547. #if NUM_POINT_LIGHT_SHADOWS > 0
  5548. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5549. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5550. struct PointLightShadow {
  5551. float shadowBias;
  5552. float shadowNormalBias;
  5553. float shadowRadius;
  5554. vec2 shadowMapSize;
  5555. float shadowCameraNear;
  5556. float shadowCameraFar;
  5557. };
  5558. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5559. #endif
  5560. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5561. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5562. }
  5563. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5564. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5565. }
  5566. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5567. float occlusion = 1.0;
  5568. vec2 distribution = texture2DDistribution( shadow, uv );
  5569. float hard_shadow = step( compare , distribution.x );
  5570. if (hard_shadow != 1.0 ) {
  5571. float distance = compare - distribution.x ;
  5572. float variance = max( 0.00000, distribution.y * distribution.y );
  5573. 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 );
  5574. }
  5575. return occlusion;
  5576. }
  5577. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5578. float shadow = 1.0;
  5579. shadowCoord.xyz /= shadowCoord.w;
  5580. shadowCoord.z += shadowBias;
  5581. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5582. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5583. if ( frustumTest ) {
  5584. #if defined( SHADOWMAP_TYPE_PCF )
  5585. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5586. float dx0 = - texelSize.x * shadowRadius;
  5587. float dy0 = - texelSize.y * shadowRadius;
  5588. float dx1 = + texelSize.x * shadowRadius;
  5589. float dy1 = + texelSize.y * shadowRadius;
  5590. float dx2 = dx0 / 2.0;
  5591. float dy2 = dy0 / 2.0;
  5592. float dx3 = dx1 / 2.0;
  5593. float dy3 = dy1 / 2.0;
  5594. shadow = (
  5595. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5596. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5597. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5598. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5599. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5600. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5601. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5602. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5603. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5604. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5605. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5606. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5607. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5608. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5609. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5610. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5611. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5612. ) * ( 1.0 / 17.0 );
  5613. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5614. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5615. float dx = texelSize.x;
  5616. float dy = texelSize.y;
  5617. vec2 uv = shadowCoord.xy;
  5618. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5619. uv -= f * texelSize;
  5620. shadow = (
  5621. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5622. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5623. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5624. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5625. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5626. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5627. f.x ) +
  5628. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5629. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5630. f.x ) +
  5631. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5632. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5633. f.y ) +
  5634. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5635. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5636. f.y ) +
  5637. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5638. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5639. f.x ),
  5640. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5641. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5642. f.x ),
  5643. f.y )
  5644. ) * ( 1.0 / 9.0 );
  5645. #elif defined( SHADOWMAP_TYPE_VSM )
  5646. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5647. #else
  5648. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5649. #endif
  5650. }
  5651. return shadow;
  5652. }
  5653. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5654. vec3 absV = abs( v );
  5655. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5656. absV *= scaleToCube;
  5657. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5658. vec2 planar = v.xy;
  5659. float almostATexel = 1.5 * texelSizeY;
  5660. float almostOne = 1.0 - almostATexel;
  5661. if ( absV.z >= almostOne ) {
  5662. if ( v.z > 0.0 )
  5663. planar.x = 4.0 - v.x;
  5664. } else if ( absV.x >= almostOne ) {
  5665. float signX = sign( v.x );
  5666. planar.x = v.z * signX + 2.0 * signX;
  5667. } else if ( absV.y >= almostOne ) {
  5668. float signY = sign( v.y );
  5669. planar.x = v.x + 2.0 * signY + 2.0;
  5670. planar.y = v.z * signY - 2.0;
  5671. }
  5672. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5673. }
  5674. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5675. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5676. vec3 lightToPosition = shadowCoord.xyz;
  5677. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5678. vec3 bd3D = normalize( lightToPosition );
  5679. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5680. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5681. return (
  5682. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5683. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5684. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5685. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5686. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5687. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5688. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5689. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5690. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5691. ) * ( 1.0 / 9.0 );
  5692. #else
  5693. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5694. #endif
  5695. }
  5696. #endif`,k4e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5697. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5698. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5699. #endif
  5700. #ifdef USE_SHADOWMAP
  5701. #if NUM_DIR_LIGHT_SHADOWS > 0
  5702. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5703. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5704. struct DirectionalLightShadow {
  5705. float shadowBias;
  5706. float shadowNormalBias;
  5707. float shadowRadius;
  5708. vec2 shadowMapSize;
  5709. };
  5710. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5711. #endif
  5712. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5713. struct SpotLightShadow {
  5714. float shadowBias;
  5715. float shadowNormalBias;
  5716. float shadowRadius;
  5717. vec2 shadowMapSize;
  5718. };
  5719. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5720. #endif
  5721. #if NUM_POINT_LIGHT_SHADOWS > 0
  5722. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5723. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5724. struct PointLightShadow {
  5725. float shadowBias;
  5726. float shadowNormalBias;
  5727. float shadowRadius;
  5728. vec2 shadowMapSize;
  5729. float shadowCameraNear;
  5730. float shadowCameraFar;
  5731. };
  5732. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5733. #endif
  5734. #endif`,P4e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5735. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5736. vec4 shadowWorldPosition;
  5737. #endif
  5738. #if defined( USE_SHADOWMAP )
  5739. #if NUM_DIR_LIGHT_SHADOWS > 0
  5740. #pragma unroll_loop_start
  5741. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5742. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5743. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5744. }
  5745. #pragma unroll_loop_end
  5746. #endif
  5747. #if NUM_POINT_LIGHT_SHADOWS > 0
  5748. #pragma unroll_loop_start
  5749. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5750. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5751. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5752. }
  5753. #pragma unroll_loop_end
  5754. #endif
  5755. #endif
  5756. #if NUM_SPOT_LIGHT_COORDS > 0
  5757. #pragma unroll_loop_start
  5758. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5759. shadowWorldPosition = worldPosition;
  5760. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5761. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5762. #endif
  5763. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5764. }
  5765. #pragma unroll_loop_end
  5766. #endif`,R4e=`float getShadowMask() {
  5767. float shadow = 1.0;
  5768. #ifdef USE_SHADOWMAP
  5769. #if NUM_DIR_LIGHT_SHADOWS > 0
  5770. DirectionalLightShadow directionalLight;
  5771. #pragma unroll_loop_start
  5772. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5773. directionalLight = directionalLightShadows[ i ];
  5774. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5775. }
  5776. #pragma unroll_loop_end
  5777. #endif
  5778. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5779. SpotLightShadow spotLight;
  5780. #pragma unroll_loop_start
  5781. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5782. spotLight = spotLightShadows[ i ];
  5783. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5784. }
  5785. #pragma unroll_loop_end
  5786. #endif
  5787. #if NUM_POINT_LIGHT_SHADOWS > 0
  5788. PointLightShadow pointLight;
  5789. #pragma unroll_loop_start
  5790. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5791. pointLight = pointLightShadows[ i ];
  5792. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5793. }
  5794. #pragma unroll_loop_end
  5795. #endif
  5796. #endif
  5797. return shadow;
  5798. }`,D4e=`#ifdef USE_SKINNING
  5799. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5800. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5801. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5802. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5803. #endif`,j4e=`#ifdef USE_SKINNING
  5804. uniform mat4 bindMatrix;
  5805. uniform mat4 bindMatrixInverse;
  5806. uniform highp sampler2D boneTexture;
  5807. mat4 getBoneMatrix( const in float i ) {
  5808. int size = textureSize( boneTexture, 0 ).x;
  5809. int j = int( i ) * 4;
  5810. int x = j % size;
  5811. int y = j / size;
  5812. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5813. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5814. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5815. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5816. return mat4( v1, v2, v3, v4 );
  5817. }
  5818. #endif`,O4e=`#ifdef USE_SKINNING
  5819. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5820. vec4 skinned = vec4( 0.0 );
  5821. skinned += boneMatX * skinVertex * skinWeight.x;
  5822. skinned += boneMatY * skinVertex * skinWeight.y;
  5823. skinned += boneMatZ * skinVertex * skinWeight.z;
  5824. skinned += boneMatW * skinVertex * skinWeight.w;
  5825. transformed = ( bindMatrixInverse * skinned ).xyz;
  5826. #endif`,L4e=`#ifdef USE_SKINNING
  5827. mat4 skinMatrix = mat4( 0.0 );
  5828. skinMatrix += skinWeight.x * boneMatX;
  5829. skinMatrix += skinWeight.y * boneMatY;
  5830. skinMatrix += skinWeight.z * boneMatZ;
  5831. skinMatrix += skinWeight.w * boneMatW;
  5832. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5833. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5834. #ifdef USE_TANGENT
  5835. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5836. #endif
  5837. #endif`,I4e=`float specularStrength;
  5838. #ifdef USE_SPECULARMAP
  5839. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5840. specularStrength = texelSpecular.r;
  5841. #else
  5842. specularStrength = 1.0;
  5843. #endif`,F4e=`#ifdef USE_SPECULARMAP
  5844. uniform sampler2D specularMap;
  5845. #endif`,U4e=`#if defined( TONE_MAPPING )
  5846. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5847. #endif`,z4e=`#ifndef saturate
  5848. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5849. #endif
  5850. uniform float toneMappingExposure;
  5851. vec3 LinearToneMapping( vec3 color ) {
  5852. return saturate( toneMappingExposure * color );
  5853. }
  5854. vec3 ReinhardToneMapping( vec3 color ) {
  5855. color *= toneMappingExposure;
  5856. return saturate( color / ( vec3( 1.0 ) + color ) );
  5857. }
  5858. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5859. color *= toneMappingExposure;
  5860. color = max( vec3( 0.0 ), color - 0.004 );
  5861. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5862. }
  5863. vec3 RRTAndODTFit( vec3 v ) {
  5864. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5865. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5866. return a / b;
  5867. }
  5868. vec3 ACESFilmicToneMapping( vec3 color ) {
  5869. const mat3 ACESInputMat = mat3(
  5870. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5871. vec3( 0.04823, 0.01566, 0.83777 )
  5872. );
  5873. const mat3 ACESOutputMat = mat3(
  5874. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5875. vec3( -0.07367, -0.00605, 1.07602 )
  5876. );
  5877. color *= toneMappingExposure / 0.6;
  5878. color = ACESInputMat * color;
  5879. color = RRTAndODTFit( color );
  5880. color = ACESOutputMat * color;
  5881. return saturate( color );
  5882. }
  5883. vec3 CustomToneMapping( vec3 color ) { return color; }`,B4e=`#ifdef USE_TRANSMISSION
  5884. material.transmission = transmission;
  5885. material.transmissionAlpha = 1.0;
  5886. material.thickness = thickness;
  5887. material.attenuationDistance = attenuationDistance;
  5888. material.attenuationColor = attenuationColor;
  5889. #ifdef USE_TRANSMISSIONMAP
  5890. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5891. #endif
  5892. #ifdef USE_THICKNESSMAP
  5893. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5894. #endif
  5895. vec3 pos = vWorldPosition;
  5896. vec3 v = normalize( cameraPosition - pos );
  5897. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5898. vec4 transmitted = getIBLVolumeRefraction(
  5899. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5900. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5901. material.attenuationColor, material.attenuationDistance );
  5902. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5903. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5904. #endif`,H4e=`#ifdef USE_TRANSMISSION
  5905. uniform float transmission;
  5906. uniform float thickness;
  5907. uniform float attenuationDistance;
  5908. uniform vec3 attenuationColor;
  5909. #ifdef USE_TRANSMISSIONMAP
  5910. uniform sampler2D transmissionMap;
  5911. #endif
  5912. #ifdef USE_THICKNESSMAP
  5913. uniform sampler2D thicknessMap;
  5914. #endif
  5915. uniform vec2 transmissionSamplerSize;
  5916. uniform sampler2D transmissionSamplerMap;
  5917. uniform mat4 modelMatrix;
  5918. uniform mat4 projectionMatrix;
  5919. varying vec3 vWorldPosition;
  5920. float w0( float a ) {
  5921. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5922. }
  5923. float w1( float a ) {
  5924. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5925. }
  5926. float w2( float a ){
  5927. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5928. }
  5929. float w3( float a ) {
  5930. return ( 1.0 / 6.0 ) * ( a * a * a );
  5931. }
  5932. float g0( float a ) {
  5933. return w0( a ) + w1( a );
  5934. }
  5935. float g1( float a ) {
  5936. return w2( a ) + w3( a );
  5937. }
  5938. float h0( float a ) {
  5939. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5940. }
  5941. float h1( float a ) {
  5942. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5943. }
  5944. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5945. uv = uv * texelSize.zw + 0.5;
  5946. vec2 iuv = floor( uv );
  5947. vec2 fuv = fract( uv );
  5948. float g0x = g0( fuv.x );
  5949. float g1x = g1( fuv.x );
  5950. float h0x = h0( fuv.x );
  5951. float h1x = h1( fuv.x );
  5952. float h0y = h0( fuv.y );
  5953. float h1y = h1( fuv.y );
  5954. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5955. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5956. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5957. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5958. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5959. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5960. }
  5961. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5962. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5963. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5964. vec2 fLodSizeInv = 1.0 / fLodSize;
  5965. vec2 cLodSizeInv = 1.0 / cLodSize;
  5966. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5967. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5968. return mix( fSample, cSample, fract( lod ) );
  5969. }
  5970. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5971. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5972. vec3 modelScale;
  5973. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5974. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5975. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5976. return normalize( refractionVector ) * thickness * modelScale;
  5977. }
  5978. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5979. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5980. }
  5981. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5982. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5983. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5984. }
  5985. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5986. if ( isinf( attenuationDistance ) ) {
  5987. return vec3( 1.0 );
  5988. } else {
  5989. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5990. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5991. }
  5992. }
  5993. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5994. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5995. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5996. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5997. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5998. vec3 refractedRayExit = position + transmissionRay;
  5999. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6000. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6001. refractionCoords += 1.0;
  6002. refractionCoords /= 2.0;
  6003. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6004. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6005. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6006. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6007. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6008. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6009. }
  6010. #endif`,$4e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6011. varying vec2 vUv;
  6012. #endif
  6013. #ifdef USE_MAP
  6014. varying vec2 vMapUv;
  6015. #endif
  6016. #ifdef USE_ALPHAMAP
  6017. varying vec2 vAlphaMapUv;
  6018. #endif
  6019. #ifdef USE_LIGHTMAP
  6020. varying vec2 vLightMapUv;
  6021. #endif
  6022. #ifdef USE_AOMAP
  6023. varying vec2 vAoMapUv;
  6024. #endif
  6025. #ifdef USE_BUMPMAP
  6026. varying vec2 vBumpMapUv;
  6027. #endif
  6028. #ifdef USE_NORMALMAP
  6029. varying vec2 vNormalMapUv;
  6030. #endif
  6031. #ifdef USE_EMISSIVEMAP
  6032. varying vec2 vEmissiveMapUv;
  6033. #endif
  6034. #ifdef USE_METALNESSMAP
  6035. varying vec2 vMetalnessMapUv;
  6036. #endif
  6037. #ifdef USE_ROUGHNESSMAP
  6038. varying vec2 vRoughnessMapUv;
  6039. #endif
  6040. #ifdef USE_ANISOTROPYMAP
  6041. varying vec2 vAnisotropyMapUv;
  6042. #endif
  6043. #ifdef USE_CLEARCOATMAP
  6044. varying vec2 vClearcoatMapUv;
  6045. #endif
  6046. #ifdef USE_CLEARCOAT_NORMALMAP
  6047. varying vec2 vClearcoatNormalMapUv;
  6048. #endif
  6049. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6050. varying vec2 vClearcoatRoughnessMapUv;
  6051. #endif
  6052. #ifdef USE_IRIDESCENCEMAP
  6053. varying vec2 vIridescenceMapUv;
  6054. #endif
  6055. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6056. varying vec2 vIridescenceThicknessMapUv;
  6057. #endif
  6058. #ifdef USE_SHEEN_COLORMAP
  6059. varying vec2 vSheenColorMapUv;
  6060. #endif
  6061. #ifdef USE_SHEEN_ROUGHNESSMAP
  6062. varying vec2 vSheenRoughnessMapUv;
  6063. #endif
  6064. #ifdef USE_SPECULARMAP
  6065. varying vec2 vSpecularMapUv;
  6066. #endif
  6067. #ifdef USE_SPECULAR_COLORMAP
  6068. varying vec2 vSpecularColorMapUv;
  6069. #endif
  6070. #ifdef USE_SPECULAR_INTENSITYMAP
  6071. varying vec2 vSpecularIntensityMapUv;
  6072. #endif
  6073. #ifdef USE_TRANSMISSIONMAP
  6074. uniform mat3 transmissionMapTransform;
  6075. varying vec2 vTransmissionMapUv;
  6076. #endif
  6077. #ifdef USE_THICKNESSMAP
  6078. uniform mat3 thicknessMapTransform;
  6079. varying vec2 vThicknessMapUv;
  6080. #endif`,V4e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6081. varying vec2 vUv;
  6082. #endif
  6083. #ifdef USE_MAP
  6084. uniform mat3 mapTransform;
  6085. varying vec2 vMapUv;
  6086. #endif
  6087. #ifdef USE_ALPHAMAP
  6088. uniform mat3 alphaMapTransform;
  6089. varying vec2 vAlphaMapUv;
  6090. #endif
  6091. #ifdef USE_LIGHTMAP
  6092. uniform mat3 lightMapTransform;
  6093. varying vec2 vLightMapUv;
  6094. #endif
  6095. #ifdef USE_AOMAP
  6096. uniform mat3 aoMapTransform;
  6097. varying vec2 vAoMapUv;
  6098. #endif
  6099. #ifdef USE_BUMPMAP
  6100. uniform mat3 bumpMapTransform;
  6101. varying vec2 vBumpMapUv;
  6102. #endif
  6103. #ifdef USE_NORMALMAP
  6104. uniform mat3 normalMapTransform;
  6105. varying vec2 vNormalMapUv;
  6106. #endif
  6107. #ifdef USE_DISPLACEMENTMAP
  6108. uniform mat3 displacementMapTransform;
  6109. varying vec2 vDisplacementMapUv;
  6110. #endif
  6111. #ifdef USE_EMISSIVEMAP
  6112. uniform mat3 emissiveMapTransform;
  6113. varying vec2 vEmissiveMapUv;
  6114. #endif
  6115. #ifdef USE_METALNESSMAP
  6116. uniform mat3 metalnessMapTransform;
  6117. varying vec2 vMetalnessMapUv;
  6118. #endif
  6119. #ifdef USE_ROUGHNESSMAP
  6120. uniform mat3 roughnessMapTransform;
  6121. varying vec2 vRoughnessMapUv;
  6122. #endif
  6123. #ifdef USE_ANISOTROPYMAP
  6124. uniform mat3 anisotropyMapTransform;
  6125. varying vec2 vAnisotropyMapUv;
  6126. #endif
  6127. #ifdef USE_CLEARCOATMAP
  6128. uniform mat3 clearcoatMapTransform;
  6129. varying vec2 vClearcoatMapUv;
  6130. #endif
  6131. #ifdef USE_CLEARCOAT_NORMALMAP
  6132. uniform mat3 clearcoatNormalMapTransform;
  6133. varying vec2 vClearcoatNormalMapUv;
  6134. #endif
  6135. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6136. uniform mat3 clearcoatRoughnessMapTransform;
  6137. varying vec2 vClearcoatRoughnessMapUv;
  6138. #endif
  6139. #ifdef USE_SHEEN_COLORMAP
  6140. uniform mat3 sheenColorMapTransform;
  6141. varying vec2 vSheenColorMapUv;
  6142. #endif
  6143. #ifdef USE_SHEEN_ROUGHNESSMAP
  6144. uniform mat3 sheenRoughnessMapTransform;
  6145. varying vec2 vSheenRoughnessMapUv;
  6146. #endif
  6147. #ifdef USE_IRIDESCENCEMAP
  6148. uniform mat3 iridescenceMapTransform;
  6149. varying vec2 vIridescenceMapUv;
  6150. #endif
  6151. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6152. uniform mat3 iridescenceThicknessMapTransform;
  6153. varying vec2 vIridescenceThicknessMapUv;
  6154. #endif
  6155. #ifdef USE_SPECULARMAP
  6156. uniform mat3 specularMapTransform;
  6157. varying vec2 vSpecularMapUv;
  6158. #endif
  6159. #ifdef USE_SPECULAR_COLORMAP
  6160. uniform mat3 specularColorMapTransform;
  6161. varying vec2 vSpecularColorMapUv;
  6162. #endif
  6163. #ifdef USE_SPECULAR_INTENSITYMAP
  6164. uniform mat3 specularIntensityMapTransform;
  6165. varying vec2 vSpecularIntensityMapUv;
  6166. #endif
  6167. #ifdef USE_TRANSMISSIONMAP
  6168. uniform mat3 transmissionMapTransform;
  6169. varying vec2 vTransmissionMapUv;
  6170. #endif
  6171. #ifdef USE_THICKNESSMAP
  6172. uniform mat3 thicknessMapTransform;
  6173. varying vec2 vThicknessMapUv;
  6174. #endif`,G4e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6175. vUv = vec3( uv, 1 ).xy;
  6176. #endif
  6177. #ifdef USE_MAP
  6178. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6179. #endif
  6180. #ifdef USE_ALPHAMAP
  6181. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6182. #endif
  6183. #ifdef USE_LIGHTMAP
  6184. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6185. #endif
  6186. #ifdef USE_AOMAP
  6187. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6188. #endif
  6189. #ifdef USE_BUMPMAP
  6190. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6191. #endif
  6192. #ifdef USE_NORMALMAP
  6193. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6194. #endif
  6195. #ifdef USE_DISPLACEMENTMAP
  6196. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6197. #endif
  6198. #ifdef USE_EMISSIVEMAP
  6199. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6200. #endif
  6201. #ifdef USE_METALNESSMAP
  6202. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6203. #endif
  6204. #ifdef USE_ROUGHNESSMAP
  6205. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6206. #endif
  6207. #ifdef USE_ANISOTROPYMAP
  6208. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6209. #endif
  6210. #ifdef USE_CLEARCOATMAP
  6211. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6212. #endif
  6213. #ifdef USE_CLEARCOAT_NORMALMAP
  6214. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6215. #endif
  6216. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6217. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6218. #endif
  6219. #ifdef USE_IRIDESCENCEMAP
  6220. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6221. #endif
  6222. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6223. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6224. #endif
  6225. #ifdef USE_SHEEN_COLORMAP
  6226. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6227. #endif
  6228. #ifdef USE_SHEEN_ROUGHNESSMAP
  6229. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6230. #endif
  6231. #ifdef USE_SPECULARMAP
  6232. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6233. #endif
  6234. #ifdef USE_SPECULAR_COLORMAP
  6235. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6236. #endif
  6237. #ifdef USE_SPECULAR_INTENSITYMAP
  6238. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6239. #endif
  6240. #ifdef USE_TRANSMISSIONMAP
  6241. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6242. #endif
  6243. #ifdef USE_THICKNESSMAP
  6244. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6245. #endif`,W4e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6246. vec4 worldPosition = vec4( transformed, 1.0 );
  6247. #ifdef USE_BATCHING
  6248. worldPosition = batchingMatrix * worldPosition;
  6249. #endif
  6250. #ifdef USE_INSTANCING
  6251. worldPosition = instanceMatrix * worldPosition;
  6252. #endif
  6253. worldPosition = modelMatrix * worldPosition;
  6254. #endif`;const q4e=`varying vec2 vUv;
  6255. uniform mat3 uvTransform;
  6256. void main() {
  6257. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6258. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6259. }`,K4e=`uniform sampler2D t2D;
  6260. uniform float backgroundIntensity;
  6261. varying vec2 vUv;
  6262. void main() {
  6263. vec4 texColor = texture2D( t2D, vUv );
  6264. #ifdef DECODE_VIDEO_TEXTURE
  6265. 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 );
  6266. #endif
  6267. texColor.rgb *= backgroundIntensity;
  6268. gl_FragColor = texColor;
  6269. #include <tonemapping_fragment>
  6270. #include <colorspace_fragment>
  6271. }`,X4e=`varying vec3 vWorldDirection;
  6272. #include <common>
  6273. void main() {
  6274. vWorldDirection = transformDirection( position, modelMatrix );
  6275. #include <begin_vertex>
  6276. #include <project_vertex>
  6277. gl_Position.z = gl_Position.w;
  6278. }`,Y4e=`#ifdef ENVMAP_TYPE_CUBE
  6279. uniform samplerCube envMap;
  6280. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6281. uniform sampler2D envMap;
  6282. #endif
  6283. uniform float flipEnvMap;
  6284. uniform float backgroundBlurriness;
  6285. uniform float backgroundIntensity;
  6286. varying vec3 vWorldDirection;
  6287. #include <cube_uv_reflection_fragment>
  6288. void main() {
  6289. #ifdef ENVMAP_TYPE_CUBE
  6290. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6291. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6292. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6293. #else
  6294. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6295. #endif
  6296. texColor.rgb *= backgroundIntensity;
  6297. gl_FragColor = texColor;
  6298. #include <tonemapping_fragment>
  6299. #include <colorspace_fragment>
  6300. }`,Z4e=`varying vec3 vWorldDirection;
  6301. #include <common>
  6302. void main() {
  6303. vWorldDirection = transformDirection( position, modelMatrix );
  6304. #include <begin_vertex>
  6305. #include <project_vertex>
  6306. gl_Position.z = gl_Position.w;
  6307. }`,Q4e=`uniform samplerCube tCube;
  6308. uniform float tFlip;
  6309. uniform float opacity;
  6310. varying vec3 vWorldDirection;
  6311. void main() {
  6312. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6313. gl_FragColor = texColor;
  6314. gl_FragColor.a *= opacity;
  6315. #include <tonemapping_fragment>
  6316. #include <colorspace_fragment>
  6317. }`,J4e=`#include <common>
  6318. #include <batching_pars_vertex>
  6319. #include <uv_pars_vertex>
  6320. #include <displacementmap_pars_vertex>
  6321. #include <morphtarget_pars_vertex>
  6322. #include <skinning_pars_vertex>
  6323. #include <logdepthbuf_pars_vertex>
  6324. #include <clipping_planes_pars_vertex>
  6325. varying vec2 vHighPrecisionZW;
  6326. void main() {
  6327. #include <uv_vertex>
  6328. #include <batching_vertex>
  6329. #include <skinbase_vertex>
  6330. #ifdef USE_DISPLACEMENTMAP
  6331. #include <beginnormal_vertex>
  6332. #include <morphnormal_vertex>
  6333. #include <skinnormal_vertex>
  6334. #endif
  6335. #include <begin_vertex>
  6336. #include <morphtarget_vertex>
  6337. #include <skinning_vertex>
  6338. #include <displacementmap_vertex>
  6339. #include <project_vertex>
  6340. #include <logdepthbuf_vertex>
  6341. #include <clipping_planes_vertex>
  6342. vHighPrecisionZW = gl_Position.zw;
  6343. }`,eIe=`#if DEPTH_PACKING == 3200
  6344. uniform float opacity;
  6345. #endif
  6346. #include <common>
  6347. #include <packing>
  6348. #include <uv_pars_fragment>
  6349. #include <map_pars_fragment>
  6350. #include <alphamap_pars_fragment>
  6351. #include <alphatest_pars_fragment>
  6352. #include <alphahash_pars_fragment>
  6353. #include <logdepthbuf_pars_fragment>
  6354. #include <clipping_planes_pars_fragment>
  6355. varying vec2 vHighPrecisionZW;
  6356. void main() {
  6357. #include <clipping_planes_fragment>
  6358. vec4 diffuseColor = vec4( 1.0 );
  6359. #if DEPTH_PACKING == 3200
  6360. diffuseColor.a = opacity;
  6361. #endif
  6362. #include <map_fragment>
  6363. #include <alphamap_fragment>
  6364. #include <alphatest_fragment>
  6365. #include <alphahash_fragment>
  6366. #include <logdepthbuf_fragment>
  6367. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6368. #if DEPTH_PACKING == 3200
  6369. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6370. #elif DEPTH_PACKING == 3201
  6371. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6372. #endif
  6373. }`,tIe=`#define DISTANCE
  6374. varying vec3 vWorldPosition;
  6375. #include <common>
  6376. #include <batching_pars_vertex>
  6377. #include <uv_pars_vertex>
  6378. #include <displacementmap_pars_vertex>
  6379. #include <morphtarget_pars_vertex>
  6380. #include <skinning_pars_vertex>
  6381. #include <clipping_planes_pars_vertex>
  6382. void main() {
  6383. #include <uv_vertex>
  6384. #include <batching_vertex>
  6385. #include <skinbase_vertex>
  6386. #ifdef USE_DISPLACEMENTMAP
  6387. #include <beginnormal_vertex>
  6388. #include <morphnormal_vertex>
  6389. #include <skinnormal_vertex>
  6390. #endif
  6391. #include <begin_vertex>
  6392. #include <morphtarget_vertex>
  6393. #include <skinning_vertex>
  6394. #include <displacementmap_vertex>
  6395. #include <project_vertex>
  6396. #include <worldpos_vertex>
  6397. #include <clipping_planes_vertex>
  6398. vWorldPosition = worldPosition.xyz;
  6399. }`,nIe=`#define DISTANCE
  6400. uniform vec3 referencePosition;
  6401. uniform float nearDistance;
  6402. uniform float farDistance;
  6403. varying vec3 vWorldPosition;
  6404. #include <common>
  6405. #include <packing>
  6406. #include <uv_pars_fragment>
  6407. #include <map_pars_fragment>
  6408. #include <alphamap_pars_fragment>
  6409. #include <alphatest_pars_fragment>
  6410. #include <alphahash_pars_fragment>
  6411. #include <clipping_planes_pars_fragment>
  6412. void main () {
  6413. #include <clipping_planes_fragment>
  6414. vec4 diffuseColor = vec4( 1.0 );
  6415. #include <map_fragment>
  6416. #include <alphamap_fragment>
  6417. #include <alphatest_fragment>
  6418. #include <alphahash_fragment>
  6419. float dist = length( vWorldPosition - referencePosition );
  6420. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6421. dist = saturate( dist );
  6422. gl_FragColor = packDepthToRGBA( dist );
  6423. }`,rIe=`varying vec3 vWorldDirection;
  6424. #include <common>
  6425. void main() {
  6426. vWorldDirection = transformDirection( position, modelMatrix );
  6427. #include <begin_vertex>
  6428. #include <project_vertex>
  6429. }`,iIe=`uniform sampler2D tEquirect;
  6430. varying vec3 vWorldDirection;
  6431. #include <common>
  6432. void main() {
  6433. vec3 direction = normalize( vWorldDirection );
  6434. vec2 sampleUV = equirectUv( direction );
  6435. gl_FragColor = texture2D( tEquirect, sampleUV );
  6436. #include <tonemapping_fragment>
  6437. #include <colorspace_fragment>
  6438. }`,aIe=`uniform float scale;
  6439. attribute float lineDistance;
  6440. varying float vLineDistance;
  6441. #include <common>
  6442. #include <uv_pars_vertex>
  6443. #include <color_pars_vertex>
  6444. #include <fog_pars_vertex>
  6445. #include <morphtarget_pars_vertex>
  6446. #include <logdepthbuf_pars_vertex>
  6447. #include <clipping_planes_pars_vertex>
  6448. void main() {
  6449. vLineDistance = scale * lineDistance;
  6450. #include <uv_vertex>
  6451. #include <color_vertex>
  6452. #include <morphcolor_vertex>
  6453. #include <begin_vertex>
  6454. #include <morphtarget_vertex>
  6455. #include <project_vertex>
  6456. #include <logdepthbuf_vertex>
  6457. #include <clipping_planes_vertex>
  6458. #include <fog_vertex>
  6459. }`,sIe=`uniform vec3 diffuse;
  6460. uniform float opacity;
  6461. uniform float dashSize;
  6462. uniform float totalSize;
  6463. varying float vLineDistance;
  6464. #include <common>
  6465. #include <color_pars_fragment>
  6466. #include <uv_pars_fragment>
  6467. #include <map_pars_fragment>
  6468. #include <fog_pars_fragment>
  6469. #include <logdepthbuf_pars_fragment>
  6470. #include <clipping_planes_pars_fragment>
  6471. void main() {
  6472. #include <clipping_planes_fragment>
  6473. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6474. discard;
  6475. }
  6476. vec3 outgoingLight = vec3( 0.0 );
  6477. vec4 diffuseColor = vec4( diffuse, opacity );
  6478. #include <logdepthbuf_fragment>
  6479. #include <map_fragment>
  6480. #include <color_fragment>
  6481. outgoingLight = diffuseColor.rgb;
  6482. #include <opaque_fragment>
  6483. #include <tonemapping_fragment>
  6484. #include <colorspace_fragment>
  6485. #include <fog_fragment>
  6486. #include <premultiplied_alpha_fragment>
  6487. }`,oIe=`#include <common>
  6488. #include <batching_pars_vertex>
  6489. #include <uv_pars_vertex>
  6490. #include <envmap_pars_vertex>
  6491. #include <color_pars_vertex>
  6492. #include <fog_pars_vertex>
  6493. #include <morphtarget_pars_vertex>
  6494. #include <skinning_pars_vertex>
  6495. #include <logdepthbuf_pars_vertex>
  6496. #include <clipping_planes_pars_vertex>
  6497. void main() {
  6498. #include <uv_vertex>
  6499. #include <color_vertex>
  6500. #include <morphcolor_vertex>
  6501. #include <batching_vertex>
  6502. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6503. #include <beginnormal_vertex>
  6504. #include <morphnormal_vertex>
  6505. #include <skinbase_vertex>
  6506. #include <skinnormal_vertex>
  6507. #include <defaultnormal_vertex>
  6508. #endif
  6509. #include <begin_vertex>
  6510. #include <morphtarget_vertex>
  6511. #include <skinning_vertex>
  6512. #include <project_vertex>
  6513. #include <logdepthbuf_vertex>
  6514. #include <clipping_planes_vertex>
  6515. #include <worldpos_vertex>
  6516. #include <envmap_vertex>
  6517. #include <fog_vertex>
  6518. }`,lIe=`uniform vec3 diffuse;
  6519. uniform float opacity;
  6520. #ifndef FLAT_SHADED
  6521. varying vec3 vNormal;
  6522. #endif
  6523. #include <common>
  6524. #include <dithering_pars_fragment>
  6525. #include <color_pars_fragment>
  6526. #include <uv_pars_fragment>
  6527. #include <map_pars_fragment>
  6528. #include <alphamap_pars_fragment>
  6529. #include <alphatest_pars_fragment>
  6530. #include <alphahash_pars_fragment>
  6531. #include <aomap_pars_fragment>
  6532. #include <lightmap_pars_fragment>
  6533. #include <envmap_common_pars_fragment>
  6534. #include <envmap_pars_fragment>
  6535. #include <fog_pars_fragment>
  6536. #include <specularmap_pars_fragment>
  6537. #include <logdepthbuf_pars_fragment>
  6538. #include <clipping_planes_pars_fragment>
  6539. void main() {
  6540. #include <clipping_planes_fragment>
  6541. vec4 diffuseColor = vec4( diffuse, opacity );
  6542. #include <logdepthbuf_fragment>
  6543. #include <map_fragment>
  6544. #include <color_fragment>
  6545. #include <alphamap_fragment>
  6546. #include <alphatest_fragment>
  6547. #include <alphahash_fragment>
  6548. #include <specularmap_fragment>
  6549. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6550. #ifdef USE_LIGHTMAP
  6551. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6552. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6553. #else
  6554. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6555. #endif
  6556. #include <aomap_fragment>
  6557. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6558. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6559. #include <envmap_fragment>
  6560. #include <opaque_fragment>
  6561. #include <tonemapping_fragment>
  6562. #include <colorspace_fragment>
  6563. #include <fog_fragment>
  6564. #include <premultiplied_alpha_fragment>
  6565. #include <dithering_fragment>
  6566. }`,cIe=`#define LAMBERT
  6567. varying vec3 vViewPosition;
  6568. #include <common>
  6569. #include <batching_pars_vertex>
  6570. #include <uv_pars_vertex>
  6571. #include <displacementmap_pars_vertex>
  6572. #include <envmap_pars_vertex>
  6573. #include <color_pars_vertex>
  6574. #include <fog_pars_vertex>
  6575. #include <normal_pars_vertex>
  6576. #include <morphtarget_pars_vertex>
  6577. #include <skinning_pars_vertex>
  6578. #include <shadowmap_pars_vertex>
  6579. #include <logdepthbuf_pars_vertex>
  6580. #include <clipping_planes_pars_vertex>
  6581. void main() {
  6582. #include <uv_vertex>
  6583. #include <color_vertex>
  6584. #include <morphcolor_vertex>
  6585. #include <batching_vertex>
  6586. #include <beginnormal_vertex>
  6587. #include <morphnormal_vertex>
  6588. #include <skinbase_vertex>
  6589. #include <skinnormal_vertex>
  6590. #include <defaultnormal_vertex>
  6591. #include <normal_vertex>
  6592. #include <begin_vertex>
  6593. #include <morphtarget_vertex>
  6594. #include <skinning_vertex>
  6595. #include <displacementmap_vertex>
  6596. #include <project_vertex>
  6597. #include <logdepthbuf_vertex>
  6598. #include <clipping_planes_vertex>
  6599. vViewPosition = - mvPosition.xyz;
  6600. #include <worldpos_vertex>
  6601. #include <envmap_vertex>
  6602. #include <shadowmap_vertex>
  6603. #include <fog_vertex>
  6604. }`,uIe=`#define LAMBERT
  6605. uniform vec3 diffuse;
  6606. uniform vec3 emissive;
  6607. uniform float opacity;
  6608. #include <common>
  6609. #include <packing>
  6610. #include <dithering_pars_fragment>
  6611. #include <color_pars_fragment>
  6612. #include <uv_pars_fragment>
  6613. #include <map_pars_fragment>
  6614. #include <alphamap_pars_fragment>
  6615. #include <alphatest_pars_fragment>
  6616. #include <alphahash_pars_fragment>
  6617. #include <aomap_pars_fragment>
  6618. #include <lightmap_pars_fragment>
  6619. #include <emissivemap_pars_fragment>
  6620. #include <envmap_common_pars_fragment>
  6621. #include <envmap_pars_fragment>
  6622. #include <fog_pars_fragment>
  6623. #include <bsdfs>
  6624. #include <lights_pars_begin>
  6625. #include <normal_pars_fragment>
  6626. #include <lights_lambert_pars_fragment>
  6627. #include <shadowmap_pars_fragment>
  6628. #include <bumpmap_pars_fragment>
  6629. #include <normalmap_pars_fragment>
  6630. #include <specularmap_pars_fragment>
  6631. #include <logdepthbuf_pars_fragment>
  6632. #include <clipping_planes_pars_fragment>
  6633. void main() {
  6634. #include <clipping_planes_fragment>
  6635. vec4 diffuseColor = vec4( diffuse, opacity );
  6636. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6637. vec3 totalEmissiveRadiance = emissive;
  6638. #include <logdepthbuf_fragment>
  6639. #include <map_fragment>
  6640. #include <color_fragment>
  6641. #include <alphamap_fragment>
  6642. #include <alphatest_fragment>
  6643. #include <alphahash_fragment>
  6644. #include <specularmap_fragment>
  6645. #include <normal_fragment_begin>
  6646. #include <normal_fragment_maps>
  6647. #include <emissivemap_fragment>
  6648. #include <lights_lambert_fragment>
  6649. #include <lights_fragment_begin>
  6650. #include <lights_fragment_maps>
  6651. #include <lights_fragment_end>
  6652. #include <aomap_fragment>
  6653. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6654. #include <envmap_fragment>
  6655. #include <opaque_fragment>
  6656. #include <tonemapping_fragment>
  6657. #include <colorspace_fragment>
  6658. #include <fog_fragment>
  6659. #include <premultiplied_alpha_fragment>
  6660. #include <dithering_fragment>
  6661. }`,dIe=`#define MATCAP
  6662. varying vec3 vViewPosition;
  6663. #include <common>
  6664. #include <batching_pars_vertex>
  6665. #include <uv_pars_vertex>
  6666. #include <color_pars_vertex>
  6667. #include <displacementmap_pars_vertex>
  6668. #include <fog_pars_vertex>
  6669. #include <normal_pars_vertex>
  6670. #include <morphtarget_pars_vertex>
  6671. #include <skinning_pars_vertex>
  6672. #include <logdepthbuf_pars_vertex>
  6673. #include <clipping_planes_pars_vertex>
  6674. void main() {
  6675. #include <uv_vertex>
  6676. #include <color_vertex>
  6677. #include <morphcolor_vertex>
  6678. #include <batching_vertex>
  6679. #include <beginnormal_vertex>
  6680. #include <morphnormal_vertex>
  6681. #include <skinbase_vertex>
  6682. #include <skinnormal_vertex>
  6683. #include <defaultnormal_vertex>
  6684. #include <normal_vertex>
  6685. #include <begin_vertex>
  6686. #include <morphtarget_vertex>
  6687. #include <skinning_vertex>
  6688. #include <displacementmap_vertex>
  6689. #include <project_vertex>
  6690. #include <logdepthbuf_vertex>
  6691. #include <clipping_planes_vertex>
  6692. #include <fog_vertex>
  6693. vViewPosition = - mvPosition.xyz;
  6694. }`,hIe=`#define MATCAP
  6695. uniform vec3 diffuse;
  6696. uniform float opacity;
  6697. uniform sampler2D matcap;
  6698. varying vec3 vViewPosition;
  6699. #include <common>
  6700. #include <dithering_pars_fragment>
  6701. #include <color_pars_fragment>
  6702. #include <uv_pars_fragment>
  6703. #include <map_pars_fragment>
  6704. #include <alphamap_pars_fragment>
  6705. #include <alphatest_pars_fragment>
  6706. #include <alphahash_pars_fragment>
  6707. #include <fog_pars_fragment>
  6708. #include <normal_pars_fragment>
  6709. #include <bumpmap_pars_fragment>
  6710. #include <normalmap_pars_fragment>
  6711. #include <logdepthbuf_pars_fragment>
  6712. #include <clipping_planes_pars_fragment>
  6713. void main() {
  6714. #include <clipping_planes_fragment>
  6715. vec4 diffuseColor = vec4( diffuse, opacity );
  6716. #include <logdepthbuf_fragment>
  6717. #include <map_fragment>
  6718. #include <color_fragment>
  6719. #include <alphamap_fragment>
  6720. #include <alphatest_fragment>
  6721. #include <alphahash_fragment>
  6722. #include <normal_fragment_begin>
  6723. #include <normal_fragment_maps>
  6724. vec3 viewDir = normalize( vViewPosition );
  6725. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6726. vec3 y = cross( viewDir, x );
  6727. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6728. #ifdef USE_MATCAP
  6729. vec4 matcapColor = texture2D( matcap, uv );
  6730. #else
  6731. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6732. #endif
  6733. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6734. #include <opaque_fragment>
  6735. #include <tonemapping_fragment>
  6736. #include <colorspace_fragment>
  6737. #include <fog_fragment>
  6738. #include <premultiplied_alpha_fragment>
  6739. #include <dithering_fragment>
  6740. }`,fIe=`#define NORMAL
  6741. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6742. varying vec3 vViewPosition;
  6743. #endif
  6744. #include <common>
  6745. #include <batching_pars_vertex>
  6746. #include <uv_pars_vertex>
  6747. #include <displacementmap_pars_vertex>
  6748. #include <normal_pars_vertex>
  6749. #include <morphtarget_pars_vertex>
  6750. #include <skinning_pars_vertex>
  6751. #include <logdepthbuf_pars_vertex>
  6752. #include <clipping_planes_pars_vertex>
  6753. void main() {
  6754. #include <uv_vertex>
  6755. #include <batching_vertex>
  6756. #include <beginnormal_vertex>
  6757. #include <morphnormal_vertex>
  6758. #include <skinbase_vertex>
  6759. #include <skinnormal_vertex>
  6760. #include <defaultnormal_vertex>
  6761. #include <normal_vertex>
  6762. #include <begin_vertex>
  6763. #include <morphtarget_vertex>
  6764. #include <skinning_vertex>
  6765. #include <displacementmap_vertex>
  6766. #include <project_vertex>
  6767. #include <logdepthbuf_vertex>
  6768. #include <clipping_planes_vertex>
  6769. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6770. vViewPosition = - mvPosition.xyz;
  6771. #endif
  6772. }`,pIe=`#define NORMAL
  6773. uniform float opacity;
  6774. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6775. varying vec3 vViewPosition;
  6776. #endif
  6777. #include <packing>
  6778. #include <uv_pars_fragment>
  6779. #include <normal_pars_fragment>
  6780. #include <bumpmap_pars_fragment>
  6781. #include <normalmap_pars_fragment>
  6782. #include <logdepthbuf_pars_fragment>
  6783. #include <clipping_planes_pars_fragment>
  6784. void main() {
  6785. #include <clipping_planes_fragment>
  6786. #include <logdepthbuf_fragment>
  6787. #include <normal_fragment_begin>
  6788. #include <normal_fragment_maps>
  6789. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6790. #ifdef OPAQUE
  6791. gl_FragColor.a = 1.0;
  6792. #endif
  6793. }`,mIe=`#define PHONG
  6794. varying vec3 vViewPosition;
  6795. #include <common>
  6796. #include <batching_pars_vertex>
  6797. #include <uv_pars_vertex>
  6798. #include <displacementmap_pars_vertex>
  6799. #include <envmap_pars_vertex>
  6800. #include <color_pars_vertex>
  6801. #include <fog_pars_vertex>
  6802. #include <normal_pars_vertex>
  6803. #include <morphtarget_pars_vertex>
  6804. #include <skinning_pars_vertex>
  6805. #include <shadowmap_pars_vertex>
  6806. #include <logdepthbuf_pars_vertex>
  6807. #include <clipping_planes_pars_vertex>
  6808. void main() {
  6809. #include <uv_vertex>
  6810. #include <color_vertex>
  6811. #include <morphcolor_vertex>
  6812. #include <batching_vertex>
  6813. #include <beginnormal_vertex>
  6814. #include <morphnormal_vertex>
  6815. #include <skinbase_vertex>
  6816. #include <skinnormal_vertex>
  6817. #include <defaultnormal_vertex>
  6818. #include <normal_vertex>
  6819. #include <begin_vertex>
  6820. #include <morphtarget_vertex>
  6821. #include <skinning_vertex>
  6822. #include <displacementmap_vertex>
  6823. #include <project_vertex>
  6824. #include <logdepthbuf_vertex>
  6825. #include <clipping_planes_vertex>
  6826. vViewPosition = - mvPosition.xyz;
  6827. #include <worldpos_vertex>
  6828. #include <envmap_vertex>
  6829. #include <shadowmap_vertex>
  6830. #include <fog_vertex>
  6831. }`,gIe=`#define PHONG
  6832. uniform vec3 diffuse;
  6833. uniform vec3 emissive;
  6834. uniform vec3 specular;
  6835. uniform float shininess;
  6836. uniform float opacity;
  6837. #include <common>
  6838. #include <packing>
  6839. #include <dithering_pars_fragment>
  6840. #include <color_pars_fragment>
  6841. #include <uv_pars_fragment>
  6842. #include <map_pars_fragment>
  6843. #include <alphamap_pars_fragment>
  6844. #include <alphatest_pars_fragment>
  6845. #include <alphahash_pars_fragment>
  6846. #include <aomap_pars_fragment>
  6847. #include <lightmap_pars_fragment>
  6848. #include <emissivemap_pars_fragment>
  6849. #include <envmap_common_pars_fragment>
  6850. #include <envmap_pars_fragment>
  6851. #include <fog_pars_fragment>
  6852. #include <bsdfs>
  6853. #include <lights_pars_begin>
  6854. #include <normal_pars_fragment>
  6855. #include <lights_phong_pars_fragment>
  6856. #include <shadowmap_pars_fragment>
  6857. #include <bumpmap_pars_fragment>
  6858. #include <normalmap_pars_fragment>
  6859. #include <specularmap_pars_fragment>
  6860. #include <logdepthbuf_pars_fragment>
  6861. #include <clipping_planes_pars_fragment>
  6862. void main() {
  6863. #include <clipping_planes_fragment>
  6864. vec4 diffuseColor = vec4( diffuse, opacity );
  6865. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6866. vec3 totalEmissiveRadiance = emissive;
  6867. #include <logdepthbuf_fragment>
  6868. #include <map_fragment>
  6869. #include <color_fragment>
  6870. #include <alphamap_fragment>
  6871. #include <alphatest_fragment>
  6872. #include <alphahash_fragment>
  6873. #include <specularmap_fragment>
  6874. #include <normal_fragment_begin>
  6875. #include <normal_fragment_maps>
  6876. #include <emissivemap_fragment>
  6877. #include <lights_phong_fragment>
  6878. #include <lights_fragment_begin>
  6879. #include <lights_fragment_maps>
  6880. #include <lights_fragment_end>
  6881. #include <aomap_fragment>
  6882. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6883. #include <envmap_fragment>
  6884. #include <opaque_fragment>
  6885. #include <tonemapping_fragment>
  6886. #include <colorspace_fragment>
  6887. #include <fog_fragment>
  6888. #include <premultiplied_alpha_fragment>
  6889. #include <dithering_fragment>
  6890. }`,xIe=`#define STANDARD
  6891. varying vec3 vViewPosition;
  6892. #ifdef USE_TRANSMISSION
  6893. varying vec3 vWorldPosition;
  6894. #endif
  6895. #include <common>
  6896. #include <batching_pars_vertex>
  6897. #include <uv_pars_vertex>
  6898. #include <displacementmap_pars_vertex>
  6899. #include <color_pars_vertex>
  6900. #include <fog_pars_vertex>
  6901. #include <normal_pars_vertex>
  6902. #include <morphtarget_pars_vertex>
  6903. #include <skinning_pars_vertex>
  6904. #include <shadowmap_pars_vertex>
  6905. #include <logdepthbuf_pars_vertex>
  6906. #include <clipping_planes_pars_vertex>
  6907. void main() {
  6908. #include <uv_vertex>
  6909. #include <color_vertex>
  6910. #include <morphcolor_vertex>
  6911. #include <batching_vertex>
  6912. #include <beginnormal_vertex>
  6913. #include <morphnormal_vertex>
  6914. #include <skinbase_vertex>
  6915. #include <skinnormal_vertex>
  6916. #include <defaultnormal_vertex>
  6917. #include <normal_vertex>
  6918. #include <begin_vertex>
  6919. #include <morphtarget_vertex>
  6920. #include <skinning_vertex>
  6921. #include <displacementmap_vertex>
  6922. #include <project_vertex>
  6923. #include <logdepthbuf_vertex>
  6924. #include <clipping_planes_vertex>
  6925. vViewPosition = - mvPosition.xyz;
  6926. #include <worldpos_vertex>
  6927. #include <shadowmap_vertex>
  6928. #include <fog_vertex>
  6929. #ifdef USE_TRANSMISSION
  6930. vWorldPosition = worldPosition.xyz;
  6931. #endif
  6932. }`,bIe=`#define STANDARD
  6933. #ifdef PHYSICAL
  6934. #define IOR
  6935. #define USE_SPECULAR
  6936. #endif
  6937. uniform vec3 diffuse;
  6938. uniform vec3 emissive;
  6939. uniform float roughness;
  6940. uniform float metalness;
  6941. uniform float opacity;
  6942. #ifdef IOR
  6943. uniform float ior;
  6944. #endif
  6945. #ifdef USE_SPECULAR
  6946. uniform float specularIntensity;
  6947. uniform vec3 specularColor;
  6948. #ifdef USE_SPECULAR_COLORMAP
  6949. uniform sampler2D specularColorMap;
  6950. #endif
  6951. #ifdef USE_SPECULAR_INTENSITYMAP
  6952. uniform sampler2D specularIntensityMap;
  6953. #endif
  6954. #endif
  6955. #ifdef USE_CLEARCOAT
  6956. uniform float clearcoat;
  6957. uniform float clearcoatRoughness;
  6958. #endif
  6959. #ifdef USE_IRIDESCENCE
  6960. uniform float iridescence;
  6961. uniform float iridescenceIOR;
  6962. uniform float iridescenceThicknessMinimum;
  6963. uniform float iridescenceThicknessMaximum;
  6964. #endif
  6965. #ifdef USE_SHEEN
  6966. uniform vec3 sheenColor;
  6967. uniform float sheenRoughness;
  6968. #ifdef USE_SHEEN_COLORMAP
  6969. uniform sampler2D sheenColorMap;
  6970. #endif
  6971. #ifdef USE_SHEEN_ROUGHNESSMAP
  6972. uniform sampler2D sheenRoughnessMap;
  6973. #endif
  6974. #endif
  6975. #ifdef USE_ANISOTROPY
  6976. uniform vec2 anisotropyVector;
  6977. #ifdef USE_ANISOTROPYMAP
  6978. uniform sampler2D anisotropyMap;
  6979. #endif
  6980. #endif
  6981. varying vec3 vViewPosition;
  6982. #include <common>
  6983. #include <packing>
  6984. #include <dithering_pars_fragment>
  6985. #include <color_pars_fragment>
  6986. #include <uv_pars_fragment>
  6987. #include <map_pars_fragment>
  6988. #include <alphamap_pars_fragment>
  6989. #include <alphatest_pars_fragment>
  6990. #include <alphahash_pars_fragment>
  6991. #include <aomap_pars_fragment>
  6992. #include <lightmap_pars_fragment>
  6993. #include <emissivemap_pars_fragment>
  6994. #include <iridescence_fragment>
  6995. #include <cube_uv_reflection_fragment>
  6996. #include <envmap_common_pars_fragment>
  6997. #include <envmap_physical_pars_fragment>
  6998. #include <fog_pars_fragment>
  6999. #include <lights_pars_begin>
  7000. #include <normal_pars_fragment>
  7001. #include <lights_physical_pars_fragment>
  7002. #include <transmission_pars_fragment>
  7003. #include <shadowmap_pars_fragment>
  7004. #include <bumpmap_pars_fragment>
  7005. #include <normalmap_pars_fragment>
  7006. #include <clearcoat_pars_fragment>
  7007. #include <iridescence_pars_fragment>
  7008. #include <roughnessmap_pars_fragment>
  7009. #include <metalnessmap_pars_fragment>
  7010. #include <logdepthbuf_pars_fragment>
  7011. #include <clipping_planes_pars_fragment>
  7012. void main() {
  7013. #include <clipping_planes_fragment>
  7014. vec4 diffuseColor = vec4( diffuse, opacity );
  7015. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7016. vec3 totalEmissiveRadiance = emissive;
  7017. #include <logdepthbuf_fragment>
  7018. #include <map_fragment>
  7019. #include <color_fragment>
  7020. #include <alphamap_fragment>
  7021. #include <alphatest_fragment>
  7022. #include <alphahash_fragment>
  7023. #include <roughnessmap_fragment>
  7024. #include <metalnessmap_fragment>
  7025. #include <normal_fragment_begin>
  7026. #include <normal_fragment_maps>
  7027. #include <clearcoat_normal_fragment_begin>
  7028. #include <clearcoat_normal_fragment_maps>
  7029. #include <emissivemap_fragment>
  7030. #include <lights_physical_fragment>
  7031. #include <lights_fragment_begin>
  7032. #include <lights_fragment_maps>
  7033. #include <lights_fragment_end>
  7034. #include <aomap_fragment>
  7035. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7036. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7037. #include <transmission_fragment>
  7038. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7039. #ifdef USE_SHEEN
  7040. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7041. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7042. #endif
  7043. #ifdef USE_CLEARCOAT
  7044. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7045. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7046. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7047. #endif
  7048. #include <opaque_fragment>
  7049. #include <tonemapping_fragment>
  7050. #include <colorspace_fragment>
  7051. #include <fog_fragment>
  7052. #include <premultiplied_alpha_fragment>
  7053. #include <dithering_fragment>
  7054. }`,yIe=`#define TOON
  7055. varying vec3 vViewPosition;
  7056. #include <common>
  7057. #include <batching_pars_vertex>
  7058. #include <uv_pars_vertex>
  7059. #include <displacementmap_pars_vertex>
  7060. #include <color_pars_vertex>
  7061. #include <fog_pars_vertex>
  7062. #include <normal_pars_vertex>
  7063. #include <morphtarget_pars_vertex>
  7064. #include <skinning_pars_vertex>
  7065. #include <shadowmap_pars_vertex>
  7066. #include <logdepthbuf_pars_vertex>
  7067. #include <clipping_planes_pars_vertex>
  7068. void main() {
  7069. #include <uv_vertex>
  7070. #include <color_vertex>
  7071. #include <morphcolor_vertex>
  7072. #include <batching_vertex>
  7073. #include <beginnormal_vertex>
  7074. #include <morphnormal_vertex>
  7075. #include <skinbase_vertex>
  7076. #include <skinnormal_vertex>
  7077. #include <defaultnormal_vertex>
  7078. #include <normal_vertex>
  7079. #include <begin_vertex>
  7080. #include <morphtarget_vertex>
  7081. #include <skinning_vertex>
  7082. #include <displacementmap_vertex>
  7083. #include <project_vertex>
  7084. #include <logdepthbuf_vertex>
  7085. #include <clipping_planes_vertex>
  7086. vViewPosition = - mvPosition.xyz;
  7087. #include <worldpos_vertex>
  7088. #include <shadowmap_vertex>
  7089. #include <fog_vertex>
  7090. }`,vIe=`#define TOON
  7091. uniform vec3 diffuse;
  7092. uniform vec3 emissive;
  7093. uniform float opacity;
  7094. #include <common>
  7095. #include <packing>
  7096. #include <dithering_pars_fragment>
  7097. #include <color_pars_fragment>
  7098. #include <uv_pars_fragment>
  7099. #include <map_pars_fragment>
  7100. #include <alphamap_pars_fragment>
  7101. #include <alphatest_pars_fragment>
  7102. #include <alphahash_pars_fragment>
  7103. #include <aomap_pars_fragment>
  7104. #include <lightmap_pars_fragment>
  7105. #include <emissivemap_pars_fragment>
  7106. #include <gradientmap_pars_fragment>
  7107. #include <fog_pars_fragment>
  7108. #include <bsdfs>
  7109. #include <lights_pars_begin>
  7110. #include <normal_pars_fragment>
  7111. #include <lights_toon_pars_fragment>
  7112. #include <shadowmap_pars_fragment>
  7113. #include <bumpmap_pars_fragment>
  7114. #include <normalmap_pars_fragment>
  7115. #include <logdepthbuf_pars_fragment>
  7116. #include <clipping_planes_pars_fragment>
  7117. void main() {
  7118. #include <clipping_planes_fragment>
  7119. vec4 diffuseColor = vec4( diffuse, opacity );
  7120. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7121. vec3 totalEmissiveRadiance = emissive;
  7122. #include <logdepthbuf_fragment>
  7123. #include <map_fragment>
  7124. #include <color_fragment>
  7125. #include <alphamap_fragment>
  7126. #include <alphatest_fragment>
  7127. #include <alphahash_fragment>
  7128. #include <normal_fragment_begin>
  7129. #include <normal_fragment_maps>
  7130. #include <emissivemap_fragment>
  7131. #include <lights_toon_fragment>
  7132. #include <lights_fragment_begin>
  7133. #include <lights_fragment_maps>
  7134. #include <lights_fragment_end>
  7135. #include <aomap_fragment>
  7136. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7137. #include <opaque_fragment>
  7138. #include <tonemapping_fragment>
  7139. #include <colorspace_fragment>
  7140. #include <fog_fragment>
  7141. #include <premultiplied_alpha_fragment>
  7142. #include <dithering_fragment>
  7143. }`,_Ie=`uniform float size;
  7144. uniform float scale;
  7145. #include <common>
  7146. #include <color_pars_vertex>
  7147. #include <fog_pars_vertex>
  7148. #include <morphtarget_pars_vertex>
  7149. #include <logdepthbuf_pars_vertex>
  7150. #include <clipping_planes_pars_vertex>
  7151. #ifdef USE_POINTS_UV
  7152. varying vec2 vUv;
  7153. uniform mat3 uvTransform;
  7154. #endif
  7155. void main() {
  7156. #ifdef USE_POINTS_UV
  7157. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7158. #endif
  7159. #include <color_vertex>
  7160. #include <morphcolor_vertex>
  7161. #include <begin_vertex>
  7162. #include <morphtarget_vertex>
  7163. #include <project_vertex>
  7164. gl_PointSize = size;
  7165. #ifdef USE_SIZEATTENUATION
  7166. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7167. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7168. #endif
  7169. #include <logdepthbuf_vertex>
  7170. #include <clipping_planes_vertex>
  7171. #include <worldpos_vertex>
  7172. #include <fog_vertex>
  7173. }`,wIe=`uniform vec3 diffuse;
  7174. uniform float opacity;
  7175. #include <common>
  7176. #include <color_pars_fragment>
  7177. #include <map_particle_pars_fragment>
  7178. #include <alphatest_pars_fragment>
  7179. #include <alphahash_pars_fragment>
  7180. #include <fog_pars_fragment>
  7181. #include <logdepthbuf_pars_fragment>
  7182. #include <clipping_planes_pars_fragment>
  7183. void main() {
  7184. #include <clipping_planes_fragment>
  7185. vec3 outgoingLight = vec3( 0.0 );
  7186. vec4 diffuseColor = vec4( diffuse, opacity );
  7187. #include <logdepthbuf_fragment>
  7188. #include <map_particle_fragment>
  7189. #include <color_fragment>
  7190. #include <alphatest_fragment>
  7191. #include <alphahash_fragment>
  7192. outgoingLight = diffuseColor.rgb;
  7193. #include <opaque_fragment>
  7194. #include <tonemapping_fragment>
  7195. #include <colorspace_fragment>
  7196. #include <fog_fragment>
  7197. #include <premultiplied_alpha_fragment>
  7198. }`,SIe=`#include <common>
  7199. #include <batching_pars_vertex>
  7200. #include <fog_pars_vertex>
  7201. #include <morphtarget_pars_vertex>
  7202. #include <skinning_pars_vertex>
  7203. #include <logdepthbuf_pars_vertex>
  7204. #include <shadowmap_pars_vertex>
  7205. void main() {
  7206. #include <batching_vertex>
  7207. #include <beginnormal_vertex>
  7208. #include <morphnormal_vertex>
  7209. #include <skinbase_vertex>
  7210. #include <skinnormal_vertex>
  7211. #include <defaultnormal_vertex>
  7212. #include <begin_vertex>
  7213. #include <morphtarget_vertex>
  7214. #include <skinning_vertex>
  7215. #include <project_vertex>
  7216. #include <logdepthbuf_vertex>
  7217. #include <worldpos_vertex>
  7218. #include <shadowmap_vertex>
  7219. #include <fog_vertex>
  7220. }`,MIe=`uniform vec3 color;
  7221. uniform float opacity;
  7222. #include <common>
  7223. #include <packing>
  7224. #include <fog_pars_fragment>
  7225. #include <bsdfs>
  7226. #include <lights_pars_begin>
  7227. #include <logdepthbuf_pars_fragment>
  7228. #include <shadowmap_pars_fragment>
  7229. #include <shadowmask_pars_fragment>
  7230. void main() {
  7231. #include <logdepthbuf_fragment>
  7232. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7233. #include <tonemapping_fragment>
  7234. #include <colorspace_fragment>
  7235. #include <fog_fragment>
  7236. }`,EIe=`uniform float rotation;
  7237. uniform vec2 center;
  7238. #include <common>
  7239. #include <uv_pars_vertex>
  7240. #include <fog_pars_vertex>
  7241. #include <logdepthbuf_pars_vertex>
  7242. #include <clipping_planes_pars_vertex>
  7243. void main() {
  7244. #include <uv_vertex>
  7245. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7246. vec2 scale;
  7247. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7248. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7249. #ifndef USE_SIZEATTENUATION
  7250. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7251. if ( isPerspective ) scale *= - mvPosition.z;
  7252. #endif
  7253. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7254. vec2 rotatedPosition;
  7255. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7256. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7257. mvPosition.xy += rotatedPosition;
  7258. gl_Position = projectionMatrix * mvPosition;
  7259. #include <logdepthbuf_vertex>
  7260. #include <clipping_planes_vertex>
  7261. #include <fog_vertex>
  7262. }`,AIe=`uniform vec3 diffuse;
  7263. uniform float opacity;
  7264. #include <common>
  7265. #include <uv_pars_fragment>
  7266. #include <map_pars_fragment>
  7267. #include <alphamap_pars_fragment>
  7268. #include <alphatest_pars_fragment>
  7269. #include <alphahash_pars_fragment>
  7270. #include <fog_pars_fragment>
  7271. #include <logdepthbuf_pars_fragment>
  7272. #include <clipping_planes_pars_fragment>
  7273. void main() {
  7274. #include <clipping_planes_fragment>
  7275. vec3 outgoingLight = vec3( 0.0 );
  7276. vec4 diffuseColor = vec4( diffuse, opacity );
  7277. #include <logdepthbuf_fragment>
  7278. #include <map_fragment>
  7279. #include <alphamap_fragment>
  7280. #include <alphatest_fragment>
  7281. #include <alphahash_fragment>
  7282. outgoingLight = diffuseColor.rgb;
  7283. #include <opaque_fragment>
  7284. #include <tonemapping_fragment>
  7285. #include <colorspace_fragment>
  7286. #include <fog_fragment>
  7287. }`,ln={alphahash_fragment:KOe,alphahash_pars_fragment:XOe,alphamap_fragment:YOe,alphamap_pars_fragment:ZOe,alphatest_fragment:QOe,alphatest_pars_fragment:JOe,aomap_fragment:eLe,aomap_pars_fragment:tLe,batching_pars_vertex:nLe,batching_vertex:rLe,begin_vertex:iLe,beginnormal_vertex:aLe,bsdfs:sLe,iridescence_fragment:oLe,bumpmap_pars_fragment:lLe,clipping_planes_fragment:cLe,clipping_planes_pars_fragment:uLe,clipping_planes_pars_vertex:dLe,clipping_planes_vertex:hLe,color_fragment:fLe,color_pars_fragment:pLe,color_pars_vertex:mLe,color_vertex:gLe,common:xLe,cube_uv_reflection_fragment:bLe,defaultnormal_vertex:yLe,displacementmap_pars_vertex:vLe,displacementmap_vertex:_Le,emissivemap_fragment:wLe,emissivemap_pars_fragment:SLe,colorspace_fragment:MLe,colorspace_pars_fragment:ELe,envmap_fragment:ALe,envmap_common_pars_fragment:TLe,envmap_pars_fragment:CLe,envmap_pars_vertex:NLe,envmap_physical_pars_fragment:BLe,envmap_vertex:kLe,fog_vertex:PLe,fog_pars_vertex:RLe,fog_fragment:DLe,fog_pars_fragment:jLe,gradientmap_pars_fragment:OLe,lightmap_fragment:LLe,lightmap_pars_fragment:ILe,lights_lambert_fragment:FLe,lights_lambert_pars_fragment:ULe,lights_pars_begin:zLe,lights_toon_fragment:HLe,lights_toon_pars_fragment:$Le,lights_phong_fragment:VLe,lights_phong_pars_fragment:GLe,lights_physical_fragment:WLe,lights_physical_pars_fragment:qLe,lights_fragment_begin:KLe,lights_fragment_maps:XLe,lights_fragment_end:YLe,logdepthbuf_fragment:ZLe,logdepthbuf_pars_fragment:QLe,logdepthbuf_pars_vertex:JLe,logdepthbuf_vertex:e4e,map_fragment:t4e,map_pars_fragment:n4e,map_particle_fragment:r4e,map_particle_pars_fragment:i4e,metalnessmap_fragment:a4e,metalnessmap_pars_fragment:s4e,morphcolor_vertex:o4e,morphnormal_vertex:l4e,morphtarget_pars_vertex:c4e,morphtarget_vertex:u4e,normal_fragment_begin:d4e,normal_fragment_maps:h4e,normal_pars_fragment:f4e,normal_pars_vertex:p4e,normal_vertex:m4e,normalmap_pars_fragment:g4e,clearcoat_normal_fragment_begin:x4e,clearcoat_normal_fragment_maps:b4e,clearcoat_pars_fragment:y4e,iridescence_pars_fragment:v4e,opaque_fragment:_4e,packing:w4e,premultiplied_alpha_fragment:S4e,project_vertex:M4e,dithering_fragment:E4e,dithering_pars_fragment:A4e,roughnessmap_fragment:T4e,roughnessmap_pars_fragment:C4e,shadowmap_pars_fragment:N4e,shadowmap_pars_vertex:k4e,shadowmap_vertex:P4e,shadowmask_pars_fragment:R4e,skinbase_vertex:D4e,skinning_pars_vertex:j4e,skinning_vertex:O4e,skinnormal_vertex:L4e,specularmap_fragment:I4e,specularmap_pars_fragment:F4e,tonemapping_fragment:U4e,tonemapping_pars_fragment:z4e,transmission_fragment:B4e,transmission_pars_fragment:H4e,uv_pars_fragment:$4e,uv_pars_vertex:V4e,uv_vertex:G4e,worldpos_vertex:W4e,background_vert:q4e,background_frag:K4e,backgroundCube_vert:X4e,backgroundCube_frag:Y4e,cube_vert:Z4e,cube_frag:Q4e,depth_vert:J4e,depth_frag:eIe,distanceRGBA_vert:tIe,distanceRGBA_frag:nIe,equirect_vert:rIe,equirect_frag:iIe,linedashed_vert:aIe,linedashed_frag:sIe,meshbasic_vert:oIe,meshbasic_frag:lIe,meshlambert_vert:cIe,meshlambert_frag:uIe,meshmatcap_vert:dIe,meshmatcap_frag:hIe,meshnormal_vert:fIe,meshnormal_frag:pIe,meshphong_vert:mIe,meshphong_frag:gIe,meshphysical_vert:xIe,meshphysical_frag:bIe,meshtoon_vert:yIe,meshtoon_frag:vIe,points_vert:_Ie,points_frag:wIe,shadow_vert:SIe,shadow_frag:MIe,sprite_vert:EIe,sprite_frag:AIe},_t={common:{diffuse:{value:new $t(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new Zt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $t(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 $t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0},uvTransform:{value:new fn}},sprite:{diffuse:{value:new $t(16777215)},opacity:{value:1},center:{value:new Zt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},Va={basic:{uniforms:_a([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.fog]),vertexShader:ln.meshbasic_vert,fragmentShader:ln.meshbasic_frag},lambert:{uniforms:_a([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new $t(0)}}]),vertexShader:ln.meshlambert_vert,fragmentShader:ln.meshlambert_frag},phong:{uniforms:_a([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:ln.meshphong_vert,fragmentShader:ln.meshphong_frag},standard:{uniforms:_a([_t.common,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.roughnessmap,_t.metalnessmap,_t.fog,_t.lights,{emissive:{value:new $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag},toon:{uniforms:_a([_t.common,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.gradientmap,_t.fog,_t.lights,{emissive:{value:new $t(0)}}]),vertexShader:ln.meshtoon_vert,fragmentShader:ln.meshtoon_frag},matcap:{uniforms:_a([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,{matcap:{value:null}}]),vertexShader:ln.meshmatcap_vert,fragmentShader:ln.meshmatcap_frag},points:{uniforms:_a([_t.points,_t.fog]),vertexShader:ln.points_vert,fragmentShader:ln.points_frag},dashed:{uniforms:_a([_t.common,_t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ln.linedashed_vert,fragmentShader:ln.linedashed_frag},depth:{uniforms:_a([_t.common,_t.displacementmap]),vertexShader:ln.depth_vert,fragmentShader:ln.depth_frag},normal:{uniforms:_a([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,{opacity:{value:1}}]),vertexShader:ln.meshnormal_vert,fragmentShader:ln.meshnormal_frag},sprite:{uniforms:_a([_t.sprite,_t.fog]),vertexShader:ln.sprite_vert,fragmentShader:ln.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ln.background_vert,fragmentShader:ln.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ln.backgroundCube_vert,fragmentShader:ln.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ln.cube_vert,fragmentShader:ln.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ln.equirect_vert,fragmentShader:ln.equirect_frag},distanceRGBA:{uniforms:_a([_t.common,_t.displacementmap,{referencePosition:{value:new je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ln.distanceRGBA_vert,fragmentShader:ln.distanceRGBA_frag},shadow:{uniforms:_a([_t.lights,_t.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:ln.shadow_vert,fragmentShader:ln.shadow_frag}};Va.physical={uniforms:_a([Va.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new Zt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new $t(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fn},transmissionSamplerSize:{value:new Zt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new $t(0)},specularColor:{value:new $t(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new Zt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag};const E_={r:0,b:0,g:0};function TIe(t,e,n,r,i,a,s){const o=new $t(0);let c=a===!0?0:1,u,d,f=null,g=0,m=null;function b(v,x){let M=!1,S=x.isScene===!0?x.background:null;S&&S.isTexture&&(S=(x.backgroundBlurriness>0?n:e).get(S)),S===null?y(o,c):S&&S.isColor&&(y(S,1),M=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,s):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===$M)?(d===void 0&&(d=new jo(new Kb(1,1,1),new pd({name:"BackgroundCubeMaterial",uniforms:jm(Va.backgroundCube.uniforms),vertexShader:Va.backgroundCube.vertexShader,fragmentShader:Va.backgroundCube.fragmentShader,side:Ka,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,k,N){this.matrixWorld.copyPosition(N.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=x.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,d.material.toneMapped=Xn.getTransfer(S.colorSpace)!==lr,(f!==S||g!==S.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),d.layers.enableAll(),v.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new jo(new vO(2,2),new pd({name:"BackgroundMaterial",uniforms:jm(Va.background.uniforms),vertexShader:Va.background.vertexShader,fragmentShader:Va.background.fragmentShader,side:fd,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=x.backgroundIntensity,u.material.toneMapped=Xn.getTransfer(S.colorSpace)!==lr,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||g!==S.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null))}function y(v,x){v.getRGB(E_,KZ(t)),r.buffers.color.setClear(E_.r,E_.g,E_.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),c=x,y(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(v){c=v,y(o,c)},render:b}}function CIe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),s=r.isWebGL2||a!==null,o={},c=v(null);let u=c,d=!1;function f(R,W,K,G,ee){let Z=!1;if(s){const Q=y(G,K,W);u!==Q&&(u=Q,m(u.object)),Z=x(R,G,K,ee),Z&&M(R,G,K,ee)}else{const Q=W.wireframe===!0;(u.geometry!==G.id||u.program!==K.id||u.wireframe!==Q)&&(u.geometry=G.id,u.program=K.id,u.wireframe=Q,Z=!0)}ee!==null&&n.update(ee,t.ELEMENT_ARRAY_BUFFER),(Z||d)&&(d=!1,I(R,W,K,G),ee!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(ee).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(R){return r.isWebGL2?t.bindVertexArray(R):a.bindVertexArrayOES(R)}function b(R){return r.isWebGL2?t.deleteVertexArray(R):a.deleteVertexArrayOES(R)}function y(R,W,K){const G=K.wireframe===!0;let ee=o[R.id];ee===void 0&&(ee={},o[R.id]=ee);let Z=ee[W.id];Z===void 0&&(Z={},ee[W.id]=Z);let Q=Z[G];return Q===void 0&&(Q=v(g()),Z[G]=Q),Q}function v(R){const W=[],K=[],G=[];for(let ee=0;ee<i;ee++)W[ee]=0,K[ee]=0,G[ee]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:G,object:R,attributes:{},index:null}}function x(R,W,K,G){const ee=u.attributes,Z=W.attributes;let Q=0;const U=K.getAttributes();for(const $ in U)if(U[$].location>=0){const te=ee[$];let fe=Z[$];if(fe===void 0&&($==="instanceMatrix"&&R.instanceMatrix&&(fe=R.instanceMatrix),$==="instanceColor"&&R.instanceColor&&(fe=R.instanceColor)),te===void 0||te.attribute!==fe||fe&&te.data!==fe.data)return!0;Q++}return u.attributesNum!==Q||u.index!==G}function M(R,W,K,G){const ee={},Z=W.attributes;let Q=0;const U=K.getAttributes();for(const $ in U)if(U[$].location>=0){let te=Z[$];te===void 0&&($==="instanceMatrix"&&R.instanceMatrix&&(te=R.instanceMatrix),$==="instanceColor"&&R.instanceColor&&(te=R.instanceColor));const fe={};fe.attribute=te,te&&te.data&&(fe.data=te.data),ee[$]=fe,Q++}u.attributes=ee,u.attributesNum=Q,u.index=G}function S(){const R=u.newAttributes;for(let W=0,K=R.length;W<K;W++)R[W]=0}function A(R){T(R,0)}function T(R,W){const K=u.newAttributes,G=u.enabledAttributes,ee=u.attributeDivisors;K[R]=1,G[R]===0&&(t.enableVertexAttribArray(R),G[R]=1),ee[R]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,W),ee[R]=W)}function k(){const R=u.newAttributes,W=u.enabledAttributes;for(let K=0,G=W.length;K<G;K++)W[K]!==R[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function N(R,W,K,G,ee,Z,Q){Q===!0?t.vertexAttribIPointer(R,W,K,ee,Z):t.vertexAttribPointer(R,W,K,G,ee,Z)}function I(R,W,K,G){if(r.isWebGL2===!1&&(R.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const ee=G.attributes,Z=K.getAttributes(),Q=W.defaultAttributeValues;for(const U in Z){const $=Z[U];if($.location>=0){let X=ee[U];if(X===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(X=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(X=R.instanceColor)),X!==void 0){const te=X.normalized,fe=X.itemSize,pe=n.get(X);if(pe===void 0)continue;const be=pe.buffer,Ne=pe.type,ie=pe.bytesPerElement,xe=r.isWebGL2===!0&&(Ne===t.INT||Ne===t.UNSIGNED_INT||X.gpuType===CZ);if(X.isInterleavedBufferAttribute){const Re=X.data,he=Re.stride,ht=X.offset;if(Re.isInstancedInterleavedBuffer){for(let H=0;H<$.locationSize;H++)T($.location+H,Re.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let H=0;H<$.locationSize;H++)A($.location+H);t.bindBuffer(t.ARRAY_BUFFER,be);for(let H=0;H<$.locationSize;H++)N($.location+H,fe/$.locationSize,Ne,te,he*ie,(ht+fe/$.locationSize*H)*ie,xe)}else{if(X.isInstancedBufferAttribute){for(let Re=0;Re<$.locationSize;Re++)T($.location+Re,X.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let Re=0;Re<$.locationSize;Re++)A($.location+Re);t.bindBuffer(t.ARRAY_BUFFER,be);for(let Re=0;Re<$.locationSize;Re++)N($.location+Re,fe/$.locationSize,Ne,te,fe*ie,fe/$.locationSize*Re*ie,xe)}}else if(Q!==void 0){const te=Q[U];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv($.location,te);break;case 3:t.vertexAttrib3fv($.location,te);break;case 4:t.vertexAttrib4fv($.location,te);break;default:t.vertexAttrib1fv($.location,te)}}}}k()}function C(){O();for(const R in o){const W=o[R];for(const K in W){const G=W[K];for(const ee in G)b(G[ee].object),delete G[ee];delete W[K]}delete o[R]}}function D(R){if(o[R.id]===void 0)return;const W=o[R.id];for(const K in W){const G=W[K];for(const ee in G)b(G[ee].object),delete G[ee];delete W[K]}delete o[R.id]}function F(R){for(const W in o){const K=o[W];if(K[R.id]===void 0)continue;const G=K[R.id];for(const ee in G)b(G[ee].object),delete G[ee];delete K[R.id]}}function O(){q(),d=!0,u!==c&&(u=c,m(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:O,resetDefaultState:q,dispose:C,releaseStatesOfGeometry:D,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:A,disableUnusedAttributes:k}}function NIe(t,e,n,r){const i=r.isWebGL2;let a;function s(d){a=d}function o(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,g){if(g===0)return;let m,b;if(i)m=t,b="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[b](a,d,f,g),n.update(f,a,g)}function u(d,f,g){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<g;b++)this.render(d[b],f[b]);else{m.multiDrawArraysWEBGL(a,d,0,f,0,g);let b=0;for(let y=0;y<g;y++)b+=f[y];n.update(b,a,1)}}this.setMode=s,this.render=o,this.renderInstances=c,this.renderMultiDraw=u}function kIe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const c=a(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const u=s||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),x=t.getParameter(t.MAX_VARYING_VECTORS),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=g>0,A=s||e.has("OES_texture_float"),T=S&&A,k=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:b,maxAttributes:y,maxVertexUniforms:v,maxVaryings:x,maxFragmentUniforms:M,vertexTextures:S,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:k}}function PIe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Pu,o=new fn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const b=f.clippingPlanes,y=f.clipIntersection,v=f.clipShadows,x=t.get(f);if(!i||b===null||b.length===0||a&&!v)a?d(null):u();else{const M=a?0:r,S=M*4;let A=x.clippingState||null;c.value=A,A=d(b,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];x.clippingState=A,this.numIntersection=y?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,g,m,b){const y=f!==null?f.length:0;let v=null;if(y!==0){if(v=c.value,b!==!0||v===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let S=0,A=m;S!==y;++S,A+=4)s.copy(f[S]).applyMatrix4(M,o),s.normal.toArray(v,A),v[A+3]=s.constant}c.value=v,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function RIe(t){let e=new WeakMap;function n(s,o){return o===PP?s.mapping=Pm:o===RP&&(s.mapping=Rm),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===PP||o===RP)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new VOe(c.height/2);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class DIe extends XZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=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=s,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,s){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=s,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,s=r+e,o=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,s=a+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,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 Kp=4,z$=[.125,.215,.35,.446,.526,.582],uh=20,xN=new DIe,B$=new $t;let bN=null,yN=0,vN=0;const sh=(1+Math.sqrt(5))/2,Pp=1/sh,H$=[new je(1,1,1),new je(-1,1,1),new je(1,1,-1),new je(-1,1,-1),new je(0,sh,Pp),new je(0,sh,-Pp),new je(Pp,0,sh),new je(-Pp,0,sh),new je(sh,Pp,0),new je(-sh,Pp,0)];class $${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){bN=this._renderer.getRenderTarget(),yN=this._renderer.getActiveCubeFace(),vN=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=W$(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=G$(),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(bN,yN,vN),e.scissorTest=!1,A_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Pm||e.mapping===Rm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),bN=this._renderer.getRenderTarget(),yN=this._renderer.getActiveCubeFace(),vN=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:Zs,minFilter:Zs,generateMipmaps:!1,type:X0,format:Qs,colorSpace:Ic,depthBuffer:!1},i=V$(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=V$(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=jIe(a)),this._blurMaterial=OIe(a,e,n)}return i}_compileMaterial(e){const n=new jo(this._lodPlanes[0],e);this._renderer.compile(n,xN)}_sceneToCubeUV(e,n,r,i){const o=new ms(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,g=d.toneMapping;d.getClearColor(B$),d.toneMapping=Qu,d.autoClear=!1;const m=new GZ({name:"PMREM.Background",side:Ka,depthWrite:!1,depthTest:!1}),b=new jo(new Kb,m);let y=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,y=!0):(m.color.copy(B$),y=!0);for(let x=0;x<6;x++){const M=x%3;M===0?(o.up.set(0,c[x],0),o.lookAt(u[x],0,0)):M===1?(o.up.set(0,0,c[x]),o.lookAt(0,u[x],0)):(o.up.set(0,c[x],0),o.lookAt(0,0,u[x]));const S=this._cubeSize;A_(i,M*S,x>2?S:0,S,S),d.setRenderTarget(i),y&&d.render(b,o),d.render(e,o)}b.geometry.dispose(),b.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=v}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Pm||e.mapping===Rm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=W$()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=G$());const a=i?this._cubemapMaterial:this._equirectMaterial,s=new jo(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;const c=this._cubeSize;A_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,xN)}_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]),s=H$[(i-1)%H$.length];this._blur(e,i-1,i,a,s)}n.autoClear=r}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new jo(this._lodPlanes[i],u),g=u.uniforms,m=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*uh-1),y=a/b,v=isFinite(a)?1+Math.floor(d*y):uh;v>uh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${uh}`);const x=[];let M=0;for(let N=0;N<uh;++N){const I=N/y,C=Math.exp(-I*I/2);x.push(C),N===0?M+=C:N<v&&(M+=2*C)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=x,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=b,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-Kp?i-S+Kp:0),k=4*(this._cubeSize-A);A_(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,xN)}}function jIe(t){const e=[],n=[],r=[];let i=t;const a=t-Kp+1+z$.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);n.push(o);let c=1/o;s>t-Kp?c=z$[s-t+Kp-1]:s===0&&(c=0),r.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,b=6,y=3,v=2,x=1,M=new Float32Array(y*b*m),S=new Float32Array(v*b*m),A=new Float32Array(x*b*m);for(let k=0;k<m;k++){const N=k%3*2/3-1,I=k>2?0:-1,C=[N,I,0,N+2/3,I,0,N+2/3,I+1,0,N,I,0,N+2/3,I+1,0,N,I+1,0];M.set(C,y*b*k),S.set(g,v*b*k);const D=[k,k,k,k,k,k];A.set(D,x*b*k)}const T=new ga;T.setAttribute("position",new Ss(M,y)),T.setAttribute("uv",new Ss(S,v)),T.setAttribute("faceIndex",new Ss(A,x)),e.push(T),i>Kp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function V$(t,e,n){const r=new nf(t,e,n);return r.texture.mapping=$M,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function A_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function OIe(t,e,n){const r=new Float32Array(uh),i=new je(0,1,0);return new pd({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:_O(),fragmentShader:`
  7288. precision mediump float;
  7289. precision mediump int;
  7290. varying vec3 vOutputDirection;
  7291. uniform sampler2D envMap;
  7292. uniform int samples;
  7293. uniform float weights[ n ];
  7294. uniform bool latitudinal;
  7295. uniform float dTheta;
  7296. uniform float mipInt;
  7297. uniform vec3 poleAxis;
  7298. #define ENVMAP_TYPE_CUBE_UV
  7299. #include <cube_uv_reflection_fragment>
  7300. vec3 getSample( float theta, vec3 axis ) {
  7301. float cosTheta = cos( theta );
  7302. // Rodrigues' axis-angle rotation
  7303. vec3 sampleDirection = vOutputDirection * cosTheta
  7304. + cross( axis, vOutputDirection ) * sin( theta )
  7305. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7306. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7307. }
  7308. void main() {
  7309. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7310. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7311. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7312. }
  7313. axis = normalize( axis );
  7314. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7315. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7316. for ( int i = 1; i < n; i++ ) {
  7317. if ( i >= samples ) {
  7318. break;
  7319. }
  7320. float theta = dTheta * float( i );
  7321. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7322. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7323. }
  7324. }
  7325. `,blending:Zu,depthTest:!1,depthWrite:!1})}function G$(){return new pd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_O(),fragmentShader:`
  7326. precision mediump float;
  7327. precision mediump int;
  7328. varying vec3 vOutputDirection;
  7329. uniform sampler2D envMap;
  7330. #include <common>
  7331. void main() {
  7332. vec3 outputDirection = normalize( vOutputDirection );
  7333. vec2 uv = equirectUv( outputDirection );
  7334. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7335. }
  7336. `,blending:Zu,depthTest:!1,depthWrite:!1})}function W$(){return new pd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_O(),fragmentShader:`
  7337. precision mediump float;
  7338. precision mediump int;
  7339. uniform float flipEnvMap;
  7340. varying vec3 vOutputDirection;
  7341. uniform samplerCube envMap;
  7342. void main() {
  7343. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7344. }
  7345. `,blending:Zu,depthTest:!1,depthWrite:!1})}function _O(){return`
  7346. precision mediump float;
  7347. precision mediump int;
  7348. attribute float faceIndex;
  7349. varying vec3 vOutputDirection;
  7350. // RH coordinate system; PMREM face-indexing convention
  7351. vec3 getDirection( vec2 uv, float face ) {
  7352. uv = 2.0 * uv - 1.0;
  7353. vec3 direction = vec3( uv, 1.0 );
  7354. if ( face == 0.0 ) {
  7355. direction = direction.zyx; // ( 1, v, u ) pos x
  7356. } else if ( face == 1.0 ) {
  7357. direction = direction.xzy;
  7358. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7359. } else if ( face == 2.0 ) {
  7360. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7361. } else if ( face == 3.0 ) {
  7362. direction = direction.zyx;
  7363. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7364. } else if ( face == 4.0 ) {
  7365. direction = direction.xzy;
  7366. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7367. } else if ( face == 5.0 ) {
  7368. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7369. }
  7370. return direction;
  7371. }
  7372. void main() {
  7373. vOutputDirection = getDirection( uv, faceIndex );
  7374. gl_Position = vec4( position, 1.0 );
  7375. }
  7376. `}function LIe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===PP||c===RP,d=c===Pm||c===Rm;if(u||d)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new $$(t)),f=u?n.fromEquirectangular(o,f):n.fromCubemap(o,f),e.set(o,f),f.texture}else{if(e.has(o))return e.get(o).texture;{const f=o.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new $$(t));const g=u?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,g),o.addEventListener("dispose",a),g.texture}else return null}}}return o}function i(o){let c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function a(o){const c=o.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function IIe(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 FIe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const b in g.attributes)e.remove(g.attributes[b]);for(const b in g.morphAttributes){const y=g.morphAttributes[b];for(let v=0,x=y.length;v<x;v++)e.remove(y[v])}g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const b in g)e.update(g[b],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const b in m){const y=m[b];for(let v=0,x=y.length;v<x;v++)e.update(y[v],t.ARRAY_BUFFER)}}function u(f){const g=[],m=f.index,b=f.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let S=0,A=M.length;S<A;S+=3){const T=M[S+0],k=M[S+1],N=M[S+2];g.push(T,k,k,N,N,T)}}else if(b!==void 0){const M=b.array;y=b.version;for(let S=0,A=M.length/3-1;S<A;S+=3){const T=S+0,k=S+1,N=S+2;g.push(T,k,k,N,N,T)}}else return;const v=new(UZ(g)?qZ:WZ)(g,1);v.version=y;const x=a.get(f);x&&e.remove(x),a.set(f,v)}function d(f){const g=a.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:o,update:c,getWireframeAttribute:d}}function UIe(t,e,n,r){const i=r.isWebGL2;let a;function s(m){a=m}let o,c;function u(m){o=m.type,c=m.bytesPerElement}function d(m,b){t.drawElements(a,b,o,m*c),n.update(b,a,1)}function f(m,b,y){if(y===0)return;let v,x;if(i)v=t,x="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[x](a,b,o,m*c,y),n.update(b,a,y)}function g(m,b,y){if(y===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<y;x++)this.render(m[x]/c,b[x]);else{v.multiDrawElementsWEBGL(a,b,0,o,m,0,y);let x=0;for(let M=0;M<y;M++)x+=b[M];n.update(x,a,1)}}this.setMode=s,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function zIe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);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 BIe(t,e){return t[0]-e[0]}function HIe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function $Ie(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,s=new Zn,o=[];for(let u=0;u<8;u++)o[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const b=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=b!==void 0?b.length:0;let v=a.get(d);if(v===void 0||v.count!==y){let W=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var m=W;v!==void 0&&v.texture.dispose();const S=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],N=d.morphAttributes.normal||[],I=d.morphAttributes.color||[];let C=0;S===!0&&(C=1),A===!0&&(C=2),T===!0&&(C=3);let D=d.attributes.position.count*C,F=1;D>e.maxTextureSize&&(F=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const O=new Float32Array(D*F*4*y),q=new HZ(O,D,F,y);q.type=xc,q.needsUpdate=!0;const R=C*4;for(let K=0;K<y;K++){const G=k[K],ee=N[K],Z=I[K],Q=D*F*4*K;for(let U=0;U<G.count;U++){const $=U*R;S===!0&&(s.fromBufferAttribute(G,U),O[Q+$+0]=s.x,O[Q+$+1]=s.y,O[Q+$+2]=s.z,O[Q+$+3]=0),A===!0&&(s.fromBufferAttribute(ee,U),O[Q+$+4]=s.x,O[Q+$+5]=s.y,O[Q+$+6]=s.z,O[Q+$+7]=0),T===!0&&(s.fromBufferAttribute(Z,U),O[Q+$+8]=s.x,O[Q+$+9]=s.y,O[Q+$+10]=s.z,O[Q+$+11]=Z.itemSize===4?s.w:1)}}v={count:y,texture:q,size:new Zt(D,F)},a.set(d,v),d.addEventListener("dispose",W)}let x=0;for(let S=0;S<g.length;S++)x+=g[S];const M=d.morphTargetsRelative?1:1-x;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const b=g===void 0?0:g.length;let y=r[d.id];if(y===void 0||y.length!==b){y=[];for(let A=0;A<b;A++)y[A]=[A,0];r[d.id]=y}for(let A=0;A<b;A++){const T=y[A];T[0]=A,T[1]=g[A]}y.sort(HIe);for(let A=0;A<8;A++)A<b&&y[A][1]?(o[A][0]=y[A][0],o[A][1]=y[A][1]):(o[A][0]=Number.MAX_SAFE_INTEGER,o[A][1]=0);o.sort(BIe);const v=d.morphAttributes.position,x=d.morphAttributes.normal;let M=0;for(let A=0;A<8;A++){const T=o[A],k=T[0],N=T[1];k!==Number.MAX_SAFE_INTEGER&&N?(v&&d.getAttribute("morphTarget"+A)!==v[k]&&d.setAttribute("morphTarget"+A,v[k]),x&&d.getAttribute("morphNormal"+A)!==x[k]&&d.setAttribute("morphNormal"+A,x[k]),i[A]=N,M+=N):(v&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),x&&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 VIe(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",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}class QZ extends Xa{constructor(e,n,r,i,a,s,o,c,u,d){if(d=d!==void 0?d:kh,d!==kh&&d!==Dm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===kh&&(r=Hu),r===void 0&&d===Dm&&(r=Nh),super(null,i,a,s,o,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Zi,this.minFilter=c!==void 0?c:Zi,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 JZ=new Xa,eQ=new QZ(1,1);eQ.compareFunction=IZ;const tQ=new HZ,nQ=new COe,rQ=new YZ,q$=[],K$=[],X$=new Float32Array(16),Y$=new Float32Array(9),Z$=new Float32Array(4);function ug(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=q$[i];if(a===void 0&&(a=new Float32Array(i),q$[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function gi(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 xi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function WM(t,e){let n=K$[e];n===void 0&&(n=new Int32Array(e),K$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function GIe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function WIe(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(gi(n,e))return;t.uniform2fv(this.addr,e),xi(n,e)}}function qIe(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(gi(n,e))return;t.uniform3fv(this.addr,e),xi(n,e)}}function KIe(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(gi(n,e))return;t.uniform4fv(this.addr,e),xi(n,e)}}function XIe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;Z$.set(r),t.uniformMatrix2fv(this.addr,!1,Z$),xi(n,r)}}function YIe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;Y$.set(r),t.uniformMatrix3fv(this.addr,!1,Y$),xi(n,r)}}function ZIe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;X$.set(r),t.uniformMatrix4fv(this.addr,!1,X$),xi(n,r)}}function QIe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function JIe(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(gi(n,e))return;t.uniform2iv(this.addr,e),xi(n,e)}}function e5e(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(gi(n,e))return;t.uniform3iv(this.addr,e),xi(n,e)}}function t5e(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(gi(n,e))return;t.uniform4iv(this.addr,e),xi(n,e)}}function n5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function r5e(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(gi(n,e))return;t.uniform2uiv(this.addr,e),xi(n,e)}}function i5e(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(gi(n,e))return;t.uniform3uiv(this.addr,e),xi(n,e)}}function a5e(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(gi(n,e))return;t.uniform4uiv(this.addr,e),xi(n,e)}}function s5e(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?eQ:JZ;n.setTexture2D(e||a,i)}function o5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||nQ,i)}function l5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||rQ,i)}function c5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||tQ,i)}function u5e(t){switch(t){case 5126:return GIe;case 35664:return WIe;case 35665:return qIe;case 35666:return KIe;case 35674:return XIe;case 35675:return YIe;case 35676:return ZIe;case 5124:case 35670:return QIe;case 35667:case 35671:return JIe;case 35668:case 35672:return e5e;case 35669:case 35673:return t5e;case 5125:return n5e;case 36294:return r5e;case 36295:return i5e;case 36296:return a5e;case 35678:case 36198:case 36298:case 36306:case 35682:return s5e;case 35679:case 36299:case 36307:return o5e;case 35680:case 36300:case 36308:case 36293:return l5e;case 36289:case 36303:case 36311:case 36292:return c5e}}function d5e(t,e){t.uniform1fv(this.addr,e)}function h5e(t,e){const n=ug(e,this.size,2);t.uniform2fv(this.addr,n)}function f5e(t,e){const n=ug(e,this.size,3);t.uniform3fv(this.addr,n)}function p5e(t,e){const n=ug(e,this.size,4);t.uniform4fv(this.addr,n)}function m5e(t,e){const n=ug(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function g5e(t,e){const n=ug(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function x5e(t,e){const n=ug(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function b5e(t,e){t.uniform1iv(this.addr,e)}function y5e(t,e){t.uniform2iv(this.addr,e)}function v5e(t,e){t.uniform3iv(this.addr,e)}function _5e(t,e){t.uniform4iv(this.addr,e)}function w5e(t,e){t.uniform1uiv(this.addr,e)}function S5e(t,e){t.uniform2uiv(this.addr,e)}function M5e(t,e){t.uniform3uiv(this.addr,e)}function E5e(t,e){t.uniform4uiv(this.addr,e)}function A5e(t,e,n){const r=this.cache,i=e.length,a=WM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||JZ,a[s])}function T5e(t,e,n){const r=this.cache,i=e.length,a=WM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||nQ,a[s])}function C5e(t,e,n){const r=this.cache,i=e.length,a=WM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||rQ,a[s])}function N5e(t,e,n){const r=this.cache,i=e.length,a=WM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||tQ,a[s])}function k5e(t){switch(t){case 5126:return d5e;case 35664:return h5e;case 35665:return f5e;case 35666:return p5e;case 35674:return m5e;case 35675:return g5e;case 35676:return x5e;case 5124:case 35670:return b5e;case 35667:case 35671:return y5e;case 35668:case 35672:return v5e;case 35669:case 35673:return _5e;case 5125:return w5e;case 36294:return S5e;case 36295:return M5e;case 36296:return E5e;case 35678:case 36198:case 36298:case 36306:case 35682:return A5e;case 35679:case 36299:case 36307:return T5e;case 35680:case 36300:case 36308:case 36293:return C5e;case 36289:case 36303:case 36311:case 36292:return N5e}}class P5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=u5e(n.type)}}class R5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=k5e(n.type)}}class D5e{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}}const _N=/(\w+)(\])?(\[|\.)?/g;function Q$(t,e){t.seq.push(e),t.map[e.id]=e}function j5e(t,e,n){const r=t.name,i=r.length;for(_N.lastIndex=0;;){const a=_N.exec(r),s=_N.lastIndex;let o=a[1];const c=a[2]==="]",u=a[3];if(c&&(o=o|0),u===void 0||u==="["&&s+2===i){Q$(n,u===void 0?new P5e(o,t,e):new R5e(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new D5e(o),Q$(n,f)),n=f}}}class p1{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),s=e.getUniformLocation(n,a.name);j5e(a,s,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,s=n.length;a!==s;++a){const o=n[a],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}}function J$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const O5e=37297;let L5e=0;function I5e(t,e){const n=t.split(`
  7377. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  7378. `)}function F5e(t){const e=Xn.getPrimaries(Xn.workingColorSpace),n=Xn.getPrimaries(t);let r;switch(e===n?r="":e===Lw&&n===Ow?r="LinearDisplayP3ToLinearSRGB":e===Ow&&n===Lw&&(r="LinearSRGBToLinearDisplayP3"),t){case Ic:case VM:return[r,"LinearTransferOETF"];case Qi:case gO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function eV(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 s=parseInt(a[1]);return n.toUpperCase()+`
  7379. `+i+`
  7380. `+I5e(t.getShaderSource(e),s)}else return i}function U5e(t,e){const n=F5e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function z5e(t,e){let n;switch(e){case Uje:n="Linear";break;case zje:n="Reinhard";break;case Bje:n="OptimizedCineon";break;case Hje:n="ACESFilmic";break;case $je:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function B5e(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(Fx).join(`
  7381. `)}function H5e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7382. `)}function $5e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Fx(t){return t!==""}function tV(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 nV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const V5e=/^[ \t]*#include +<([\w\d./]+)>/gm;function FP(t){return t.replace(V5e,W5e)}const G5e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function W5e(t,e){let n=ln[e];if(n===void 0){const r=G5e.get(e);if(r!==void 0)n=ln[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 FP(n)}const q5e=/#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 rV(t){return t.replace(q5e,K5e)}function K5e(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 iV(t){let e="precision "+t.precision+` float;
  7383. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7384. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7385. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7386. #define LOW_PRECISION`),e}function X5e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===AZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===fje?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ac&&(e="SHADOWMAP_TYPE_VSM"),e}function Y5e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Pm:case Rm:e="ENVMAP_TYPE_CUBE";break;case $M:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Z5e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Rm:e="ENVMAP_MODE_REFRACTION";break}return e}function Q5e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case pO:e="ENVMAP_BLENDING_MULTIPLY";break;case Ije:e="ENVMAP_BLENDING_MIX";break;case Fje:e="ENVMAP_BLENDING_ADD";break}return e}function J5e(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 eFe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const c=X5e(n),u=Y5e(n),d=Z5e(n),f=Q5e(n),g=J5e(n),m=n.isWebGL2?"":B5e(n),b=H5e(a),y=i.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
  7387. `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Fx).join(`
  7388. `),v.length>0&&(v+=`
  7389. `),x=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Fx).join(`
  7390. `),x.length>0&&(x+=`
  7391. `)):(v=[iV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7392. `].filter(Fx).join(`
  7393. `),x=[m,iV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Qu?"#define TONE_MAPPING":"",n.toneMapping!==Qu?ln.tonemapping_pars_fragment:"",n.toneMapping!==Qu?z5e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ln.colorspace_pars_fragment,U5e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7394. `].filter(Fx).join(`
  7395. `)),s=FP(s),s=tV(s,n),s=nV(s,n),o=FP(o),o=tV(o,n),o=nV(o,n),s=rV(s),o=rV(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  7396. `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7397. `)+`
  7398. `+v,x=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===w$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===w$?"":"#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(`
  7399. `)+`
  7400. `+x);const S=M+v+s,A=M+x+o,T=J$(i,i.VERTEX_SHADER,S),k=J$(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function N(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(T).trim(),R=i.getShaderInfoLog(k).trim();let W=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const G=eV(i,T,"vertex"),ee=eV(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7401. Program Info Log: `+O+`
  7402. `+G+`
  7403. `+ee)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||R==="")&&(K=!1);K&&(F.diagnostics={runnable:W,programLog:O,vertexShader:{log:q,prefix:v},fragmentShader:{log:R,prefix:x}})}i.deleteShader(T),i.deleteShader(k),I=new p1(i,y),C=$5e(i,y)}let I;this.getUniforms=function(){return I===void 0&&N(this),I};let C;this.getAttributes=function(){return C===void 0&&N(this),C};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,O5e)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=L5e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let tFe=0;class nFe{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),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.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 rFe(e),n.set(e,r)),r}}class rFe{constructor(e){this.id=tFe++,this.code=e,this.usedTimes=0}}function iFe(t,e,n,r,i,a,s){const o=new $Z,c=new nFe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return C===0?"uv":`uv${C}`}function v(C,D,F,O,q){const R=O.fog,W=q.geometry,K=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),ee=G&&G.mapping===$M?G.image.height:null,Z=b[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Q!==void 0?Q.length:0;let $=0;W.morphAttributes.position!==void 0&&($=1),W.morphAttributes.normal!==void 0&&($=2),W.morphAttributes.color!==void 0&&($=3);let X,te,fe,pe;if(Z){const Qt=Va[Z];X=Qt.vertexShader,te=Qt.fragmentShader}else X=C.vertexShader,te=C.fragmentShader,c.update(C),fe=c.getVertexShaderID(C),pe=c.getFragmentShaderID(C);const be=t.getRenderTarget(),Ne=q.isInstancedMesh===!0,ie=q.isBatchedMesh===!0,xe=!!C.map,Re=!!C.matcap,he=!!G,ht=!!C.aoMap,H=!!C.lightMap,B=!!C.bumpMap,re=!!C.normalMap,V=!!C.displacementMap,J=!!C.emissiveMap,se=!!C.metalnessMap,Ae=!!C.roughnessMap,Pe=C.anisotropy>0,Se=C.clearcoat>0,z=C.iridescence>0,L=C.sheen>0,ne=C.transmission>0,ve=Pe&&!!C.anisotropyMap,we=Se&&!!C.clearcoatMap,ye=Se&&!!C.clearcoatNormalMap,nt=Se&&!!C.clearcoatRoughnessMap,Be=z&&!!C.iridescenceMap,ue=z&&!!C.iridescenceThicknessMap,Ve=L&&!!C.sheenColorMap,Fe=L&&!!C.sheenRoughnessMap,oe=!!C.specularMap,et=!!C.specularColorMap,He=!!C.specularIntensityMap,Ke=ne&&!!C.transmissionMap,ct=ne&&!!C.thicknessMap,de=!!C.gradientMap,Ye=!!C.alphaMap,ge=C.alphaTest>0,Ue=!!C.alphaHash,Ce=!!C.extensions,_e=!!W.attributes.uv1,ce=!!W.attributes.uv2,st=!!W.attributes.uv3;let xt=Qu;return C.toneMapped&&(be===null||be.isXRRenderTarget===!0)&&(xt=t.toneMapping),{isWebGL2:d,shaderID:Z,shaderType:C.type,shaderName:C.name,vertexShader:X,fragmentShader:te,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:pe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:ie,instancing:Ne,instancingColor:Ne&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:be===null?t.outputColorSpace:be.isXRRenderTarget===!0?be.texture.colorSpace:Ic,map:xe,matcap:Re,envMap:he,envMapMode:he&&G.mapping,envMapCubeUVHeight:ee,aoMap:ht,lightMap:H,bumpMap:B,normalMap:re,displacementMap:g&&V,emissiveMap:J,normalMapObjectSpace:re&&C.normalMapType===tOe,normalMapTangentSpace:re&&C.normalMapType===LZ,metalnessMap:se,roughnessMap:Ae,anisotropy:Pe,anisotropyMap:ve,clearcoat:Se,clearcoatMap:we,clearcoatNormalMap:ye,clearcoatRoughnessMap:nt,iridescence:z,iridescenceMap:Be,iridescenceThicknessMap:ue,sheen:L,sheenColorMap:Ve,sheenRoughnessMap:Fe,specularMap:oe,specularColorMap:et,specularIntensityMap:He,transmission:ne,transmissionMap:Ke,thicknessMap:ct,gradientMap:de,opaque:C.transparent===!1&&C.blending===am,alphaMap:Ye,alphaTest:ge,alphaHash:Ue,combine:C.combine,mapUv:xe&&y(C.map.channel),aoMapUv:ht&&y(C.aoMap.channel),lightMapUv:H&&y(C.lightMap.channel),bumpMapUv:B&&y(C.bumpMap.channel),normalMapUv:re&&y(C.normalMap.channel),displacementMapUv:V&&y(C.displacementMap.channel),emissiveMapUv:J&&y(C.emissiveMap.channel),metalnessMapUv:se&&y(C.metalnessMap.channel),roughnessMapUv:Ae&&y(C.roughnessMap.channel),anisotropyMapUv:ve&&y(C.anisotropyMap.channel),clearcoatMapUv:we&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:ye&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:nt&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Be&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:ue&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&y(C.sheenRoughnessMap.channel),specularMapUv:oe&&y(C.specularMap.channel),specularColorMapUv:et&&y(C.specularColorMap.channel),specularIntensityMapUv:He&&y(C.specularIntensityMap.channel),transmissionMapUv:Ke&&y(C.transmissionMap.channel),thicknessMapUv:ct&&y(C.thicknessMap.channel),alphaMapUv:Ye&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(re||Pe),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:_e,vertexUv2s:ce,vertexUv3s:st,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(xe||Ye),fog:!!R,useFog:C.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:$,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:xe&&C.map.isVideoTexture===!0&&Xn.getTransfer(C.map.colorSpace)===lr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===dc,flipSided:C.side===Ka,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Ce&&C.extensions.derivatives===!0,extensionFragDepth:Ce&&C.extensions.fragDepth===!0,extensionDrawBuffers:Ce&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ce&&C.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()}}function x(C){const D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)D.push(F),D.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(M(D,C),S(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function M(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function S(C,D){o.disableAll(),D.isWebGL2&&o.enable(0),D.supportsVertexTextures&&o.enable(1),D.instancing&&o.enable(2),D.instancingColor&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),C.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.skinning&&o.enable(4),D.morphTargets&&o.enable(5),D.morphNormals&&o.enable(6),D.morphColors&&o.enable(7),D.premultipliedAlpha&&o.enable(8),D.shadowMapEnabled&&o.enable(9),D.useLegacyLights&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),C.push(o.mask)}function A(C){const D=b[C.type];let F;if(D){const O=Va[D];F=yO.clone(O.uniforms)}else F=C.uniforms;return F}function T(C,D){let F;for(let O=0,q=u.length;O<q;O++){const R=u[O];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new eFe(t,D,C,a),u.push(F)),F}function k(C){if(--C.usedTimes===0){const D=u.indexOf(C);u[D]=u[u.length-1],u.pop(),C.destroy()}}function N(C){c.remove(C)}function I(){c.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:u,dispose:I}}function aFe(){let t=new WeakMap;function e(a){let s=t.get(a);return s===void 0&&(s={},t.set(a,s)),s}function n(a){t.delete(a)}function r(a,s,o){t.get(a)[s]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function sFe(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 aV(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 sV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,m,b,y,v){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:g,material:m,groupOrder:b,renderOrder:f.renderOrder,z:y,group:v},t[e]=x):(x.id=f.id,x.object=f,x.geometry=g,x.material=m,x.groupOrder=b,x.renderOrder=f.renderOrder,x.z=y,x.group=v),e++,x}function o(f,g,m,b,y,v){const x=s(f,g,m,b,y,v);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function c(f,g,m,b,y,v){const x=s(f,g,m,b,y,v);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function u(f,g){n.length>1&&n.sort(f||sFe),r.length>1&&r.sort(g||aV),i.length>1&&i.sort(g||aV)}function d(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:c,finish:d,sort:u}}function oFe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new sV,t.set(r,[s])):i>=a.length?(s=new sV,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function lFe(){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 je,color:new $t};break;case"SpotLight":n={position:new je,direction:new je,color:new $t,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new je,color:new $t,distance:0,decay:0};break;case"HemisphereLight":n={direction:new je,skyColor:new $t,groundColor:new $t};break;case"RectAreaLight":n={color:new $t,position:new je,halfWidth:new je,halfHeight:new je};break}return t[e.id]=n,n}}}function cFe(){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 Zt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let uFe=0;function dFe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function hFe(t,e){const n=new lFe,r=cFe(),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 je);const a=new je,s=new ar,o=new ar;function c(d,f){let g=0,m=0,b=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let y=0,v=0,x=0,M=0,S=0,A=0,T=0,k=0,N=0,I=0,C=0;d.sort(dFe);const D=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const R=d[O],W=R.color,K=R.intensity,G=R.distance,ee=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=W.r*K*D,m+=W.g*K*D,b+=W.b*K*D;else if(R.isLightProbe){for(let Z=0;Z<9;Z++)i.probe[Z].addScaledVector(R.sh.coefficients[Z],K);C++}else if(R.isDirectionalLight){const Z=n.get(R);if(Z.color.copy(R.color).multiplyScalar(R.intensity*D),R.castShadow){const Q=R.shadow,U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,i.directionalShadow[y]=U,i.directionalShadowMap[y]=ee,i.directionalShadowMatrix[y]=R.shadow.matrix,A++}i.directional[y]=Z,y++}else if(R.isSpotLight){const Z=n.get(R);Z.position.setFromMatrixPosition(R.matrixWorld),Z.color.copy(W).multiplyScalar(K*D),Z.distance=G,Z.coneCos=Math.cos(R.angle),Z.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Z.decay=R.decay,i.spot[x]=Z;const Q=R.shadow;if(R.map&&(i.spotLightMap[N]=R.map,N++,Q.updateMatrices(R),R.castShadow&&I++),i.spotLightMatrix[x]=Q.matrix,R.castShadow){const U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,i.spotShadow[x]=U,i.spotShadowMap[x]=ee,k++}x++}else if(R.isRectAreaLight){const Z=n.get(R);Z.color.copy(W).multiplyScalar(K),Z.halfWidth.set(R.width*.5,0,0),Z.halfHeight.set(0,R.height*.5,0),i.rectArea[M]=Z,M++}else if(R.isPointLight){const Z=n.get(R);if(Z.color.copy(R.color).multiplyScalar(R.intensity*D),Z.distance=R.distance,Z.decay=R.decay,R.castShadow){const Q=R.shadow,U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,U.shadowCameraNear=Q.camera.near,U.shadowCameraFar=Q.camera.far,i.pointShadow[v]=U,i.pointShadowMap[v]=ee,i.pointShadowMatrix[v]=R.shadow.matrix,T++}i.point[v]=Z,v++}else if(R.isHemisphereLight){const Z=n.get(R);Z.skyColor.copy(R.color).multiplyScalar(K*D),Z.groundColor.copy(R.groundColor).multiplyScalar(K*D),i.hemi[S]=Z,S++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=_t.LTC_FLOAT_1,i.rectAreaLTC2=_t.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=_t.LTC_HALF_1,i.rectAreaLTC2=_t.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=m,i.ambient[2]=b;const F=i.hash;(F.directionalLength!==y||F.pointLength!==v||F.spotLength!==x||F.rectAreaLength!==M||F.hemiLength!==S||F.numDirectionalShadows!==A||F.numPointShadows!==T||F.numSpotShadows!==k||F.numSpotMaps!==N||F.numLightProbes!==C)&&(i.directional.length=y,i.spot.length=x,i.rectArea.length=M,i.point.length=v,i.hemi.length=S,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=k+N-I,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=C,F.directionalLength=y,F.pointLength=v,F.spotLength=x,F.rectAreaLength=M,F.hemiLength=S,F.numDirectionalShadows=A,F.numPointShadows=T,F.numSpotShadows=k,F.numSpotMaps=N,F.numLightProbes=C,i.version=uFe++)}function u(d,f){let g=0,m=0,b=0,y=0,v=0;const x=f.matrixWorldInverse;for(let M=0,S=d.length;M<S;M++){const A=d[M];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),g++}else if(A.isSpotLight){const T=i.spot[b];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),b++}else if(A.isRectAreaLight){const T=i.rectArea[y];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),o.identity(),s.copy(A.matrixWorld),s.premultiply(x),o.extractRotation(s),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),y++}else if(A.isPointLight){const T=i.point[m];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(x),m++}else if(A.isHemisphereLight){const T=i.hemi[v];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(x),v++}}}return{setup:c,setupView:u,state:i}}function oV(t,e){const n=new hFe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function s(f){r.push(f)}function o(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:s,pushShadow:o}}function fFe(t,e){let n=new WeakMap;function r(a,s=0){const o=n.get(a);let c;return o===void 0?(c=new oV(t,e),n.set(a,[c])):s>=o.length?(c=new oV(t,e),o.push(c)):c=o[s],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class pFe extends cg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jje,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 mFe extends cg{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const gFe=`void main() {
  7404. gl_Position = vec4( position, 1.0 );
  7405. }`,xFe=`uniform sampler2D shadow_pass;
  7406. uniform vec2 resolution;
  7407. uniform float radius;
  7408. #include <packing>
  7409. void main() {
  7410. const float samples = float( VSM_SAMPLES );
  7411. float mean = 0.0;
  7412. float squared_mean = 0.0;
  7413. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7414. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7415. for ( float i = 0.0; i < samples; i ++ ) {
  7416. float uvOffset = uvStart + i * uvStride;
  7417. #ifdef HORIZONTAL_PASS
  7418. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7419. mean += distribution.x;
  7420. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7421. #else
  7422. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7423. mean += depth;
  7424. squared_mean += depth * depth;
  7425. #endif
  7426. }
  7427. mean = mean / samples;
  7428. squared_mean = squared_mean / samples;
  7429. float std_dev = sqrt( squared_mean - mean * mean );
  7430. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7431. }`;function bFe(t,e,n){let r=new GM;const i=new Zt,a=new Zt,s=new Zn,o=new pFe({depthPacking:eOe}),c=new mFe,u={},d=n.maxTextureSize,f={[fd]:Ka,[Ka]:fd,[dc]:dc},g=new pd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Zt},radius:{value:4}},vertexShader:gFe,fragmentShader:xFe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const b=new ga;b.setAttribute("position",new Ss(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new jo(b,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=AZ;let x=this.type;this.render=function(T,k,N){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const I=t.getRenderTarget(),C=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Zu),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const O=x!==ac&&this.type===ac,q=x===ac&&this.type!==ac;for(let R=0,W=T.length;R<W;R++){const K=T[R],G=K.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const ee=G.getFrameExtents();if(i.multiply(ee),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/ee.x),i.x=a.x*ee.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/ee.y),i.y=a.y*ee.y,G.mapSize.y=a.y)),G.map===null||O===!0||q===!0){const Q=this.type!==ac?{minFilter:Zi,magFilter:Zi}:{};G.map!==null&&G.map.dispose(),G.map=new nf(i.x,i.y,Q),G.map.texture.name=K.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const Z=G.getViewportCount();for(let Q=0;Q<Z;Q++){const U=G.getViewport(Q);s.set(a.x*U.x,a.y*U.y,a.x*U.z,a.y*U.w),F.viewport(s),G.updateMatrices(K,Q),r=G.getFrustum(),A(k,N,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===ac&&M(G,N),G.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(I,C,D)};function M(T,k){const N=e.update(y);g.defines.VSM_SAMPLES!==T.blurSamples&&(g.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new nf(i.x,i.y)),g.uniforms.shadow_pass.value=T.map.texture,g.uniforms.resolution.value=T.mapSize,g.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(k,null,N,g,y,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(k,null,N,m,y,null)}function S(T,k,N,I){let C=null;const D=N.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)C=D;else if(C=N.isPointLight===!0?c:o,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=C.uuid,O=k.uuid;let q=u[F];q===void 0&&(q={},u[F]=q);let R=q[O];R===void 0&&(R=C.clone(),q[O]=R),C=R}if(C.visible=k.visible,C.wireframe=k.wireframe,I===ac?C.side=k.shadowSide!==null?k.shadowSide:k.side:C.side=k.shadowSide!==null?k.shadowSide:f[k.side],C.alphaMap=k.alphaMap,C.alphaTest=k.alphaTest,C.map=k.map,C.clipShadows=k.clipShadows,C.clippingPlanes=k.clippingPlanes,C.clipIntersection=k.clipIntersection,C.displacementMap=k.displacementMap,C.displacementScale=k.displacementScale,C.displacementBias=k.displacementBias,C.wireframeLinewidth=k.wireframeLinewidth,C.linewidth=k.linewidth,N.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const F=t.properties.get(C);F.light=N}return C}function A(T,k,N,I,C){if(T.visible===!1)return;if(T.layers.test(k.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&C===ac)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const O=e.update(T),q=T.material;if(Array.isArray(q)){const R=O.groups;for(let W=0,K=R.length;W<K;W++){const G=R[W],ee=q[G.materialIndex];if(ee&&ee.visible){const Z=S(T,ee,I,C);T.onBeforeShadow(t,T,k,N,O,Z,G),t.renderBufferDirect(N,null,O,Z,T,G),T.onAfterShadow(t,T,k,N,O,Z,G)}}}else if(q.visible){const R=S(T,q,I,C);T.onBeforeShadow(t,T,k,N,O,R,null),t.renderBufferDirect(N,null,O,R,T,null),T.onAfterShadow(t,T,k,N,O,R,null)}}const F=T.children;for(let O=0,q=F.length;O<q;O++)A(F[O],k,N,I,C)}}function yFe(t,e,n){const r=n.isWebGL2;function i(){let ge=!1;const Ue=new Zn;let Ce=null;const _e=new Zn(0,0,0,0);return{setMask:function(ce){Ce!==ce&&!ge&&(t.colorMask(ce,ce,ce,ce),Ce=ce)},setLocked:function(ce){ge=ce},setClear:function(ce,st,xt,St,Qt){Qt===!0&&(ce*=St,st*=St,xt*=St),Ue.set(ce,st,xt,St),_e.equals(Ue)===!1&&(t.clearColor(ce,st,xt,St),_e.copy(Ue))},reset:function(){ge=!1,Ce=null,_e.set(-1,0,0,0)}}}function a(){let ge=!1,Ue=null,Ce=null,_e=null;return{setTest:function(ce){ce?ie(t.DEPTH_TEST):xe(t.DEPTH_TEST)},setMask:function(ce){Ue!==ce&&!ge&&(t.depthMask(ce),Ue=ce)},setFunc:function(ce){if(Ce!==ce){switch(ce){case kje:t.depthFunc(t.NEVER);break;case Pje:t.depthFunc(t.ALWAYS);break;case Rje:t.depthFunc(t.LESS);break;case Dw:t.depthFunc(t.LEQUAL);break;case Dje:t.depthFunc(t.EQUAL);break;case jje:t.depthFunc(t.GEQUAL);break;case Oje:t.depthFunc(t.GREATER);break;case Lje:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ce=ce}},setLocked:function(ce){ge=ce},setClear:function(ce){_e!==ce&&(t.clearDepth(ce),_e=ce)},reset:function(){ge=!1,Ue=null,Ce=null,_e=null}}}function s(){let ge=!1,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null,St=null,Qt=null;return{setTest:function(Ot){ge||(Ot?ie(t.STENCIL_TEST):xe(t.STENCIL_TEST))},setMask:function(Ot){Ue!==Ot&&!ge&&(t.stencilMask(Ot),Ue=Ot)},setFunc:function(Ot,Vt,On){(Ce!==Ot||_e!==Vt||ce!==On)&&(t.stencilFunc(Ot,Vt,On),Ce=Ot,_e=Vt,ce=On)},setOp:function(Ot,Vt,On){(st!==Ot||xt!==Vt||St!==On)&&(t.stencilOp(Ot,Vt,On),st=Ot,xt=Vt,St=On)},setLocked:function(Ot){ge=Ot},setClear:function(Ot){Qt!==Ot&&(t.clearStencil(Ot),Qt=Ot)},reset:function(){ge=!1,Ue=null,Ce=null,_e=null,ce=null,st=null,xt=null,St=null,Qt=null}}}const o=new i,c=new a,u=new s,d=new WeakMap,f=new WeakMap;let g={},m={},b=new WeakMap,y=[],v=null,x=!1,M=null,S=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,O=null,q=null,R=null,W=null,K=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ee=!1,Z=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(Q)[1]),ee=Z>=1):Q.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),ee=Z>=2);let U=null,$={};const X=t.getParameter(t.SCISSOR_BOX),te=t.getParameter(t.VIEWPORT),fe=new Zn().fromArray(X),pe=new Zn().fromArray(te);function be(ge,Ue,Ce,_e){const ce=new Uint8Array(4),st=t.createTexture();t.bindTexture(ge,st),t.texParameteri(ge,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ge,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let xt=0;xt<Ce;xt++)r&&(ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ue,0,t.RGBA,1,1,_e,0,t.RGBA,t.UNSIGNED_BYTE,ce):t.texImage2D(Ue+xt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ce);return st}const Ne={};Ne[t.TEXTURE_2D]=be(t.TEXTURE_2D,t.TEXTURE_2D,1),Ne[t.TEXTURE_CUBE_MAP]=be(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ne[t.TEXTURE_2D_ARRAY]=be(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ne[t.TEXTURE_3D]=be(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ie(t.DEPTH_TEST),c.setFunc(Dw),J(!1),se($H),ie(t.CULL_FACE),re(Zu);function ie(ge){g[ge]!==!0&&(t.enable(ge),g[ge]=!0)}function xe(ge){g[ge]!==!1&&(t.disable(ge),g[ge]=!1)}function Re(ge,Ue){return m[ge]!==Ue?(t.bindFramebuffer(ge,Ue),m[ge]=Ue,r&&(ge===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ue),ge===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ue)),!0):!1}function he(ge,Ue){let Ce=y,_e=!1;if(ge)if(Ce=b.get(Ue),Ce===void 0&&(Ce=[],b.set(Ue,Ce)),ge.isWebGLMultipleRenderTargets){const ce=ge.texture;if(Ce.length!==ce.length||Ce[0]!==t.COLOR_ATTACHMENT0){for(let st=0,xt=ce.length;st<xt;st++)Ce[st]=t.COLOR_ATTACHMENT0+st;Ce.length=ce.length,_e=!0}}else Ce[0]!==t.COLOR_ATTACHMENT0&&(Ce[0]=t.COLOR_ATTACHMENT0,_e=!0);else Ce[0]!==t.BACK&&(Ce[0]=t.BACK,_e=!0);_e&&(n.isWebGL2?t.drawBuffers(Ce):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ce))}function ht(ge){return v!==ge?(t.useProgram(ge),v=ge,!0):!1}const H={[ch]:t.FUNC_ADD,[mje]:t.FUNC_SUBTRACT,[gje]:t.FUNC_REVERSE_SUBTRACT};if(r)H[qH]=t.MIN,H[KH]=t.MAX;else{const ge=e.get("EXT_blend_minmax");ge!==null&&(H[qH]=ge.MIN_EXT,H[KH]=ge.MAX_EXT)}const B={[xje]:t.ZERO,[bje]:t.ONE,[yje]:t.SRC_COLOR,[NP]:t.SRC_ALPHA,[Eje]:t.SRC_ALPHA_SATURATE,[Sje]:t.DST_COLOR,[_je]:t.DST_ALPHA,[vje]:t.ONE_MINUS_SRC_COLOR,[kP]:t.ONE_MINUS_SRC_ALPHA,[Mje]:t.ONE_MINUS_DST_COLOR,[wje]:t.ONE_MINUS_DST_ALPHA,[Aje]:t.CONSTANT_COLOR,[Tje]:t.ONE_MINUS_CONSTANT_COLOR,[Cje]:t.CONSTANT_ALPHA,[Nje]:t.ONE_MINUS_CONSTANT_ALPHA};function re(ge,Ue,Ce,_e,ce,st,xt,St,Qt,Ot){if(ge===Zu){x===!0&&(xe(t.BLEND),x=!1);return}if(x===!1&&(ie(t.BLEND),x=!0),ge!==pje){if(ge!==M||Ot!==F){if((S!==ch||k!==ch)&&(t.blendEquation(t.FUNC_ADD),S=ch,k=ch),Ot)switch(ge){case am:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case VH:t.blendFunc(t.ONE,t.ONE);break;case GH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case WH:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}else switch(ge){case am:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case VH:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case GH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case WH:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}A=null,T=null,N=null,I=null,C.set(0,0,0),D=0,M=ge,F=Ot}return}ce=ce||Ue,st=st||Ce,xt=xt||_e,(Ue!==S||ce!==k)&&(t.blendEquationSeparate(H[Ue],H[ce]),S=Ue,k=ce),(Ce!==A||_e!==T||st!==N||xt!==I)&&(t.blendFuncSeparate(B[Ce],B[_e],B[st],B[xt]),A=Ce,T=_e,N=st,I=xt),(St.equals(C)===!1||Qt!==D)&&(t.blendColor(St.r,St.g,St.b,Qt),C.copy(St),D=Qt),M=ge,F=!1}function V(ge,Ue){ge.side===dc?xe(t.CULL_FACE):ie(t.CULL_FACE);let Ce=ge.side===Ka;Ue&&(Ce=!Ce),J(Ce),ge.blending===am&&ge.transparent===!1?re(Zu):re(ge.blending,ge.blendEquation,ge.blendSrc,ge.blendDst,ge.blendEquationAlpha,ge.blendSrcAlpha,ge.blendDstAlpha,ge.blendColor,ge.blendAlpha,ge.premultipliedAlpha),c.setFunc(ge.depthFunc),c.setTest(ge.depthTest),c.setMask(ge.depthWrite),o.setMask(ge.colorWrite);const _e=ge.stencilWrite;u.setTest(_e),_e&&(u.setMask(ge.stencilWriteMask),u.setFunc(ge.stencilFunc,ge.stencilRef,ge.stencilFuncMask),u.setOp(ge.stencilFail,ge.stencilZFail,ge.stencilZPass)),Pe(ge.polygonOffset,ge.polygonOffsetFactor,ge.polygonOffsetUnits),ge.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):xe(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(ge){O!==ge&&(ge?t.frontFace(t.CW):t.frontFace(t.CCW),O=ge)}function se(ge){ge!==dje?(ie(t.CULL_FACE),ge!==q&&(ge===$H?t.cullFace(t.BACK):ge===hje?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):xe(t.CULL_FACE),q=ge}function Ae(ge){ge!==R&&(ee&&t.lineWidth(ge),R=ge)}function Pe(ge,Ue,Ce){ge?(ie(t.POLYGON_OFFSET_FILL),(W!==Ue||K!==Ce)&&(t.polygonOffset(Ue,Ce),W=Ue,K=Ce)):xe(t.POLYGON_OFFSET_FILL)}function Se(ge){ge?ie(t.SCISSOR_TEST):xe(t.SCISSOR_TEST)}function z(ge){ge===void 0&&(ge=t.TEXTURE0+G-1),U!==ge&&(t.activeTexture(ge),U=ge)}function L(ge,Ue,Ce){Ce===void 0&&(U===null?Ce=t.TEXTURE0+G-1:Ce=U);let _e=$[Ce];_e===void 0&&(_e={type:void 0,texture:void 0},$[Ce]=_e),(_e.type!==ge||_e.texture!==Ue)&&(U!==Ce&&(t.activeTexture(Ce),U=Ce),t.bindTexture(ge,Ue||Ne[ge]),_e.type=ge,_e.texture=Ue)}function ne(){const ge=$[U];ge!==void 0&&ge.type!==void 0&&(t.bindTexture(ge.type,null),ge.type=void 0,ge.texture=void 0)}function ve(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ye(){try{t.texSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function nt(){try{t.texSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Be(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ue(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ve(){try{t.texStorage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Fe(){try{t.texStorage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function oe(){try{t.texImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function et(){try{t.texImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function He(ge){fe.equals(ge)===!1&&(t.scissor(ge.x,ge.y,ge.z,ge.w),fe.copy(ge))}function Ke(ge){pe.equals(ge)===!1&&(t.viewport(ge.x,ge.y,ge.z,ge.w),pe.copy(ge))}function ct(ge,Ue){let Ce=f.get(Ue);Ce===void 0&&(Ce=new WeakMap,f.set(Ue,Ce));let _e=Ce.get(ge);_e===void 0&&(_e=t.getUniformBlockIndex(Ue,ge.name),Ce.set(ge,_e))}function de(ge,Ue){const _e=f.get(Ue).get(ge);d.get(Ue)!==_e&&(t.uniformBlockBinding(Ue,_e,ge.__bindingPointIndex),d.set(Ue,_e))}function Ye(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},U=null,$={},m={},b=new WeakMap,y=[],v=null,x=!1,M=null,S=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,O=null,q=null,R=null,W=null,K=null,fe.set(0,0,t.canvas.width,t.canvas.height),pe.set(0,0,t.canvas.width,t.canvas.height),o.reset(),c.reset(),u.reset()}return{buffers:{color:o,depth:c,stencil:u},enable:ie,disable:xe,bindFramebuffer:Re,drawBuffers:he,useProgram:ht,setBlending:re,setMaterial:V,setFlipSided:J,setCullFace:se,setLineWidth:Ae,setPolygonOffset:Pe,setScissorTest:Se,activeTexture:z,bindTexture:L,unbindTexture:ne,compressedTexImage2D:ve,compressedTexImage3D:we,texImage2D:oe,texImage3D:et,updateUBOMapping:ct,uniformBlockBinding:de,texStorage2D:Ve,texStorage3D:Fe,texSubImage2D:ye,texSubImage3D:nt,compressedTexSubImage2D:Be,compressedTexSubImage3D:ue,scissor:He,viewport:Ke,reset:Ye}}function vFe(t,e,n,r,i,a,s){const o=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),b=new WeakMap;let y;const v=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(z,L){return x?new OffscreenCanvas(z,L):Fw("canvas")}function S(z,L,ne,ve){let we=1;if((z.width>ve||z.height>ve)&&(we=ve/Math.max(z.width,z.height)),we<1||L===!0)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap){const ye=L?Iw:Math.floor,nt=ye(we*z.width),Be=ye(we*z.height);y===void 0&&(y=M(nt,Be));const ue=ne?M(nt,Be):y;return ue.width=nt,ue.height=Be,ue.getContext("2d").drawImage(z,0,0,nt,Be),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+nt+"x"+Be+")."),ue}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),z;return z}function A(z){return IP(z.width)&&IP(z.height)}function T(z){return o?!1:z.wrapS!==ko||z.wrapT!==ko||z.minFilter!==Zi&&z.minFilter!==Zs}function k(z,L){return z.generateMipmaps&&L&&z.minFilter!==Zi&&z.minFilter!==Zs}function N(z){t.generateMipmap(z)}function I(z,L,ne,ve,we=!1){if(o===!1)return L;if(z!==null){if(t[z]!==void 0)return t[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let ye=L;if(L===t.RED&&(ne===t.FLOAT&&(ye=t.R32F),ne===t.HALF_FLOAT&&(ye=t.R16F),ne===t.UNSIGNED_BYTE&&(ye=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.R8UI),ne===t.UNSIGNED_SHORT&&(ye=t.R16UI),ne===t.UNSIGNED_INT&&(ye=t.R32UI),ne===t.BYTE&&(ye=t.R8I),ne===t.SHORT&&(ye=t.R16I),ne===t.INT&&(ye=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ye=t.RG32F),ne===t.HALF_FLOAT&&(ye=t.RG16F),ne===t.UNSIGNED_BYTE&&(ye=t.RG8)),L===t.RGBA){const nt=we?jw:Xn.getTransfer(ve);ne===t.FLOAT&&(ye=t.RGBA32F),ne===t.HALF_FLOAT&&(ye=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ye=nt===lr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function C(z,L,ne){return k(z,ne)===!0||z.isFramebufferTexture&&z.minFilter!==Zi&&z.minFilter!==Zs?Math.log2(Math.max(L.width,L.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?L.mipmaps.length:1}function D(z){return z===Zi||z===XH||z===KC?t.NEAREST:t.LINEAR}function F(z){const L=z.target;L.removeEventListener("dispose",F),q(L),L.isVideoTexture&&b.delete(L)}function O(z){const L=z.target;L.removeEventListener("dispose",O),W(L)}function q(z){const L=r.get(z);if(L.__webglInit===void 0)return;const ne=z.source,ve=v.get(ne);if(ve){const we=ve[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&R(z),Object.keys(ve).length===0&&v.delete(ne)}r.remove(z)}function R(z){const L=r.get(z);t.deleteTexture(L.__webglTexture);const ne=z.source,ve=v.get(ne);delete ve[L.__cacheKey],s.memory.textures--}function W(z){const L=z.texture,ne=r.get(z),ve=r.get(L);if(ve.__webglTexture!==void 0&&(t.deleteTexture(ve.__webglTexture),s.memory.textures--),z.depthTexture&&z.depthTexture.dispose(),z.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(ne.__webglFramebuffer[we]))for(let ye=0;ye<ne.__webglFramebuffer[we].length;ye++)t.deleteFramebuffer(ne.__webglFramebuffer[we][ye]);else t.deleteFramebuffer(ne.__webglFramebuffer[we]);ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer[we])}else{if(Array.isArray(ne.__webglFramebuffer))for(let we=0;we<ne.__webglFramebuffer.length;we++)t.deleteFramebuffer(ne.__webglFramebuffer[we]);else t.deleteFramebuffer(ne.__webglFramebuffer);if(ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let we=0;we<ne.__webglColorRenderbuffer.length;we++)ne.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(ne.__webglColorRenderbuffer[we]);ne.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(z.isWebGLMultipleRenderTargets)for(let we=0,ye=L.length;we<ye;we++){const nt=r.get(L[we]);nt.__webglTexture&&(t.deleteTexture(nt.__webglTexture),s.memory.textures--),r.remove(L[we])}r.remove(L),r.remove(z)}let K=0;function G(){K=0}function ee(){const z=K;return z>=c&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+c),K+=1,z}function Z(z){const L=[];return L.push(z.wrapS),L.push(z.wrapT),L.push(z.wrapR||0),L.push(z.magFilter),L.push(z.minFilter),L.push(z.anisotropy),L.push(z.internalFormat),L.push(z.format),L.push(z.type),L.push(z.generateMipmaps),L.push(z.premultiplyAlpha),L.push(z.flipY),L.push(z.unpackAlignment),L.push(z.colorSpace),L.join()}function Q(z,L){const ne=r.get(z);if(z.isVideoTexture&&Pe(z),z.isRenderTargetTexture===!1&&z.version>0&&ne.__version!==z.version){const ve=z.image;if(ve===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ne,z,L);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function U(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){ie(ne,z,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function $(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){ie(ne,z,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function X(z,L){const ne=r.get(z);if(z.version>0&&ne.__version!==z.version){xe(ne,z,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const te={[DP]:t.REPEAT,[ko]:t.CLAMP_TO_EDGE,[jP]:t.MIRRORED_REPEAT},fe={[Zi]:t.NEAREST,[XH]:t.NEAREST_MIPMAP_NEAREST,[KC]:t.NEAREST_MIPMAP_LINEAR,[Zs]:t.LINEAR,[Vje]:t.LINEAR_MIPMAP_NEAREST,[K0]:t.LINEAR_MIPMAP_LINEAR},pe={[nOe]:t.NEVER,[lOe]:t.ALWAYS,[rOe]:t.LESS,[IZ]:t.LEQUAL,[iOe]:t.EQUAL,[oOe]:t.GEQUAL,[aOe]:t.GREATER,[sOe]:t.NOTEQUAL};function be(z,L,ne){if(ne?(t.texParameteri(z,t.TEXTURE_WRAP_S,te[L.wrapS]),t.texParameteri(z,t.TEXTURE_WRAP_T,te[L.wrapT]),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,te[L.wrapR]),t.texParameteri(z,t.TEXTURE_MAG_FILTER,fe[L.magFilter]),t.texParameteri(z,t.TEXTURE_MIN_FILTER,fe[L.minFilter])):(t.texParameteri(z,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(z,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(z===t.TEXTURE_3D||z===t.TEXTURE_2D_ARRAY)&&t.texParameteri(z,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==ko||L.wrapT!==ko)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(z,t.TEXTURE_MAG_FILTER,D(L.magFilter)),t.texParameteri(z,t.TEXTURE_MIN_FILTER,D(L.minFilter)),L.minFilter!==Zi&&L.minFilter!==Zs&&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(z,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(z,t.TEXTURE_COMPARE_FUNC,pe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ve=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Zi||L.minFilter!==KC&&L.minFilter!==K0||L.type===xc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===X0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(z,ve.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ne(z,L){let ne=!1;z.__webglInit===void 0&&(z.__webglInit=!0,L.addEventListener("dispose",F));const ve=L.source;let we=v.get(ve);we===void 0&&(we={},v.set(ve,we));const ye=Z(L);if(ye!==z.__cacheKey){we[ye]===void 0&&(we[ye]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),we[ye].usedTimes++;const nt=we[z.__cacheKey];nt!==void 0&&(we[z.__cacheKey].usedTimes--,nt.usedTimes===0&&R(L)),z.__cacheKey=ye,z.__webglTexture=we[ye].texture}return ne}function ie(z,L,ne){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const we=Ne(z,L),ye=L.source;n.bindTexture(ve,z.__webglTexture,t.TEXTURE0+ne);const nt=r.get(ye);if(ye.version!==nt.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Be=Xn.getPrimaries(Xn.workingColorSpace),ue=L.colorSpace===Js?null:Xn.getPrimaries(L.colorSpace),Ve=L.colorSpace===Js||Be===ue?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,Ve);const Fe=T(L)&&A(L.image)===!1;let oe=S(L.image,Fe,!1,d);oe=Se(L,oe);const et=A(oe)||o,He=a.convert(L.format,L.colorSpace);let Ke=a.convert(L.type),ct=I(L.internalFormat,He,Ke,L.colorSpace,L.isVideoTexture);be(ve,L,et);let de;const Ye=L.mipmaps,ge=o&&L.isVideoTexture!==!0&&ct!==jZ,Ue=nt.__version===void 0||we===!0,Ce=C(L,oe,et);if(L.isDepthTexture)ct=t.DEPTH_COMPONENT,o?L.type===xc?ct=t.DEPTH_COMPONENT32F:L.type===Hu?ct=t.DEPTH_COMPONENT24:L.type===Nh?ct=t.DEPTH24_STENCIL8:ct=t.DEPTH_COMPONENT16:L.type===xc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===kh&&ct===t.DEPTH_COMPONENT&&L.type!==mO&&L.type!==Hu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Hu,Ke=a.convert(L.type)),L.format===Dm&&ct===t.DEPTH_COMPONENT&&(ct=t.DEPTH_STENCIL,L.type!==Nh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Nh,Ke=a.convert(L.type))),Ue&&(ge?n.texStorage2D(t.TEXTURE_2D,1,ct,oe.width,oe.height):n.texImage2D(t.TEXTURE_2D,0,ct,oe.width,oe.height,0,He,Ke,null));else if(L.isDataTexture)if(Ye.length>0&&et){ge&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],ge?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,de.width,de.height,He,Ke,de.data):n.texImage2D(t.TEXTURE_2D,_e,ct,de.width,de.height,0,He,Ke,de.data);L.generateMipmaps=!1}else ge?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe.width,oe.height,He,Ke,oe.data)):n.texImage2D(t.TEXTURE_2D,0,ct,oe.width,oe.height,0,He,Ke,oe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ge&&Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,ct,Ye[0].width,Ye[0].height,oe.depth);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],L.format!==Qs?He!==null?ge?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,de.width,de.height,oe.depth,He,de.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,_e,ct,de.width,de.height,oe.depth,0,de.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,de.width,de.height,oe.depth,He,Ke,de.data):n.texImage3D(t.TEXTURE_2D_ARRAY,_e,ct,de.width,de.height,oe.depth,0,He,Ke,de.data)}else{ge&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],L.format!==Qs?He!==null?ge?n.compressedTexSubImage2D(t.TEXTURE_2D,_e,0,0,de.width,de.height,He,de.data):n.compressedTexImage2D(t.TEXTURE_2D,_e,ct,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,de.width,de.height,He,Ke,de.data):n.texImage2D(t.TEXTURE_2D,_e,ct,de.width,de.height,0,He,Ke,de.data)}else if(L.isDataArrayTexture)ge?(Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,ct,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,He,Ke,oe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ct,oe.width,oe.height,oe.depth,0,He,Ke,oe.data);else if(L.isData3DTexture)ge?(Ue&&n.texStorage3D(t.TEXTURE_3D,Ce,ct,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,He,Ke,oe.data)):n.texImage3D(t.TEXTURE_3D,0,ct,oe.width,oe.height,oe.depth,0,He,Ke,oe.data);else if(L.isFramebufferTexture){if(Ue)if(ge)n.texStorage2D(t.TEXTURE_2D,Ce,ct,oe.width,oe.height);else{let _e=oe.width,ce=oe.height;for(let st=0;st<Ce;st++)n.texImage2D(t.TEXTURE_2D,st,ct,_e,ce,0,He,Ke,null),_e>>=1,ce>>=1}}else if(Ye.length>0&&et){ge&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let _e=0,ce=Ye.length;_e<ce;_e++)de=Ye[_e],ge?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,He,Ke,de):n.texImage2D(t.TEXTURE_2D,_e,ct,He,Ke,de);L.generateMipmaps=!1}else ge?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,He,Ke,oe)):n.texImage2D(t.TEXTURE_2D,0,ct,He,Ke,oe);k(L,et)&&N(ve),nt.__version=ye.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function xe(z,L,ne){if(L.image.length!==6)return;const ve=Ne(z,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,z.__webglTexture,t.TEXTURE0+ne);const ye=r.get(we);if(we.version!==ye.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const nt=Xn.getPrimaries(Xn.workingColorSpace),Be=L.colorSpace===Js?null:Xn.getPrimaries(L.colorSpace),ue=L.colorSpace===Js||nt===Be?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,ue);const Ve=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let _e=0;_e<6;_e++)!Ve&&!Fe?oe[_e]=S(L.image[_e],!1,!0,u):oe[_e]=Fe?L.image[_e].image:L.image[_e],oe[_e]=Se(L,oe[_e]);const et=oe[0],He=A(et)||o,Ke=a.convert(L.format,L.colorSpace),ct=a.convert(L.type),de=I(L.internalFormat,Ke,ct,L.colorSpace),Ye=o&&L.isVideoTexture!==!0,ge=ye.__version===void 0||ve===!0;let Ue=C(L,et,He);be(t.TEXTURE_CUBE_MAP,L,He);let Ce;if(Ve){Ye&&ge&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,de,et.width,et.height);for(let _e=0;_e<6;_e++){Ce=oe[_e].mipmaps;for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];L.format!==Qs?Ke!==null?Ye?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,Ke,st.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,de,st.width,st.height,0,st.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,0,0,st.width,st.height,Ke,ct,st.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce,de,st.width,st.height,0,Ke,ct,st.data)}}}else{Ce=L.mipmaps,Ye&&ge&&(Ce.length>0&&Ue++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,de,oe[0].width,oe[0].height));for(let _e=0;_e<6;_e++)if(Fe){Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,oe[_e].width,oe[_e].height,Ke,ct,oe[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,de,oe[_e].width,oe[_e].height,0,Ke,ct,oe[_e].data);for(let ce=0;ce<Ce.length;ce++){const xt=Ce[ce].image[_e].image;Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,xt.width,xt.height,Ke,ct,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,de,xt.width,xt.height,0,Ke,ct,xt.data)}}else{Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,Ke,ct,oe[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,de,Ke,ct,oe[_e]);for(let ce=0;ce<Ce.length;ce++){const st=Ce[ce];Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,0,0,Ke,ct,st.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,ce+1,de,Ke,ct,st.image[_e])}}}k(L,He)&&N(t.TEXTURE_CUBE_MAP),ye.__version=we.version,L.onUpdate&&L.onUpdate(L)}z.__version=L.version}function Re(z,L,ne,ve,we,ye){const nt=a.convert(ne.format,ne.colorSpace),Be=a.convert(ne.type),ue=I(ne.internalFormat,nt,Be,ne.colorSpace);if(!r.get(L).__hasExternalTextures){const Fe=Math.max(1,L.width>>ye),oe=Math.max(1,L.height>>ye);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ye,ue,Fe,oe,L.depth,0,nt,Be,null):n.texImage2D(we,ye,ue,Fe,oe,0,nt,Be,null)}n.bindFramebuffer(t.FRAMEBUFFER,z),Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,we,r.get(ne).__webglTexture,0,se(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,we,r.get(ne).__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(z,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,z),L.depthBuffer&&!L.stencilBuffer){let ve=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||Ae(L)){const we=L.depthTexture;we&&we.isDepthTexture&&(we.type===xc?ve=t.DEPTH_COMPONENT32F:we.type===Hu&&(ve=t.DEPTH_COMPONENT24));const ye=se(L);Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,ve,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,ve,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ve,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,z)}else if(L.depthBuffer&&L.stencilBuffer){const ve=se(L);ne&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,L.width,L.height):Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,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,z)}else{const ve=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let we=0;we<ve.length;we++){const ye=ve[we],nt=a.convert(ye.format,ye.colorSpace),Be=a.convert(ye.type),ue=I(ye.internalFormat,nt,Be,ye.colorSpace),Ve=se(L);ne&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,ue,L.width,L.height):Ae(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,ue,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ue,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ht(z,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,z),!(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),Q(L.depthTexture,0);const ve=r.get(L.depthTexture).__webglTexture,we=se(L);if(L.depthTexture.format===kh)Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0);else if(L.depthTexture.format===Dm)Ae(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function H(z){const L=r.get(z),ne=z.isWebGLCubeRenderTarget===!0;if(z.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");ht(L.__webglFramebuffer,z)}else if(ne){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]=t.createRenderbuffer(),he(L.__webglDepthbuffer[ve],z,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,z,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function B(z,L,ne){const ve=r.get(z);L!==void 0&&Re(ve.__webglFramebuffer,z,z.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&H(z)}function re(z){const L=z.texture,ne=r.get(z),ve=r.get(L);z.addEventListener("dispose",O),z.isWebGLMultipleRenderTargets!==!0&&(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,s.memory.textures++);const we=z.isWebGLCubeRenderTarget===!0,ye=z.isWebGLMultipleRenderTargets===!0,nt=A(z)||o;if(we){ne.__webglFramebuffer=[];for(let Be=0;Be<6;Be++)if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Be]=[];for(let ue=0;ue<L.mipmaps.length;ue++)ne.__webglFramebuffer[Be][ue]=t.createFramebuffer()}else ne.__webglFramebuffer[Be]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Be=0;Be<L.mipmaps.length;Be++)ne.__webglFramebuffer[Be]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(ye)if(i.drawBuffers){const Be=z.texture;for(let ue=0,Ve=Be.length;ue<Ve;ue++){const Fe=r.get(Be[ue]);Fe.__webglTexture===void 0&&(Fe.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&z.samples>0&&Ae(z)===!1){const Be=ye?L:[L];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let ue=0;ue<Be.length;ue++){const Ve=Be[ue];ne.__webglColorRenderbuffer[ue]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[ue]);const Fe=a.convert(Ve.format,Ve.colorSpace),oe=a.convert(Ve.type),et=I(Ve.internalFormat,Fe,oe,Ve.colorSpace,z.isXRRenderTarget===!0),He=se(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,He,et,z.width,z.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ue,t.RENDERBUFFER,ne.__webglColorRenderbuffer[ue])}t.bindRenderbuffer(t.RENDERBUFFER,null),z.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),he(ne.__webglDepthRenderbuffer,z,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),be(t.TEXTURE_CUBE_MAP,L,nt);for(let Be=0;Be<6;Be++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Re(ne.__webglFramebuffer[Be][ue],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,ue);else Re(ne.__webglFramebuffer[Be],z,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0);k(L,nt)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ye){const Be=z.texture;for(let ue=0,Ve=Be.length;ue<Ve;ue++){const Fe=Be[ue],oe=r.get(Fe);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture),be(t.TEXTURE_2D,Fe,nt),Re(ne.__webglFramebuffer,z,Fe,t.COLOR_ATTACHMENT0+ue,t.TEXTURE_2D,0),k(Fe,nt)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Be=t.TEXTURE_2D;if((z.isWebGL3DRenderTarget||z.isWebGLArrayRenderTarget)&&(o?Be=z.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Be,ve.__webglTexture),be(Be,L,nt),o&&L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Re(ne.__webglFramebuffer[ue],z,L,t.COLOR_ATTACHMENT0,Be,ue);else Re(ne.__webglFramebuffer,z,L,t.COLOR_ATTACHMENT0,Be,0);k(L,nt)&&N(Be),n.unbindTexture()}z.depthBuffer&&H(z)}function V(z){const L=A(z)||o,ne=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let ve=0,we=ne.length;ve<we;ve++){const ye=ne[ve];if(k(ye,L)){const nt=z.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Be=r.get(ye).__webglTexture;n.bindTexture(nt,Be),N(nt),n.unbindTexture()}}}function J(z){if(o&&z.samples>0&&Ae(z)===!1){const L=z.isWebGLMultipleRenderTargets?z.texture:[z.texture],ne=z.width,ve=z.height;let we=t.COLOR_BUFFER_BIT;const ye=[],nt=z.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Be=r.get(z),ue=z.isWebGLMultipleRenderTargets===!0;if(ue)for(let Ve=0;Ve<L.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Be.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglFramebuffer);for(let Ve=0;Ve<L.length;Ve++){ye.push(t.COLOR_ATTACHMENT0+Ve),z.depthBuffer&&ye.push(nt);const Fe=Be.__ignoreDepthValues!==void 0?Be.__ignoreDepthValues:!1;if(Fe===!1&&(z.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),z.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),ue&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Be.__webglColorRenderbuffer[Ve]),Fe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[nt]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[nt])),ue){const oe=r.get(L[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,oe,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,we,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ye)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ue)for(let Ve=0;Ve<L.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,Be.__webglColorRenderbuffer[Ve]);const Fe=r.get(L[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglMultisampledFramebuffer)}}function se(z){return Math.min(f,z.samples)}function Ae(z){const L=r.get(z);return o&&z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Pe(z){const L=s.render.frame;b.get(z)!==L&&(b.set(z,L),z.update())}function Se(z,L){const ne=z.colorSpace,ve=z.format,we=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||z.format===LP||ne!==Ic&&ne!==Js&&(Xn.getTransfer(ne)===lr?o===!1?e.has("EXT_sRGB")===!0&&ve===Qs?(z.format=LP,z.minFilter=Zs,z.generateMipmaps=!1):L=zZ.sRGBToLinear(L):(ve!==Qs||we!==Ju)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),L}this.allocateTextureUnit=ee,this.resetTextureUnits=G,this.setTexture2D=Q,this.setTexture2DArray=U,this.setTexture3D=$,this.setTextureCube=X,this.rebindTextures=B,this.setupRenderTarget=re,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=Ae}function _Fe(t,e,n){const r=n.isWebGL2;function i(a,s=Js){let o;const c=Xn.getTransfer(s);if(a===Ju)return t.UNSIGNED_BYTE;if(a===NZ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===kZ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===Gje)return t.BYTE;if(a===Wje)return t.SHORT;if(a===mO)return t.UNSIGNED_SHORT;if(a===CZ)return t.INT;if(a===Hu)return t.UNSIGNED_INT;if(a===xc)return t.FLOAT;if(a===X0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===qje)return t.ALPHA;if(a===Qs)return t.RGBA;if(a===Kje)return t.LUMINANCE;if(a===Xje)return t.LUMINANCE_ALPHA;if(a===kh)return t.DEPTH_COMPONENT;if(a===Dm)return t.DEPTH_STENCIL;if(a===LP)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===Yje)return t.RED;if(a===PZ)return t.RED_INTEGER;if(a===Zje)return t.RG;if(a===RZ)return t.RG_INTEGER;if(a===DZ)return t.RGBA_INTEGER;if(a===XC||a===YC||a===ZC||a===QC)if(c===lr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===XC)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===YC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===ZC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===QC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===XC)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===YC)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===ZC)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===QC)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===YH||a===ZH||a===QH||a===JH)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===YH)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===ZH)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===QH)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===JH)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===jZ)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===e$||a===t$)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(a===e$)return c===lr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===t$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===n$||a===r$||a===i$||a===a$||a===s$||a===o$||a===l$||a===c$||a===u$||a===d$||a===h$||a===f$||a===p$||a===m$)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(a===n$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===r$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===i$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===a$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===s$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===o$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===l$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===c$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===u$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===d$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===h$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===f$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===p$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===m$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===JC||a===g$||a===x$)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(a===JC)return c===lr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===g$)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===x$)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===Qje||a===b$||a===y$||a===v$)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(a===JC)return o.COMPRESSED_RED_RGTC1_EXT;if(a===b$)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===y$)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===v$)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Nh?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class wFe extends ms{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ux extends Aa{constructor(){super(),this.isGroup=!0,this.type="Group"}}const SFe={type:"move"};class wN{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ux,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 Ux,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new je,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new je),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ux,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new je,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new je),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,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),x=this._getHandJoint(u,y);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),m=.02,b=.005;u.inputState.pinching&&g>m+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=m-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(SFe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Ux;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class MFe extends mf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",c=1,u=null,d=null,f=null,g=null,m=null,b=null;const y=n.getContextAttributes();let v=null,x=null;const M=[],S=[],A=new Zt;let T=null;const k=new ms;k.layers.enable(1),k.viewport=new Zn;const N=new ms;N.layers.enable(2),N.viewport=new Zn;const I=[k,N],C=new wFe;C.layers.enable(1),C.layers.enable(2);let D=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let te=M[X];return te===void 0&&(te=new wN,M[X]=te),te.getTargetRaySpace()},this.getControllerGrip=function(X){let te=M[X];return te===void 0&&(te=new wN,M[X]=te),te.getGripSpace()},this.getHand=function(X){let te=M[X];return te===void 0&&(te=new wN,M[X]=te),te.getHandSpace()};function O(X){const te=S.indexOf(X.inputSource);if(te===-1)return;const fe=M[te];fe!==void 0&&(fe.update(X.inputSource,X.frame,u||s),fe.dispatchEvent({type:X.type,data:X.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let X=0;X<M.length;X++){const te=S[X];te!==null&&(S[X]=null,M[X].disconnect(te))}D=null,F=null,e.setRenderTarget(v),m=null,g=null,f=null,i=null,x=null,$.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){a=X,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(X){u=X},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(X){if(i=X,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const te={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,te),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new nf(m.framebufferWidth,m.framebufferHeight,{format:Qs,type:Ju,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let te=null,fe=null,pe=null;y.depth&&(pe=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,te=y.stencil?Dm:kh,fe=y.stencil?Nh:Hu);const be={colorFormat:n.RGBA8,depthFormat:pe,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(be),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),x=new nf(g.textureWidth,g.textureHeight,{format:Qs,type:Ju,depthTexture:new QZ(g.textureWidth,g.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Ne=e.properties.get(x);Ne.__ignoreDepthValues=g.ignoreDepthValues}x.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(o),$.setContext(i),$.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function R(X){for(let te=0;te<X.removed.length;te++){const fe=X.removed[te],pe=S.indexOf(fe);pe>=0&&(S[pe]=null,M[pe].disconnect(fe))}for(let te=0;te<X.added.length;te++){const fe=X.added[te];let pe=S.indexOf(fe);if(pe===-1){for(let Ne=0;Ne<M.length;Ne++)if(Ne>=S.length){S.push(fe),pe=Ne;break}else if(S[Ne]===null){S[Ne]=fe,pe=Ne;break}if(pe===-1)break}const be=M[pe];be&&be.connect(fe)}}const W=new je,K=new je;function G(X,te,fe){W.setFromMatrixPosition(te.matrixWorld),K.setFromMatrixPosition(fe.matrixWorld);const pe=W.distanceTo(K),be=te.projectionMatrix.elements,Ne=fe.projectionMatrix.elements,ie=be[14]/(be[10]-1),xe=be[14]/(be[10]+1),Re=(be[9]+1)/be[5],he=(be[9]-1)/be[5],ht=(be[8]-1)/be[0],H=(Ne[8]+1)/Ne[0],B=ie*ht,re=ie*H,V=pe/(-ht+H),J=V*-ht;te.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(J),X.translateZ(V),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert();const se=ie+V,Ae=xe+V,Pe=B-J,Se=re+(pe-J),z=Re*xe/Ae*se,L=he*xe/Ae*se;X.projectionMatrix.makePerspective(Pe,Se,z,L,se,Ae),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}function ee(X,te){te===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(te.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;C.near=N.near=k.near=X.near,C.far=N.far=k.far=X.far,(D!==C.near||F!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),D=C.near,F=C.far);const te=X.parent,fe=C.cameras;ee(C,te);for(let pe=0;pe<fe.length;pe++)ee(fe[pe],te);fe.length===2?G(C,k,N):C.projectionMatrix.copy(k.projectionMatrix),Z(X,C,te)};function Z(X,te,fe){fe===null?X.matrix.copy(te.matrixWorld):(X.matrix.copy(fe.matrixWorld),X.matrix.invert(),X.matrix.multiply(te.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(te.projectionMatrix),X.projectionMatrixInverse.copy(te.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Z0*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(X){c=X,g!==null&&(g.fixedFoveation=X),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=X)};let Q=null;function U(X,te){if(d=te.getViewerPose(u||s),b=te,d!==null){const fe=d.views;m!==null&&(e.setRenderTargetFramebuffer(x,m.framebuffer),e.setRenderTarget(x));let pe=!1;fe.length!==C.cameras.length&&(C.cameras.length=0,pe=!0);for(let be=0;be<fe.length;be++){const Ne=fe[be];let ie=null;if(m!==null)ie=m.getViewport(Ne);else{const Re=f.getViewSubImage(g,Ne);ie=Re.viewport,be===0&&(e.setRenderTargetTextures(x,Re.colorTexture,g.ignoreDepthValues?void 0:Re.depthStencilTexture),e.setRenderTarget(x))}let xe=I[be];xe===void 0&&(xe=new ms,xe.layers.enable(be),xe.viewport=new Zn,I[be]=xe),xe.matrix.fromArray(Ne.transform.matrix),xe.matrix.decompose(xe.position,xe.quaternion,xe.scale),xe.projectionMatrix.fromArray(Ne.projectionMatrix),xe.projectionMatrixInverse.copy(xe.projectionMatrix).invert(),xe.viewport.set(ie.x,ie.y,ie.width,ie.height),be===0&&(C.matrix.copy(xe.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),pe===!0&&C.cameras.push(xe)}}for(let fe=0;fe<M.length;fe++){const pe=S[fe],be=M[fe];pe!==null&&be!==void 0&&be.update(pe,te,u||s)}Q&&Q(X,te),te.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:te}),b=null}const $=new ZZ;$.setAnimationLoop(U),this.setAnimationLoop=function(X){Q=X},this.dispose=function(){}}}function EFe(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function r(v,x){x.color.getRGB(v.fogColor.value,KZ(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function i(v,x,M,S,A){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),f(v,x)):x.isMeshPhongMaterial?(a(v,x),d(v,x)):x.isMeshStandardMaterial?(a(v,x),g(v,x),x.isMeshPhysicalMaterial&&m(v,x,A)):x.isMeshMatcapMaterial?(a(v,x),b(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),y(v,x)):x.isMeshNormalMaterial?a(v,x):x.isLineBasicMaterial?(s(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?c(v,x,M,S):x.isSpriteMaterial?u(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===Ka&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===Ka&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x).envMap;if(M&&(v.envMap.value=M,v.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap){v.lightMap.value=x.lightMap;const S=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=x.lightMapIntensity*S,n(x.lightMap,v.lightMapTransform)}x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function s(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function c(v,x,M,S){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=S*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function u(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function d(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function f(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function g(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),e.get(x).envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Ka&&v.clearcoatNormalScale.value.negate())),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function b(v,x){x.matcap&&(v.matcap.value=x.matcap)}function y(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function AFe(t,e,n,r){let i={},a={},s=[];const o=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&&(b(M),A=d(M),i[M.id]=A,M.addEventListener("dispose",v));const T=S.program;r.updateUBOMapping(M,T);const k=e.render.frame;a[M.id]!==k&&(g(M),a[M.id]=k)}function d(M){const S=f();M.__bindingPointIndex=S;const A=t.createBuffer(),T=M.__size,k=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const S=i[M.id],A=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,N=A.length;k<N;k++){const I=A[k];if(m(I,k,T)===!0){const C=I.__offset,D=Array.isArray(I.value)?I.value:[I.value];let F=0;for(let O=0;O<D.length;O++){const q=D[O],R=y(q);typeof q=="number"?(I.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,C+F,I.__data)):q.isMatrix3?(I.__data[0]=q.elements[0],I.__data[1]=q.elements[1],I.__data[2]=q.elements[2],I.__data[3]=q.elements[0],I.__data[4]=q.elements[3],I.__data[5]=q.elements[4],I.__data[6]=q.elements[5],I.__data[7]=q.elements[0],I.__data[8]=q.elements[6],I.__data[9]=q.elements[7],I.__data[10]=q.elements[8],I.__data[11]=q.elements[0]):(q.toArray(I.__data,F),F+=R.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,C,I.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,S,A){const T=M.value;if(A[S]===void 0){if(typeof T=="number")A[S]=T;else{const k=Array.isArray(T)?T:[T],N=[];for(let I=0;I<k.length;I++)N.push(k[I].clone());A[S]=N}return!0}else if(typeof T=="number"){if(A[S]!==T)return A[S]=T,!0}else{const k=Array.isArray(A[S])?A[S]:[A[S]],N=Array.isArray(T)?T:[T];for(let I=0;I<k.length;I++){const C=k[I];if(C.equals(N[I])===!1)return C.copy(N[I]),!0}}return!1}function b(M){const S=M.uniforms;let A=0;const T=16;let k=0;for(let N=0,I=S.length;N<I;N++){const C=S[N],D={boundary:0,storage:0},F=Array.isArray(C.value)?C.value:[C.value];for(let O=0,q=F.length;O<q;O++){const R=F[O],W=y(R);D.boundary+=W.boundary,D.storage+=W.storage}if(C.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=A,N>0){k=A%T;const O=T-k;k!==0&&O-D.boundary<0&&(A+=T-k,C.__offset=A)}A+=D.storage}return k=A%T,k>0&&(A+=T-k),M.__size=A,M.__cache={},this}function y(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 v(M){const S=M.target;S.removeEventListener("dispose",v);const A=s.indexOf(S.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete a[S.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:c,update:u,dispose:x}}class UP{constructor(e={}){const{canvas:n=SOe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=s;const m=new Uint32Array(4),b=new Int32Array(4);let y=null,v=null;const x=[],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=Qi,this._useLegacyLights=!1,this.toneMapping=Qu,this.toneMappingExposure=1;const S=this;let A=!1,T=0,k=0,N=null,I=-1,C=null;const D=new Zn,F=new Zn;let O=null;const q=new $t(0);let R=0,W=n.width,K=n.height,G=1,ee=null,Z=null;const Q=new Zn(0,0,W,K),U=new Zn(0,0,W,K);let $=!1;const X=new GM;let te=!1,fe=!1,pe=null;const be=new ar,Ne=new Zt,ie=new je,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Re(){return N===null?G:1}let he=r;function ht(me,$e){for(let rt=0;rt<me.length;rt++){const it=me[rt],tt=n.getContext(it,$e);if(tt!==null)return tt}return null}try{const me={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${HM}`),n.addEventListener("webglcontextlost",Ye,!1),n.addEventListener("webglcontextrestored",ge,!1),n.addEventListener("webglcontextcreationerror",Ue,!1),he===null){const $e=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&$e.shift(),he=ht($e,me),he===null)throw ht($e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&he instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),he.getShaderPrecisionFormat===void 0&&(he.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(me){throw console.error("THREE.WebGLRenderer: "+me.message),me}let H,B,re,V,J,se,Ae,Pe,Se,z,L,ne,ve,we,ye,nt,Be,ue,Ve,Fe,oe,et,He,Ke;function ct(){H=new IIe(he),B=new kIe(he,H,e),H.init(B),et=new _Fe(he,H,B),re=new yFe(he,H,B),V=new zIe(he),J=new aFe,se=new vFe(he,H,re,J,B,et,V),Ae=new RIe(S),Pe=new LIe(S),Se=new qOe(he,B),He=new CIe(he,H,Se,B),z=new FIe(he,Se,V,He),L=new VIe(he,z,Se,V),Ve=new $Ie(he,B,se),nt=new PIe(J),ne=new iFe(S,Ae,Pe,H,B,He,nt),ve=new EFe(S,J),we=new oFe,ye=new fFe(H,B),ue=new TIe(S,Ae,Pe,re,L,g,c),Be=new bFe(S,L,B),Ke=new AFe(he,V,B,re),Fe=new NIe(he,H,V,B),oe=new UIe(he,H,V,B),V.programs=ne.programs,S.capabilities=B,S.extensions=H,S.properties=J,S.renderLists=we,S.shadowMap=Be,S.state=re,S.info=V}ct();const de=new MFe(S,he);this.xr=de,this.getContext=function(){return he},this.getContextAttributes=function(){return he.getContextAttributes()},this.forceContextLoss=function(){const me=H.get("WEBGL_lose_context");me&&me.loseContext()},this.forceContextRestore=function(){const me=H.get("WEBGL_lose_context");me&&me.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(me){me!==void 0&&(G=me,this.setSize(W,K,!1))},this.getSize=function(me){return me.set(W,K)},this.setSize=function(me,$e,rt=!0){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=me,K=$e,n.width=Math.floor(me*G),n.height=Math.floor($e*G),rt===!0&&(n.style.width=me+"px",n.style.height=$e+"px"),this.setViewport(0,0,me,$e)},this.getDrawingBufferSize=function(me){return me.set(W*G,K*G).floor()},this.setDrawingBufferSize=function(me,$e,rt){W=me,K=$e,G=rt,n.width=Math.floor(me*rt),n.height=Math.floor($e*rt),this.setViewport(0,0,me,$e)},this.getCurrentViewport=function(me){return me.copy(D)},this.getViewport=function(me){return me.copy(Q)},this.setViewport=function(me,$e,rt,it){me.isVector4?Q.set(me.x,me.y,me.z,me.w):Q.set(me,$e,rt,it),re.viewport(D.copy(Q).multiplyScalar(G).floor())},this.getScissor=function(me){return me.copy(U)},this.setScissor=function(me,$e,rt,it){me.isVector4?U.set(me.x,me.y,me.z,me.w):U.set(me,$e,rt,it),re.scissor(F.copy(U).multiplyScalar(G).floor())},this.getScissorTest=function(){return $},this.setScissorTest=function(me){re.setScissorTest($=me)},this.setOpaqueSort=function(me){ee=me},this.setTransparentSort=function(me){Z=me},this.getClearColor=function(me){return me.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(me=!0,$e=!0,rt=!0){let it=0;if(me){let tt=!1;if(N!==null){const Mt=N.texture.format;tt=Mt===DZ||Mt===RZ||Mt===PZ}if(tt){const Mt=N.texture.type,ae=Mt===Ju||Mt===Hu||Mt===mO||Mt===Nh||Mt===NZ||Mt===kZ,Me=ue.getClearColor(),Ie=ue.getClearAlpha(),Oe=Me.r,Te=Me.g,ot=Me.b;ae?(m[0]=Oe,m[1]=Te,m[2]=ot,m[3]=Ie,he.clearBufferuiv(he.COLOR,0,m)):(b[0]=Oe,b[1]=Te,b[2]=ot,b[3]=Ie,he.clearBufferiv(he.COLOR,0,b))}else it|=he.COLOR_BUFFER_BIT}$e&&(it|=he.DEPTH_BUFFER_BIT),rt&&(it|=he.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),he.clear(it)},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",Ye,!1),n.removeEventListener("webglcontextrestored",ge,!1),n.removeEventListener("webglcontextcreationerror",Ue,!1),we.dispose(),ye.dispose(),J.dispose(),Ae.dispose(),Pe.dispose(),L.dispose(),He.dispose(),Ke.dispose(),ne.dispose(),de.dispose(),de.removeEventListener("sessionstart",Qt),de.removeEventListener("sessionend",Ot),pe&&(pe.dispose(),pe=null),Vt.stop()};function Ye(me){me.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ge(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const me=V.autoReset,$e=Be.enabled,rt=Be.autoUpdate,it=Be.needsUpdate,tt=Be.type;ct(),V.autoReset=me,Be.enabled=$e,Be.autoUpdate=rt,Be.needsUpdate=it,Be.type=tt}function Ue(me){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",me.statusMessage)}function Ce(me){const $e=me.target;$e.removeEventListener("dispose",Ce),_e($e)}function _e(me){ce(me),J.remove(me)}function ce(me){const $e=J.get(me).programs;$e!==void 0&&($e.forEach(function(rt){ne.releaseProgram(rt)}),me.isShaderMaterial&&ne.releaseShaderCache(me))}this.renderBufferDirect=function(me,$e,rt,it,tt,Mt){$e===null&&($e=xe);const ae=tt.isMesh&&tt.matrixWorld.determinant()<0,Me=jr(me,$e,rt,it,tt);re.setMaterial(it,ae);let Ie=rt.index,Oe=1;if(it.wireframe===!0){if(Ie=z.getWireframeAttribute(rt),Ie===void 0)return;Oe=2}const Te=rt.drawRange,ot=rt.attributes.position;let ft=Te.start*Oe,yt=(Te.start+Te.count)*Oe;Mt!==null&&(ft=Math.max(ft,Mt.start*Oe),yt=Math.min(yt,(Mt.start+Mt.count)*Oe)),Ie!==null?(ft=Math.max(ft,0),yt=Math.min(yt,Ie.count)):ot!=null&&(ft=Math.max(ft,0),yt=Math.min(yt,ot.count));const bt=yt-ft;if(bt<0||bt===1/0)return;He.setup(tt,it,Me,rt,Ie);let Lt,Tt=Fe;if(Ie!==null&&(Lt=Se.get(Ie),Tt=oe,Tt.setIndex(Lt)),tt.isMesh)it.wireframe===!0?(re.setLineWidth(it.wireframeLinewidth*Re()),Tt.setMode(he.LINES)):Tt.setMode(he.TRIANGLES);else if(tt.isLine){let mt=it.linewidth;mt===void 0&&(mt=1),re.setLineWidth(mt*Re()),tt.isLineSegments?Tt.setMode(he.LINES):tt.isLineLoop?Tt.setMode(he.LINE_LOOP):Tt.setMode(he.LINE_STRIP)}else tt.isPoints?Tt.setMode(he.POINTS):tt.isSprite&&Tt.setMode(he.TRIANGLES);if(tt.isBatchedMesh)Tt.renderMultiDraw(tt._multiDrawStarts,tt._multiDrawCounts,tt._multiDrawCount);else if(tt.isInstancedMesh)Tt.renderInstances(ft,bt,tt.count);else if(rt.isInstancedBufferGeometry){const mt=rt._maxInstanceCount!==void 0?rt._maxInstanceCount:1/0,Xt=Math.min(rt.instanceCount,mt);Tt.renderInstances(ft,bt,Xt)}else Tt.render(ft,bt)};function st(me,$e,rt){me.transparent===!0&&me.side===dc&&me.forceSinglePass===!1?(me.side=Ka,me.needsUpdate=!0,ra(me,$e,rt),me.side=fd,me.needsUpdate=!0,ra(me,$e,rt),me.side=dc):ra(me,$e,rt)}this.compile=function(me,$e,rt=null){rt===null&&(rt=me),v=ye.get(rt),v.init(),M.push(v),rt.traverseVisible(function(tt){tt.isLight&&tt.layers.test($e.layers)&&(v.pushLight(tt),tt.castShadow&&v.pushShadow(tt))}),me!==rt&&me.traverseVisible(function(tt){tt.isLight&&tt.layers.test($e.layers)&&(v.pushLight(tt),tt.castShadow&&v.pushShadow(tt))}),v.setupLights(S._useLegacyLights);const it=new Set;return me.traverse(function(tt){const Mt=tt.material;if(Mt)if(Array.isArray(Mt))for(let ae=0;ae<Mt.length;ae++){const Me=Mt[ae];st(Me,rt,tt),it.add(Me)}else st(Mt,rt,tt),it.add(Mt)}),M.pop(),v=null,it},this.compileAsync=function(me,$e,rt=null){const it=this.compile(me,$e,rt);return new Promise(tt=>{function Mt(){if(it.forEach(function(ae){J.get(ae).currentProgram.isReady()&&it.delete(ae)}),it.size===0){tt(me);return}setTimeout(Mt,10)}H.get("KHR_parallel_shader_compile")!==null?Mt():setTimeout(Mt,10)})};let xt=null;function St(me){xt&&xt(me)}function Qt(){Vt.stop()}function Ot(){Vt.start()}const Vt=new ZZ;Vt.setAnimationLoop(St),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(me){xt=me,de.setAnimationLoop(me),me===null?Vt.stop():Vt.start()},de.addEventListener("sessionstart",Qt),de.addEventListener("sessionend",Ot),this.render=function(me,$e){if($e!==void 0&&$e.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;me.matrixWorldAutoUpdate===!0&&me.updateMatrixWorld(),$e.parent===null&&$e.matrixWorldAutoUpdate===!0&&$e.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(de.cameraAutoUpdate===!0&&de.updateCamera($e),$e=de.getCamera()),me.isScene===!0&&me.onBeforeRender(S,me,$e,N),v=ye.get(me,M.length),v.init(),M.push(v),be.multiplyMatrices($e.projectionMatrix,$e.matrixWorldInverse),X.setFromProjectionMatrix(be),fe=this.localClippingEnabled,te=nt.init(this.clippingPlanes,fe),y=we.get(me,x.length),y.init(),x.push(y),On(me,$e,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(ee,Z),this.info.render.frame++,te===!0&&nt.beginShadows();const rt=v.state.shadowsArray;if(Be.render(rt,me,$e),te===!0&&nt.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(y,me),v.setupLights(S._useLegacyLights),$e.isArrayCamera){const it=$e.cameras;for(let tt=0,Mt=it.length;tt<Mt;tt++){const ae=it[tt];Mi(y,me,ae,ae.viewport)}}else Mi(y,me,$e);N!==null&&(se.updateMultisampleRenderTarget(N),se.updateRenderTargetMipmap(N)),me.isScene===!0&&me.onAfterRender(S,me,$e),He.resetDefaultState(),I=-1,C=null,M.pop(),M.length>0?v=M[M.length-1]:v=null,x.pop(),x.length>0?y=x[x.length-1]:y=null};function On(me,$e,rt,it){if(me.visible===!1)return;if(me.layers.test($e.layers)){if(me.isGroup)rt=me.renderOrder;else if(me.isLOD)me.autoUpdate===!0&&me.update($e);else if(me.isLight)v.pushLight(me),me.castShadow&&v.pushShadow(me);else if(me.isSprite){if(!me.frustumCulled||X.intersectsSprite(me)){it&&ie.setFromMatrixPosition(me.matrixWorld).applyMatrix4(be);const ae=L.update(me),Me=me.material;Me.visible&&y.push(me,ae,Me,rt,ie.z,null)}}else if((me.isMesh||me.isLine||me.isPoints)&&(!me.frustumCulled||X.intersectsObject(me))){const ae=L.update(me),Me=me.material;if(it&&(me.boundingSphere!==void 0?(me.boundingSphere===null&&me.computeBoundingSphere(),ie.copy(me.boundingSphere.center)):(ae.boundingSphere===null&&ae.computeBoundingSphere(),ie.copy(ae.boundingSphere.center)),ie.applyMatrix4(me.matrixWorld).applyMatrix4(be)),Array.isArray(Me)){const Ie=ae.groups;for(let Oe=0,Te=Ie.length;Oe<Te;Oe++){const ot=Ie[Oe],ft=Me[ot.materialIndex];ft&&ft.visible&&y.push(me,ae,ft,rt,ie.z,ot)}}else Me.visible&&y.push(me,ae,Me,rt,ie.z,null)}}const Mt=me.children;for(let ae=0,Me=Mt.length;ae<Me;ae++)On(Mt[ae],$e,rt,it)}function Mi(me,$e,rt,it){const tt=me.opaque,Mt=me.transmissive,ae=me.transparent;v.setupLightsView(rt),te===!0&&nt.setGlobalState(S.clippingPlanes,rt),Mt.length>0&&si(tt,Mt,$e,rt),it&&re.viewport(D.copy(it)),tt.length>0&&Ei(tt,$e,rt),Mt.length>0&&Ei(Mt,$e,rt),ae.length>0&&Ei(ae,$e,rt),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function si(me,$e,rt,it){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;const Mt=B.isWebGL2;pe===null&&(pe=new nf(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?X0:Ju,minFilter:K0,samples:Mt?4:0})),S.getDrawingBufferSize(Ne),Mt?pe.setSize(Ne.x,Ne.y):pe.setSize(Iw(Ne.x),Iw(Ne.y));const ae=S.getRenderTarget();S.setRenderTarget(pe),S.getClearColor(q),R=S.getClearAlpha(),R<1&&S.setClearColor(16777215,.5),S.clear();const Me=S.toneMapping;S.toneMapping=Qu,Ei(me,rt,it),se.updateMultisampleRenderTarget(pe),se.updateRenderTargetMipmap(pe);let Ie=!1;for(let Oe=0,Te=$e.length;Oe<Te;Oe++){const ot=$e[Oe],ft=ot.object,yt=ot.geometry,bt=ot.material,Lt=ot.group;if(bt.side===dc&&ft.layers.test(it.layers)){const Tt=bt.side;bt.side=Ka,bt.needsUpdate=!0,zi(ft,rt,it,yt,bt,Lt),bt.side=Tt,bt.needsUpdate=!0,Ie=!0}}Ie===!0&&(se.updateMultisampleRenderTarget(pe),se.updateRenderTargetMipmap(pe)),S.setRenderTarget(ae),S.setClearColor(q,R),S.toneMapping=Me}function Ei(me,$e,rt){const it=$e.isScene===!0?$e.overrideMaterial:null;for(let tt=0,Mt=me.length;tt<Mt;tt++){const ae=me[tt],Me=ae.object,Ie=ae.geometry,Oe=it===null?ae.material:it,Te=ae.group;Me.layers.test(rt.layers)&&zi(Me,$e,rt,Ie,Oe,Te)}}function zi(me,$e,rt,it,tt,Mt){me.onBeforeRender(S,$e,rt,it,tt,Mt),me.modelViewMatrix.multiplyMatrices(rt.matrixWorldInverse,me.matrixWorld),me.normalMatrix.getNormalMatrix(me.modelViewMatrix),tt.onBeforeRender(S,$e,rt,it,me,Mt),tt.transparent===!0&&tt.side===dc&&tt.forceSinglePass===!1?(tt.side=Ka,tt.needsUpdate=!0,S.renderBufferDirect(rt,$e,it,tt,me,Mt),tt.side=fd,tt.needsUpdate=!0,S.renderBufferDirect(rt,$e,it,tt,me,Mt),tt.side=dc):S.renderBufferDirect(rt,$e,it,tt,me,Mt),me.onAfterRender(S,$e,rt,it,tt,Mt)}function ra(me,$e,rt){$e.isScene!==!0&&($e=xe);const it=J.get(me),tt=v.state.lights,Mt=v.state.shadowsArray,ae=tt.state.version,Me=ne.getParameters(me,tt.state,Mt,$e,rt),Ie=ne.getProgramCacheKey(Me);let Oe=it.programs;it.environment=me.isMeshStandardMaterial?$e.environment:null,it.fog=$e.fog,it.envMap=(me.isMeshStandardMaterial?Pe:Ae).get(me.envMap||it.environment),Oe===void 0&&(me.addEventListener("dispose",Ce),Oe=new Map,it.programs=Oe);let Te=Oe.get(Ie);if(Te!==void 0){if(it.currentProgram===Te&&it.lightsStateVersion===ae)return br(me,Me),Te}else Me.uniforms=ne.getUniforms(me),me.onBuild(rt,Me,S),me.onBeforeCompile(Me,S),Te=ne.acquireProgram(Me,Ie),Oe.set(Ie,Te),it.uniforms=Me.uniforms;const ot=it.uniforms;return(!me.isShaderMaterial&&!me.isRawShaderMaterial||me.clipping===!0)&&(ot.clippingPlanes=nt.uniform),br(me,Me),it.needsLights=$c(me),it.lightsStateVersion=ae,it.needsLights&&(ot.ambientLightColor.value=tt.state.ambient,ot.lightProbe.value=tt.state.probe,ot.directionalLights.value=tt.state.directional,ot.directionalLightShadows.value=tt.state.directionalShadow,ot.spotLights.value=tt.state.spot,ot.spotLightShadows.value=tt.state.spotShadow,ot.rectAreaLights.value=tt.state.rectArea,ot.ltc_1.value=tt.state.rectAreaLTC1,ot.ltc_2.value=tt.state.rectAreaLTC2,ot.pointLights.value=tt.state.point,ot.pointLightShadows.value=tt.state.pointShadow,ot.hemisphereLights.value=tt.state.hemi,ot.directionalShadowMap.value=tt.state.directionalShadowMap,ot.directionalShadowMatrix.value=tt.state.directionalShadowMatrix,ot.spotShadowMap.value=tt.state.spotShadowMap,ot.spotLightMatrix.value=tt.state.spotLightMatrix,ot.spotLightMap.value=tt.state.spotLightMap,ot.pointShadowMap.value=tt.state.pointShadowMap,ot.pointShadowMatrix.value=tt.state.pointShadowMatrix),it.currentProgram=Te,it.uniformsList=null,Te}function Hr(me){if(me.uniformsList===null){const $e=me.currentProgram.getUniforms();me.uniformsList=p1.seqWithValue($e.seq,me.uniforms)}return me.uniformsList}function br(me,$e){const rt=J.get(me);rt.outputColorSpace=$e.outputColorSpace,rt.batching=$e.batching,rt.instancing=$e.instancing,rt.instancingColor=$e.instancingColor,rt.skinning=$e.skinning,rt.morphTargets=$e.morphTargets,rt.morphNormals=$e.morphNormals,rt.morphColors=$e.morphColors,rt.morphTargetsCount=$e.morphTargetsCount,rt.numClippingPlanes=$e.numClippingPlanes,rt.numIntersection=$e.numClipIntersection,rt.vertexAlphas=$e.vertexAlphas,rt.vertexTangents=$e.vertexTangents,rt.toneMapping=$e.toneMapping}function jr(me,$e,rt,it,tt){$e.isScene!==!0&&($e=xe),se.resetTextureUnits();const Mt=$e.fog,ae=it.isMeshStandardMaterial?$e.environment:null,Me=N===null?S.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Ic,Ie=(it.isMeshStandardMaterial?Pe:Ae).get(it.envMap||ae),Oe=it.vertexColors===!0&&!!rt.attributes.color&&rt.attributes.color.itemSize===4,Te=!!rt.attributes.tangent&&(!!it.normalMap||it.anisotropy>0),ot=!!rt.morphAttributes.position,ft=!!rt.morphAttributes.normal,yt=!!rt.morphAttributes.color;let bt=Qu;it.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(bt=S.toneMapping);const Lt=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,Tt=Lt!==void 0?Lt.length:0,mt=J.get(it),Xt=v.state.lights;if(te===!0&&(fe===!0||me!==C)){const Or=me===C&&it.id===I;nt.setState(it,me,Or)}let Ut=!1;it.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Xt.state.version||mt.outputColorSpace!==Me||tt.isBatchedMesh&&mt.batching===!1||!tt.isBatchedMesh&&mt.batching===!0||tt.isInstancedMesh&&mt.instancing===!1||!tt.isInstancedMesh&&mt.instancing===!0||tt.isSkinnedMesh&&mt.skinning===!1||!tt.isSkinnedMesh&&mt.skinning===!0||tt.isInstancedMesh&&mt.instancingColor===!0&&tt.instanceColor===null||tt.isInstancedMesh&&mt.instancingColor===!1&&tt.instanceColor!==null||mt.envMap!==Ie||it.fog===!0&&mt.fog!==Mt||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==nt.numPlanes||mt.numIntersection!==nt.numIntersection)||mt.vertexAlphas!==Oe||mt.vertexTangents!==Te||mt.morphTargets!==ot||mt.morphNormals!==ft||mt.morphColors!==yt||mt.toneMapping!==bt||B.isWebGL2===!0&&mt.morphTargetsCount!==Tt)&&(Ut=!0):(Ut=!0,mt.__version=it.version);let an=mt.currentProgram;Ut===!0&&(an=ra(it,$e,tt));let hn=!1,bn=!1,Ft=!1;const Jt=an.getUniforms(),tn=mt.uniforms;if(re.useProgram(an.program)&&(hn=!0,bn=!0,Ft=!0),it.id!==I&&(I=it.id,bn=!0),hn||C!==me){Jt.setValue(he,"projectionMatrix",me.projectionMatrix),Jt.setValue(he,"viewMatrix",me.matrixWorldInverse);const Or=Jt.map.cameraPosition;Or!==void 0&&Or.setValue(he,ie.setFromMatrixPosition(me.matrixWorld)),B.logarithmicDepthBuffer&&Jt.setValue(he,"logDepthBufFC",2/(Math.log(me.far+1)/Math.LN2)),(it.isMeshPhongMaterial||it.isMeshToonMaterial||it.isMeshLambertMaterial||it.isMeshBasicMaterial||it.isMeshStandardMaterial||it.isShaderMaterial)&&Jt.setValue(he,"isOrthographic",me.isOrthographicCamera===!0),C!==me&&(C=me,bn=!0,Ft=!0)}if(tt.isSkinnedMesh){Jt.setOptional(he,tt,"bindMatrix"),Jt.setOptional(he,tt,"bindMatrixInverse");const Or=tt.skeleton;Or&&(B.floatVertexTextures?(Or.boneTexture===null&&Or.computeBoneTexture(),Jt.setValue(he,"boneTexture",Or.boneTexture,se)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}tt.isBatchedMesh&&(Jt.setOptional(he,tt,"batchingTexture"),Jt.setValue(he,"batchingTexture",tt._matricesTexture,se));const Ar=rt.morphAttributes;if((Ar.position!==void 0||Ar.normal!==void 0||Ar.color!==void 0&&B.isWebGL2===!0)&&Ve.update(tt,rt,an),(bn||mt.receiveShadow!==tt.receiveShadow)&&(mt.receiveShadow=tt.receiveShadow,Jt.setValue(he,"receiveShadow",tt.receiveShadow)),it.isMeshGouraudMaterial&&it.envMap!==null&&(tn.envMap.value=Ie,tn.flipEnvMap.value=Ie.isCubeTexture&&Ie.isRenderTargetTexture===!1?-1:1),bn&&(Jt.setValue(he,"toneMappingExposure",S.toneMappingExposure),mt.needsLights&&mo(tn,Ft),Mt&&it.fog===!0&&ve.refreshFogUniforms(tn,Mt),ve.refreshMaterialUniforms(tn,it,G,K,pe),p1.upload(he,Hr(mt),tn,se)),it.isShaderMaterial&&it.uniformsNeedUpdate===!0&&(p1.upload(he,Hr(mt),tn,se),it.uniformsNeedUpdate=!1),it.isSpriteMaterial&&Jt.setValue(he,"center",tt.center),Jt.setValue(he,"modelViewMatrix",tt.modelViewMatrix),Jt.setValue(he,"normalMatrix",tt.normalMatrix),Jt.setValue(he,"modelMatrix",tt.matrixWorld),it.isShaderMaterial||it.isRawShaderMaterial){const Or=it.uniformsGroups;for(let Dn=0,go=Or.length;Dn<go;Dn++)if(B.isWebGL2){const Ln=Or[Dn];Ke.update(Ln,an),Ke.bind(Ln,an)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return an}function mo(me,$e){me.ambientLightColor.needsUpdate=$e,me.lightProbe.needsUpdate=$e,me.directionalLights.needsUpdate=$e,me.directionalLightShadows.needsUpdate=$e,me.pointLights.needsUpdate=$e,me.pointLightShadows.needsUpdate=$e,me.spotLights.needsUpdate=$e,me.spotLightShadows.needsUpdate=$e,me.rectAreaLights.needsUpdate=$e,me.hemisphereLights.needsUpdate=$e}function $c(me){return me.isMeshLambertMaterial||me.isMeshToonMaterial||me.isMeshPhongMaterial||me.isMeshStandardMaterial||me.isShadowMaterial||me.isShaderMaterial&&me.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(me,$e,rt){J.get(me.texture).__webglTexture=$e,J.get(me.depthTexture).__webglTexture=rt;const it=J.get(me);it.__hasExternalTextures=!0,it.__hasExternalTextures&&(it.__autoAllocateDepthBuffer=rt===void 0,it.__autoAllocateDepthBuffer||H.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),it.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(me,$e){const rt=J.get(me);rt.__webglFramebuffer=$e,rt.__useDefaultFramebuffer=$e===void 0},this.setRenderTarget=function(me,$e=0,rt=0){N=me,T=$e,k=rt;let it=!0,tt=null,Mt=!1,ae=!1;if(me){const Ie=J.get(me);Ie.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(he.FRAMEBUFFER,null),it=!1):Ie.__webglFramebuffer===void 0?se.setupRenderTarget(me):Ie.__hasExternalTextures&&se.rebindTextures(me,J.get(me.texture).__webglTexture,J.get(me.depthTexture).__webglTexture);const Oe=me.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(ae=!0);const Te=J.get(me).__webglFramebuffer;me.isWebGLCubeRenderTarget?(Array.isArray(Te[$e])?tt=Te[$e][rt]:tt=Te[$e],Mt=!0):B.isWebGL2&&me.samples>0&&se.useMultisampledRTT(me)===!1?tt=J.get(me).__webglMultisampledFramebuffer:Array.isArray(Te)?tt=Te[rt]:tt=Te,D.copy(me.viewport),F.copy(me.scissor),O=me.scissorTest}else D.copy(Q).multiplyScalar(G).floor(),F.copy(U).multiplyScalar(G).floor(),O=$;if(re.bindFramebuffer(he.FRAMEBUFFER,tt)&&B.drawBuffers&&it&&re.drawBuffers(me,tt),re.viewport(D),re.scissor(F),re.setScissorTest(O),Mt){const Ie=J.get(me.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Ie.__webglTexture,rt)}else if(ae){const Ie=J.get(me.texture),Oe=$e||0;he.framebufferTextureLayer(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,Ie.__webglTexture,rt||0,Oe)}I=-1},this.readRenderTargetPixels=function(me,$e,rt,it,tt,Mt,ae){if(!(me&&me.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Me=J.get(me).__webglFramebuffer;if(me.isWebGLCubeRenderTarget&&ae!==void 0&&(Me=Me[ae]),Me){re.bindFramebuffer(he.FRAMEBUFFER,Me);try{const Ie=me.texture,Oe=Ie.format,Te=Ie.type;if(Oe!==Qs&&et.convert(Oe)!==he.getParameter(he.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ot=Te===X0&&(H.has("EXT_color_buffer_half_float")||B.isWebGL2&&H.has("EXT_color_buffer_float"));if(Te!==Ju&&et.convert(Te)!==he.getParameter(he.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===xc&&(B.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!ot){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$e>=0&&$e<=me.width-it&&rt>=0&&rt<=me.height-tt&&he.readPixels($e,rt,it,tt,et.convert(Oe),et.convert(Te),Mt)}finally{const Ie=N!==null?J.get(N).__webglFramebuffer:null;re.bindFramebuffer(he.FRAMEBUFFER,Ie)}}},this.copyFramebufferToTexture=function(me,$e,rt=0){const it=Math.pow(2,-rt),tt=Math.floor($e.image.width*it),Mt=Math.floor($e.image.height*it);se.setTexture2D($e,0),he.copyTexSubImage2D(he.TEXTURE_2D,rt,0,0,me.x,me.y,tt,Mt),re.unbindTexture()},this.copyTextureToTexture=function(me,$e,rt,it=0){const tt=$e.image.width,Mt=$e.image.height,ae=et.convert(rt.format),Me=et.convert(rt.type);se.setTexture2D(rt,0),he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,rt.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,rt.unpackAlignment),$e.isDataTexture?he.texSubImage2D(he.TEXTURE_2D,it,me.x,me.y,tt,Mt,ae,Me,$e.image.data):$e.isCompressedTexture?he.compressedTexSubImage2D(he.TEXTURE_2D,it,me.x,me.y,$e.mipmaps[0].width,$e.mipmaps[0].height,ae,$e.mipmaps[0].data):he.texSubImage2D(he.TEXTURE_2D,it,me.x,me.y,ae,Me,$e.image),it===0&&rt.generateMipmaps&&he.generateMipmap(he.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(me,$e,rt,it,tt=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Mt=me.max.x-me.min.x+1,ae=me.max.y-me.min.y+1,Me=me.max.z-me.min.z+1,Ie=et.convert(it.format),Oe=et.convert(it.type);let Te;if(it.isData3DTexture)se.setTexture3D(it,0),Te=he.TEXTURE_3D;else if(it.isDataArrayTexture)se.setTexture2DArray(it,0),Te=he.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,it.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,it.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,it.unpackAlignment);const ot=he.getParameter(he.UNPACK_ROW_LENGTH),ft=he.getParameter(he.UNPACK_IMAGE_HEIGHT),yt=he.getParameter(he.UNPACK_SKIP_PIXELS),bt=he.getParameter(he.UNPACK_SKIP_ROWS),Lt=he.getParameter(he.UNPACK_SKIP_IMAGES),Tt=rt.isCompressedTexture?rt.mipmaps[0]:rt.image;he.pixelStorei(he.UNPACK_ROW_LENGTH,Tt.width),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,Tt.height),he.pixelStorei(he.UNPACK_SKIP_PIXELS,me.min.x),he.pixelStorei(he.UNPACK_SKIP_ROWS,me.min.y),he.pixelStorei(he.UNPACK_SKIP_IMAGES,me.min.z),rt.isDataTexture||rt.isData3DTexture?he.texSubImage3D(Te,tt,$e.x,$e.y,$e.z,Mt,ae,Me,Ie,Oe,Tt.data):rt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),he.compressedTexSubImage3D(Te,tt,$e.x,$e.y,$e.z,Mt,ae,Me,Ie,Tt.data)):he.texSubImage3D(Te,tt,$e.x,$e.y,$e.z,Mt,ae,Me,Ie,Oe,Tt),he.pixelStorei(he.UNPACK_ROW_LENGTH,ot),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,ft),he.pixelStorei(he.UNPACK_SKIP_PIXELS,yt),he.pixelStorei(he.UNPACK_SKIP_ROWS,bt),he.pixelStorei(he.UNPACK_SKIP_IMAGES,Lt),tt===0&&it.generateMipmaps&&he.generateMipmap(Te),re.unbindTexture()},this.initTexture=function(me){me.isCubeTexture?se.setTextureCube(me,0):me.isData3DTexture?se.setTexture3D(me,0):me.isDataArrayTexture||me.isCompressedArrayTexture?se.setTexture2DArray(me,0):se.setTexture2D(me,0),re.unbindTexture()},this.resetState=function(){T=0,k=0,N=null,re.reset(),He.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ll}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===gO?"display-p3":"srgb",n.unpackColorSpace=Xn.workingColorSpace===VM?"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===Qi?Ph:OZ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ph?Qi:Ic}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 TFe extends UP{}TFe.prototype.isWebGL1Renderer=!0;class wO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new $t(e),this.near=n,this.far=r}clone(){return new wO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class CFe extends Aa{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 NFe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=OP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Mc()}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=Mc()),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=Mc()),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 ya=new je;class $u{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++)ya.fromBufferAttribute(this,n),ya.applyMatrix4(e),this.setXYZ(n,ya.x,ya.y,ya.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ya.fromBufferAttribute(this,n),ya.applyNormalMatrix(e),this.setXYZ(n,ya.x,ya.y,ya.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ya.fromBufferAttribute(this,n),ya.transformDirection(e),this.setXYZ(n,ya.x,ya.y,ya.z);return this}setX(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Kn(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=il(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=il(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=il(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=il(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Kn(n,this.array),r=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array),a=Kn(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 Ss(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 $u(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 kFe extends Xa{constructor(e=null,n=1,r=1,i,a,s,o,c,u=Zi,d=Zi,f,g){super(null,s,o,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function PFe(t,e){return t.z-e.z}function RFe(t,e){return e.z-t.z}class DFe{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 Rp="batchId",Mu=new ar,lV=new ar,jFe=new ar,cV=new ar,SN=new GM,T_=new ao,Jd=new ul,Tx=new je,MN=new DFe,ca=new jo,C_=[];function OFe(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 s=0;s<r;s++)e.setComponent(a+n,s,t.getComponent(a,s))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class LFe extends jo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ga,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 kFe(n,e,e,Qs,xc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const c=e.getAttribute(o),{array:u,itemSize:d,normalized:f}=c,g=new u.constructor(r*d),m=new c.constructor(g,d,f);m.setUsage(c.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new Ss(o,1))}const s=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Rp,new Ss(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Rp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Rp}"`);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===Rp)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 ao);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,Mu),this.getBoundingBoxAt(i,T_).applyMatrix4(Mu),n.union(T_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ul);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,Mu),this.getBoundingSphereAt(i,Jd).applyMatrix4(Mu),n.union(Jd))}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 s=this._reservedRanges,o=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=s[s.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,m=this._matricesTexture,b=this._matricesTexture.image.data;f.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,jFe.toArray(b,y*16),m.needsUpdate=!0,s.push(i),o.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new ao,sphereInitialized:!1,sphere:new ul});const v=this.geometry.getAttribute(Rp);for(let x=0;x<i.vertexCount;x++)v.setX(i.vertexStart+x,y);return v.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),s=n.getIndex(),o=this._reservedRanges[e];if(i&&s.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=o.vertexStart,u=o.vertexCount;for(const m in r.attributes){if(m===Rp)continue;const b=n.getAttribute(m),y=r.getAttribute(m);OFe(b,y,c);const v=b.itemSize;for(let x=b.count,M=u;x<M;x++){const S=c+x;for(let A=0;A<v;A++)y.setComponent(S,A,0)}y.needsUpdate=!0}if(i){const m=o.indexStart;for(let b=0;b<s.count;b++)a.setX(m+b,c+s.getX(b));for(let b=s.count,y=o.indexCount;b<y;b++)a.setX(m+b,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?s.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,s=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const o=s.index,c=s.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let g=d;o&&(g=o.getX(g)),a.expandByPoint(Tx.fromBufferAttribute(c,g))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,T_),T_.getCenter(a.center);const o=s.index,c=s.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,g=u.start+u.count;f<g;f++){let m=f;o&&(m=o.getX(m)),Tx.fromBufferAttribute(c,m),d=Math.max(d,a.center.distanceToSquared(Tx))}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,s=this._geometryCount;return e>=s||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,s=this._geometryCount,o=this.matrixWorld,c=this.geometry;ca.material=this.material,ca.geometry.index=c.index,ca.geometry.attributes=c.attributes,ca.geometry.boundingBox===null&&(ca.geometry.boundingBox=new ao),ca.geometry.boundingSphere===null&&(ca.geometry.boundingSphere=new ul);for(let u=0;u<s;u++){if(!r[u]||!i[u])continue;const d=a[u];ca.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ca.matrixWorld).premultiply(o),this.getBoundingBoxAt(u,ca.geometry.boundingBox),this.getBoundingSphereAt(u,ca.geometry.boundingSphere),ca.raycast(e,C_);for(let f=0,g=C_.length;f<g;f++){const m=C_[f];m.object=this,m.batchId=u,n.push(m)}C_.length=0}ca.material=null,ca.geometry.index=null,ca.geometry.attributes={},ca.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 s=i.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(cV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),SN.setFromProjectionMatrix(cV,e.isWebGPURenderer?Y0:ll));let m=0;if(this.sortObjects){lV.copy(this.matrixWorld).invert(),Tx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(lV);for(let v=0,x=c.length;v<x;v++)if(c[v]){this.getMatrixAt(v,Mu),this.getBoundingSphereAt(v,Jd).applyMatrix4(Mu);let M=!1;if(g&&(M=!SN.intersectsSphere(Jd)),!M){const S=Tx.distanceTo(Jd.center);MN.push(f[v],S)}}const b=MN.list,y=this.customSort;y===null?b.sort(a.transparent?RFe:PFe):y.call(this,b,r);for(let v=0,x=b.length;v<x;v++){const M=b[v];u[m]=M.start*o,d[m]=M.count,m++}MN.reset()}else for(let b=0,y=c.length;b<y;b++)if(c[b]){let v=!1;if(g&&(this.getMatrixAt(b,Mu),this.getBoundingSphereAt(b,Jd).applyMatrix4(Mu),v=!SN.intersectsSphere(Jd)),!v){const x=f[b];u[m]=x.start*o,d[m]=x.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,s){this.onBeforeRender(e,null,i,a,s)}}class Xb extends cg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new $t(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 uV=new je,dV=new je,hV=new ar,EN=new bO,N_=new ul;class IFe extends Aa{constructor(e=new ga,n=new Xb){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++)uV.fromBufferAttribute(n,i-1),dV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=uV.distanceTo(dV);e.setAttribute("lineDistance",new Br(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,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),N_.copy(r.boundingSphere),N_.applyMatrix4(i),N_.radius+=a,e.ray.intersectsSphere(N_)===!1)return;hV.copy(i).invert(),EN.copy(e.ray).applyMatrix4(hV);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=new je,d=new je,f=new je,g=new je,m=this.isLineSegments?2:1,b=r.index,v=r.attributes.position;if(b!==null){const x=Math.max(0,s.start),M=Math.min(b.count,s.start+s.count);for(let S=x,A=M-1;S<A;S+=m){const T=b.getX(S),k=b.getX(S+1);if(u.fromBufferAttribute(v,T),d.fromBufferAttribute(v,k),EN.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(g);I<e.near||I>e.far||n.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,s.start),M=Math.min(v.count,s.start+s.count);for(let S=x,A=M-1;S<A;S+=m){if(u.fromBufferAttribute(v,S),d.fromBufferAttribute(v,S+1),EN.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(g);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,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}const fV=new je,pV=new je;class qM extends IFe{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)fV.fromBufferAttribute(n,i),pV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+fV.distanceTo(pV);e.setAttribute("lineDistance",new Br(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class FFe extends ga{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new je,a=new je;if(e.index!==null){const s=e.attributes.position,o=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,m=f.count;for(let b=g,y=g+m;b<y;b+=3)for(let v=0;v<3;v++){const x=o.getX(b+v),M=o.getX(b+(v+1)%3);i.fromBufferAttribute(s,x),a.fromBufferAttribute(s,M),mV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let o=0,c=s.count/3;o<c;o++)for(let u=0;u<3;u++){const d=3*o+u,f=3*o+(u+1)%3;i.fromBufferAttribute(s,d),a.fromBufferAttribute(s,f),mV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Br(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function mV(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 UFe extends cg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new $t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new $t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=LZ,this.normalScale=new Zt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=pO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.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 zFe extends Xb{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 iQ extends Aa{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new $t(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 AN=new ar,gV=new je,xV=new je;class BFe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Zt(512,512),this.map=null,this.mapPass=null,this.matrix=new ar,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new GM,this._frameExtents=new Zt(1,1),this._viewportCount=1,this._viewports=[new Zn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;gV.setFromMatrixPosition(e.matrixWorld),n.position.copy(gV),xV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(xV),n.updateMatrixWorld(),AN.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(AN),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(AN)}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 bV=new ar,Cx=new je,TN=new je;class HFe extends BFe{constructor(){super(new ms(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Zt(4,2),this._viewportCount=6,this._viewports=[new Zn(2,1,1,1),new Zn(0,1,1,1),new Zn(3,1,1,1),new Zn(1,1,1,1),new Zn(3,0,1,1),new Zn(1,0,1,1)],this._cubeDirections=[new je(1,0,0),new je(-1,0,0),new je(0,0,1),new je(0,0,-1),new je(0,1,0),new je(0,-1,0)],this._cubeUps=[new je(0,1,0),new je(0,1,0),new je(0,1,0),new je(0,1,0),new je(0,0,1),new je(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()),Cx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Cx),TN.copy(r.position),TN.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(TN),r.updateMatrixWorld(),i.makeTranslation(-Cx.x,-Cx.y,-Cx.z),bV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bV)}}class $Fe extends iQ{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 HFe}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 VFe extends iQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class GFe extends ga{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 zP extends NFe{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 yV{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(Ji(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const vV=new je,k_=new je;class WFe{constructor(e=new je,n=new je){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){vV.subVectors(e,this.start),k_.subVectors(this.end,this.start);const r=k_.dot(k_);let a=k_.dot(vV)/r;return n&&(a=Ji(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 qFe extends qM{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 ga;i.setAttribute("position",new Br(n,3)),i.setAttribute("color",new Br(r,3));const a=new Xb({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new $t,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:HM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=HM);class dl{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"),dl.nextNameID=dl.nextNameID||0,this.$name.id=`lil-gui-name-${++dl.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",s=>s.stopPropagation()),this.domElement.addEventListener("keyup",s=>s.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 KFe extends dl{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 BP(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 XFe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:BP,toHexString:BP},Q0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},YFe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=Q0.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 Q0.toHexString(i)}},ZFe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=Q0.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 Q0.toHexString(i)}},QFe=[XFe,Q0,YFe,ZFe];function JFe(t){return QFe.find(e=>e.match(t))}class eUe extends dl{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=JFe(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=BP(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 CN extends dl{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 tUe extends dl{constructor(e,n,r,i,a,s){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const o=s!==void 0;this.step(o?s:this._getImplicitStep(),o),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 s=!1,o,c,u,d,f;const g=5,m=M=>{o=M.clientX,c=u=M.clientY,s=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",y)},b=M=>{if(s){const S=M.clientX-o,A=M.clientY-c;Math.abs(A)>g?(M.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>g&&y()}if(!s){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},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)},v=()=>{this._inputFocused=!0},x=()=>{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",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",x)}_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=(x,M,S,A,T)=>(x-M)/(S-M)*(T-A)+A,n=x=>{const M=this.$slider.getBoundingClientRect();let S=e(x,M.left,M.right,this._min,this._max);this._snapClampSetValue(S)},r=x=>{this._setDraggingStyle(!0),n(x.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=x=>{n(x.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,o,c;const u=x=>{x.preventDefault(),this._setDraggingStyle(!0),n(x.touches[0].clientX),s=!1},d=x=>{x.touches.length>1||(this._hasScrollBar?(o=x.touches[0].clientX,c=x.touches[0].clientY,s=!0):u(x),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=x=>{if(s){const M=x.touches[0].clientX-o,S=x.touches[0].clientY-c;Math.abs(M)>Math.abs(S)?u(x):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else x.preventDefault(),n(x.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),b=400;let y;const v=x=>{if(Math.abs(x.deltaX)<Math.abs(x.deltaY)&&this._hasScrollBar)return;x.preventDefault();const S=this._normalizeMouseWheel(x)*this._step;this._snapClampSetValue(this.getValue()+S),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,b)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",v,{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 nUe extends dl{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 rUe extends dl{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 iUe=`.lil-gui {
  7432. font-family: var(--font-family);
  7433. font-size: var(--font-size);
  7434. line-height: 1;
  7435. font-weight: normal;
  7436. font-style: normal;
  7437. text-align: left;
  7438. color: var(--text-color);
  7439. user-select: none;
  7440. -webkit-user-select: none;
  7441. touch-action: manipulation;
  7442. --background-color: #1f1f1f;
  7443. --text-color: #ebebeb;
  7444. --title-background-color: #111111;
  7445. --title-text-color: #ebebeb;
  7446. --widget-color: #424242;
  7447. --hover-color: #4f4f4f;
  7448. --focus-color: #595959;
  7449. --number-color: #2cc9ff;
  7450. --string-color: #a2db3c;
  7451. --font-size: 11px;
  7452. --input-font-size: 11px;
  7453. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7454. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7455. --padding: 4px;
  7456. --spacing: 4px;
  7457. --widget-height: 20px;
  7458. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7459. --name-width: 45%;
  7460. --slider-knob-width: 2px;
  7461. --slider-input-width: 27%;
  7462. --color-input-width: 27%;
  7463. --slider-input-min-width: 45px;
  7464. --color-input-min-width: 45px;
  7465. --folder-indent: 7px;
  7466. --widget-padding: 0 0 0 3px;
  7467. --widget-border-radius: 2px;
  7468. --checkbox-size: calc(0.75 * var(--widget-height));
  7469. --scrollbar-width: 5px;
  7470. }
  7471. .lil-gui, .lil-gui * {
  7472. box-sizing: border-box;
  7473. margin: 0;
  7474. padding: 0;
  7475. }
  7476. .lil-gui.root {
  7477. width: var(--width, 245px);
  7478. display: flex;
  7479. flex-direction: column;
  7480. background: var(--background-color);
  7481. }
  7482. .lil-gui.root > .title {
  7483. background: var(--title-background-color);
  7484. color: var(--title-text-color);
  7485. }
  7486. .lil-gui.root > .children {
  7487. overflow-x: hidden;
  7488. overflow-y: auto;
  7489. }
  7490. .lil-gui.root > .children::-webkit-scrollbar {
  7491. width: var(--scrollbar-width);
  7492. height: var(--scrollbar-width);
  7493. background: var(--background-color);
  7494. }
  7495. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7496. border-radius: var(--scrollbar-width);
  7497. background: var(--focus-color);
  7498. }
  7499. @media (pointer: coarse) {
  7500. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7501. --widget-height: 28px;
  7502. --padding: 6px;
  7503. --spacing: 6px;
  7504. --font-size: 13px;
  7505. --input-font-size: 16px;
  7506. --folder-indent: 10px;
  7507. --scrollbar-width: 7px;
  7508. --slider-input-min-width: 50px;
  7509. --color-input-min-width: 65px;
  7510. }
  7511. }
  7512. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7513. --widget-height: 28px;
  7514. --padding: 6px;
  7515. --spacing: 6px;
  7516. --font-size: 13px;
  7517. --input-font-size: 16px;
  7518. --folder-indent: 10px;
  7519. --scrollbar-width: 7px;
  7520. --slider-input-min-width: 50px;
  7521. --color-input-min-width: 65px;
  7522. }
  7523. .lil-gui.autoPlace {
  7524. max-height: 100%;
  7525. position: fixed;
  7526. top: 0;
  7527. right: 15px;
  7528. z-index: 1001;
  7529. }
  7530. .lil-gui .controller {
  7531. display: flex;
  7532. align-items: center;
  7533. padding: 0 var(--padding);
  7534. margin: var(--spacing) 0;
  7535. }
  7536. .lil-gui .controller.disabled {
  7537. opacity: 0.5;
  7538. }
  7539. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7540. pointer-events: none !important;
  7541. }
  7542. .lil-gui .controller > .name {
  7543. min-width: var(--name-width);
  7544. flex-shrink: 0;
  7545. white-space: pre;
  7546. padding-right: var(--spacing);
  7547. line-height: var(--widget-height);
  7548. }
  7549. .lil-gui .controller .widget {
  7550. position: relative;
  7551. display: flex;
  7552. align-items: center;
  7553. width: 100%;
  7554. min-height: var(--widget-height);
  7555. }
  7556. .lil-gui .controller.string input {
  7557. color: var(--string-color);
  7558. }
  7559. .lil-gui .controller.boolean {
  7560. cursor: pointer;
  7561. }
  7562. .lil-gui .controller.color .display {
  7563. width: 100%;
  7564. height: var(--widget-height);
  7565. border-radius: var(--widget-border-radius);
  7566. position: relative;
  7567. }
  7568. @media (hover: hover) {
  7569. .lil-gui .controller.color .display:hover:before {
  7570. content: " ";
  7571. display: block;
  7572. position: absolute;
  7573. border-radius: var(--widget-border-radius);
  7574. border: 1px solid #fff9;
  7575. top: 0;
  7576. right: 0;
  7577. bottom: 0;
  7578. left: 0;
  7579. }
  7580. }
  7581. .lil-gui .controller.color input[type=color] {
  7582. opacity: 0;
  7583. width: 100%;
  7584. height: 100%;
  7585. cursor: pointer;
  7586. }
  7587. .lil-gui .controller.color input[type=text] {
  7588. margin-left: var(--spacing);
  7589. font-family: var(--font-family-mono);
  7590. min-width: var(--color-input-min-width);
  7591. width: var(--color-input-width);
  7592. flex-shrink: 0;
  7593. }
  7594. .lil-gui .controller.option select {
  7595. opacity: 0;
  7596. position: absolute;
  7597. width: 100%;
  7598. max-width: 100%;
  7599. }
  7600. .lil-gui .controller.option .display {
  7601. position: relative;
  7602. pointer-events: none;
  7603. border-radius: var(--widget-border-radius);
  7604. height: var(--widget-height);
  7605. line-height: var(--widget-height);
  7606. max-width: 100%;
  7607. overflow: hidden;
  7608. word-break: break-all;
  7609. padding-left: 0.55em;
  7610. padding-right: 1.75em;
  7611. background: var(--widget-color);
  7612. }
  7613. @media (hover: hover) {
  7614. .lil-gui .controller.option .display.focus {
  7615. background: var(--focus-color);
  7616. }
  7617. }
  7618. .lil-gui .controller.option .display.active {
  7619. background: var(--focus-color);
  7620. }
  7621. .lil-gui .controller.option .display:after {
  7622. font-family: "lil-gui";
  7623. content: "↕";
  7624. position: absolute;
  7625. top: 0;
  7626. right: 0;
  7627. bottom: 0;
  7628. padding-right: 0.375em;
  7629. }
  7630. .lil-gui .controller.option .widget,
  7631. .lil-gui .controller.option select {
  7632. cursor: pointer;
  7633. }
  7634. @media (hover: hover) {
  7635. .lil-gui .controller.option .widget:hover .display {
  7636. background: var(--hover-color);
  7637. }
  7638. }
  7639. .lil-gui .controller.number input {
  7640. color: var(--number-color);
  7641. }
  7642. .lil-gui .controller.number.hasSlider input {
  7643. margin-left: var(--spacing);
  7644. width: var(--slider-input-width);
  7645. min-width: var(--slider-input-min-width);
  7646. flex-shrink: 0;
  7647. }
  7648. .lil-gui .controller.number .slider {
  7649. width: 100%;
  7650. height: var(--widget-height);
  7651. background: var(--widget-color);
  7652. border-radius: var(--widget-border-radius);
  7653. padding-right: var(--slider-knob-width);
  7654. overflow: hidden;
  7655. cursor: ew-resize;
  7656. touch-action: pan-y;
  7657. }
  7658. @media (hover: hover) {
  7659. .lil-gui .controller.number .slider:hover {
  7660. background: var(--hover-color);
  7661. }
  7662. }
  7663. .lil-gui .controller.number .slider.active {
  7664. background: var(--focus-color);
  7665. }
  7666. .lil-gui .controller.number .slider.active .fill {
  7667. opacity: 0.95;
  7668. }
  7669. .lil-gui .controller.number .fill {
  7670. height: 100%;
  7671. border-right: var(--slider-knob-width) solid var(--number-color);
  7672. box-sizing: content-box;
  7673. }
  7674. .lil-gui-dragging .lil-gui {
  7675. --hover-color: var(--widget-color);
  7676. }
  7677. .lil-gui-dragging * {
  7678. cursor: ew-resize !important;
  7679. }
  7680. .lil-gui-dragging.lil-gui-vertical * {
  7681. cursor: ns-resize !important;
  7682. }
  7683. .lil-gui .title {
  7684. height: var(--title-height);
  7685. line-height: calc(var(--title-height) - 4px);
  7686. font-weight: 600;
  7687. padding: 0 var(--padding);
  7688. -webkit-tap-highlight-color: transparent;
  7689. cursor: pointer;
  7690. outline: none;
  7691. text-decoration-skip: objects;
  7692. }
  7693. .lil-gui .title:before {
  7694. font-family: "lil-gui";
  7695. content: "▾";
  7696. padding-right: 2px;
  7697. display: inline-block;
  7698. }
  7699. .lil-gui .title:active {
  7700. background: var(--title-background-color);
  7701. opacity: 0.75;
  7702. }
  7703. @media (hover: hover) {
  7704. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7705. background: var(--title-background-color);
  7706. opacity: 0.85;
  7707. }
  7708. .lil-gui .title:focus {
  7709. text-decoration: underline var(--focus-color);
  7710. }
  7711. }
  7712. .lil-gui.root > .title:focus {
  7713. text-decoration: none !important;
  7714. }
  7715. .lil-gui.closed > .title:before {
  7716. content: "▸";
  7717. }
  7718. .lil-gui.closed > .children {
  7719. transform: translateY(-7px);
  7720. opacity: 0;
  7721. }
  7722. .lil-gui.closed:not(.transition) > .children {
  7723. display: none;
  7724. }
  7725. .lil-gui.transition > .children {
  7726. transition-duration: 300ms;
  7727. transition-property: height, opacity, transform;
  7728. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7729. overflow: hidden;
  7730. pointer-events: none;
  7731. }
  7732. .lil-gui .children:empty:before {
  7733. content: "Empty";
  7734. padding: 0 var(--padding);
  7735. margin: var(--spacing) 0;
  7736. display: block;
  7737. height: var(--widget-height);
  7738. font-style: italic;
  7739. line-height: var(--widget-height);
  7740. opacity: 0.5;
  7741. }
  7742. .lil-gui.root > .children > .lil-gui > .title {
  7743. border: 0 solid var(--widget-color);
  7744. border-width: 1px 0;
  7745. transition: border-color 300ms;
  7746. }
  7747. .lil-gui.root > .children > .lil-gui.closed > .title {
  7748. border-bottom-color: transparent;
  7749. }
  7750. .lil-gui + .controller {
  7751. border-top: 1px solid var(--widget-color);
  7752. margin-top: 0;
  7753. padding-top: var(--spacing);
  7754. }
  7755. .lil-gui .lil-gui .lil-gui > .title {
  7756. border: none;
  7757. }
  7758. .lil-gui .lil-gui .lil-gui > .children {
  7759. border: none;
  7760. margin-left: var(--folder-indent);
  7761. border-left: 2px solid var(--widget-color);
  7762. }
  7763. .lil-gui .lil-gui .controller {
  7764. border: none;
  7765. }
  7766. .lil-gui label, .lil-gui input, .lil-gui button {
  7767. -webkit-tap-highlight-color: transparent;
  7768. }
  7769. .lil-gui input {
  7770. border: 0;
  7771. outline: none;
  7772. font-family: var(--font-family);
  7773. font-size: var(--input-font-size);
  7774. border-radius: var(--widget-border-radius);
  7775. height: var(--widget-height);
  7776. background: var(--widget-color);
  7777. color: var(--text-color);
  7778. width: 100%;
  7779. }
  7780. @media (hover: hover) {
  7781. .lil-gui input:hover {
  7782. background: var(--hover-color);
  7783. }
  7784. .lil-gui input:active {
  7785. background: var(--focus-color);
  7786. }
  7787. }
  7788. .lil-gui input:disabled {
  7789. opacity: 1;
  7790. }
  7791. .lil-gui input[type=text],
  7792. .lil-gui input[type=number] {
  7793. padding: var(--widget-padding);
  7794. -moz-appearance: textfield;
  7795. }
  7796. .lil-gui input[type=text]:focus,
  7797. .lil-gui input[type=number]:focus {
  7798. background: var(--focus-color);
  7799. }
  7800. .lil-gui input[type=checkbox] {
  7801. appearance: none;
  7802. width: var(--checkbox-size);
  7803. height: var(--checkbox-size);
  7804. border-radius: var(--widget-border-radius);
  7805. text-align: center;
  7806. cursor: pointer;
  7807. }
  7808. .lil-gui input[type=checkbox]:checked:before {
  7809. font-family: "lil-gui";
  7810. content: "✓";
  7811. font-size: var(--checkbox-size);
  7812. line-height: var(--checkbox-size);
  7813. }
  7814. @media (hover: hover) {
  7815. .lil-gui input[type=checkbox]:focus {
  7816. box-shadow: inset 0 0 0 1px var(--focus-color);
  7817. }
  7818. }
  7819. .lil-gui button {
  7820. outline: none;
  7821. cursor: pointer;
  7822. font-family: var(--font-family);
  7823. font-size: var(--font-size);
  7824. color: var(--text-color);
  7825. width: 100%;
  7826. height: var(--widget-height);
  7827. text-transform: none;
  7828. background: var(--widget-color);
  7829. border-radius: var(--widget-border-radius);
  7830. border: none;
  7831. }
  7832. @media (hover: hover) {
  7833. .lil-gui button:hover {
  7834. background: var(--hover-color);
  7835. }
  7836. .lil-gui button:focus {
  7837. box-shadow: inset 0 0 0 1px var(--focus-color);
  7838. }
  7839. }
  7840. .lil-gui button:active {
  7841. background: var(--focus-color);
  7842. }
  7843. @font-face {
  7844. font-family: "lil-gui";
  7845. 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");
  7846. }`;function aUe(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 _V=!1;class Uw{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:s=!1,injectStyles:o=!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"),!_V&&o&&(aUe(iUe),_V=!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=s}add(e,n,r,i,a){if(Object(r)===r)return new nUe(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new tUe(this,e,n,r,i,a);case"boolean":return new KFe(this,e,n);case"string":return new rUe(this,e,n);case"function":return new CN(this,e,n)}console.error(`gui.add failed
  7847. property:`,n,`
  7848. object:`,e,`
  7849. value:`,s)}addColor(e,n,r=1){return new eUe(this,e,n,r)}addFolder(e){const n=new Uw({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof CN||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 CN)){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 NN(t,e,n,r){return new(n||(n=Promise))((function(i,a){function s(u){try{c(r.next(u))}catch(d){a(d)}}function o(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(s,o)}c((r=r.apply(t,[])).next())}))}class SO{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 SO(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 MO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class wV extends MO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Eu extends MO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class SV{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class zw{constructor(e){this.lines=[],this.preamble=new SV(-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(`
  7850. `);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,s]of Object.entries(i))this.metadata.thumbnails[a]=s;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],s=n&&i[1]||void 0,o=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",u=this.parseParams(o.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new wV(e,c,u,s);case"t0":return new Eu(e,c,s,0);case"t1":return new Eu(e,c,s,1);case"t2":return new Eu(e,c,s,2);case"t3":return new Eu(e,c,s,3);case"t4":return new Eu(e,c,s,4);case"t5":return new Eu(e,c,s,5);case"t6":return new Eu(e,c,s,6);case"t7":return new Eu(e,c,s,7);default:return new MO(e,c,u,s)}}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 s=a[i-1];return s=s.toLowerCase(),this.isAlpha(s)&&(n[s]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof wV){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 s=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new SV(this.layers.length,[],r,s))}}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 s=a.indexOf("thumbnail begin"),o=a.indexOf("thumbnail end");s>-1?r=SO.parse(a.slice(s+15).trim()):r&&(o==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}zw.prototype.parseGcode=zw.prototype.parseGCode;const MV={type:"change"},kN={type:"start"},EV={type:"end"},P_=new bO,AV=new Pu,sUe=Math.cos(70*FZ.DEG2RAD);class oUe extends mf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new je,this.cursor=new je,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:pp.ROTATE,MIDDLE:pp.DOLLY,RIGHT:pp.PAN},this.touches={ONE:mp.ROTATE,TWO:mp.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 o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(B){B.addEventListener("keydown",Re),this._domElementKeyEvents=B},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(MV),r.update(),a=i.NONE},this.update=(function(){const B=new je,re=new rf().setFromUnitVectors(e.up,new je(0,1,0)),V=re.clone().invert(),J=new je,se=new rf,Ae=new je,Pe=2*Math.PI;return function(Se=null){const z=r.object.position;B.copy(z).sub(r.target),B.applyQuaternion(re),o.setFromVector3(B),r.autoRotate&&a===i.NONE&&D((function(we){return we!==null?2*Math.PI/60*r.autoRotateSpeed*we:2*Math.PI/60/60*r.autoRotateSpeed})(Se)),r.enableDamping?(o.theta+=c.theta*r.dampingFactor,o.phi+=c.phi*r.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let L=r.minAzimuthAngle,ne=r.maxAzimuthAngle;isFinite(L)&&isFinite(ne)&&(L<-Math.PI?L+=Pe:L>Math.PI&&(L-=Pe),ne<-Math.PI?ne+=Pe:ne>Math.PI&&(ne-=Pe),o.theta=L<=ne?Math.max(L,Math.min(ne,o.theta)):o.theta>(L+ne)/2?Math.max(L,o.theta):Math.min(ne,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.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?o.radius=ee(o.radius):o.radius=ee(o.radius*u),B.setFromSpherical(o),B.applyQuaternion(V),z.copy(r.target).add(B),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 ve=!1;if(r.zoomToCursor&&k){let we=null;if(r.object.isPerspectiveCamera){const ye=B.length();we=ee(ye*u);const nt=ye-we;r.object.position.addScaledVector(A,nt),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ye=new je(T.x,T.y,0);ye.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0;const nt=new je(T.x,T.y,0);nt.unproject(r.object),r.object.position.sub(nt).add(ye),r.object.updateMatrixWorld(),we=B.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;we!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(we).add(r.object.position):(P_.origin.copy(r.object.position),P_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(P_.direction))<sUe?e.lookAt(r.target):(AV.setFromNormalAndCoplanarPoint(r.object.up,r.target),P_.intersectPlane(AV,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0);return u=1,k=!1,!!(ve||J.distanceToSquared(r.object.position)>s||8*(1-se.dot(r.object.quaternion))>s||Ae.distanceToSquared(r.target)>0)&&(r.dispatchEvent(MV),J.copy(r.object.position),se.copy(r.object.quaternion),Ae.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",he),r.domElement.removeEventListener("pointerdown",be),r.domElement.removeEventListener("pointercancel",ie),r.domElement.removeEventListener("wheel",xe),r.domElement.removeEventListener("pointermove",Ne),r.domElement.removeEventListener("pointerup",ie),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 s=1e-6,o=new yV,c=new yV;let u=1;const d=new je,f=new Zt,g=new Zt,m=new Zt,b=new Zt,y=new Zt,v=new Zt,x=new Zt,M=new Zt,S=new Zt,A=new je,T=new Zt;let k=!1;const N=[],I={};function C(){return Math.pow(.95,r.zoomSpeed)}function D(B){c.theta-=B}function F(B){c.phi-=B}const O=(function(){const B=new je;return function(re,V){B.setFromMatrixColumn(V,0),B.multiplyScalar(-re),d.add(B)}})(),q=(function(){const B=new je;return function(re,V){r.screenSpacePanning===!0?B.setFromMatrixColumn(V,1):(B.setFromMatrixColumn(V,0),B.crossVectors(r.object.up,B)),B.multiplyScalar(re),d.add(B)}})(),R=(function(){const B=new je;return function(re,V){const J=r.domElement;if(r.object.isPerspectiveCamera){const se=r.object.position;B.copy(se).sub(r.target);let Ae=B.length();Ae*=Math.tan(r.object.fov/2*Math.PI/180),O(2*re*Ae/J.clientHeight,r.object.matrix),q(2*V*Ae/J.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(re*(r.object.right-r.object.left)/r.object.zoom/J.clientWidth,r.object.matrix),q(V*(r.object.top-r.object.bottom)/r.object.zoom/J.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(B){if(!r.zoomToCursor)return;k=!0;const re=r.domElement.getBoundingClientRect(),V=B.clientX-re.left,J=B.clientY-re.top,se=re.width,Ae=re.height;T.x=V/se*2-1,T.y=-J/Ae*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function ee(B){return Math.max(r.minDistance,Math.min(r.maxDistance,B))}function Z(B){f.set(B.clientX,B.clientY)}function Q(B){b.set(B.clientX,B.clientY)}function U(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const B=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);f.set(B,re)}}function $(){if(N.length===1)b.set(N[0].pageX,N[0].pageY);else{const B=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);b.set(B,re)}}function X(){const B=N[0].pageX-N[1].pageX,re=N[0].pageY-N[1].pageY,V=Math.sqrt(B*B+re*re);x.set(0,V)}function te(B){if(N.length==1)g.set(B.pageX,B.pageY);else{const V=H(B),J=.5*(B.pageX+V.x),se=.5*(B.pageY+V.y);g.set(J,se)}m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const re=r.domElement;D(2*Math.PI*m.x/re.clientHeight),F(2*Math.PI*m.y/re.clientHeight),f.copy(g)}function fe(B){if(N.length===1)y.set(B.pageX,B.pageY);else{const re=H(B),V=.5*(B.pageX+re.x),J=.5*(B.pageY+re.y);y.set(V,J)}v.subVectors(y,b).multiplyScalar(r.panSpeed),R(v.x,v.y),b.copy(y)}function pe(B){const re=H(B),V=B.pageX-re.x,J=B.pageY-re.y,se=Math.sqrt(V*V+J*J);M.set(0,se),S.set(0,Math.pow(M.y/x.y,r.zoomSpeed)),W(S.y),x.copy(M)}function be(B){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture(B.pointerId),r.domElement.addEventListener("pointermove",Ne),r.domElement.addEventListener("pointerup",ie)),(function(re){N.push(re)})(B),B.pointerType==="touch"?(function(re){switch(ht(re),N.length){case 1:switch(r.touches.ONE){case mp.ROTATE:if(r.enableRotate===!1)return;U(),a=i.TOUCH_ROTATE;break;case mp.PAN:if(r.enablePan===!1)return;$(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case mp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&X(),r.enablePan&&$(),a=i.TOUCH_DOLLY_PAN;break;case mp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&X(),r.enableRotate&&U(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(kN)})(B):(function(re){let V;switch(re.button){case 0:V=r.mouseButtons.LEFT;break;case 1:V=r.mouseButtons.MIDDLE;break;case 2:V=r.mouseButtons.RIGHT;break;default:V=-1}switch(V){case pp.DOLLY:if(r.enableZoom===!1)return;(function(J){G(J),x.set(J.clientX,J.clientY)})(re),a=i.DOLLY;break;case pp.ROTATE:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enablePan===!1)return;Q(re),a=i.PAN}else{if(r.enableRotate===!1)return;Z(re),a=i.ROTATE}break;case pp.PAN:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enableRotate===!1)return;Z(re),a=i.ROTATE}else{if(r.enablePan===!1)return;Q(re),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(kN)})(B))}function Ne(B){r.enabled!==!1&&(B.pointerType==="touch"?(function(re){switch(ht(re),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;te(re),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;fe(re),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(V){r.enableZoom&&pe(V),r.enablePan&&fe(V)})(re),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(V){r.enableZoom&&pe(V),r.enableRotate&&te(V)})(re),r.update();break;default:a=i.NONE}})(B):(function(re){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(V){g.set(V.clientX,V.clientY),m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const J=r.domElement;D(2*Math.PI*m.x/J.clientHeight),F(2*Math.PI*m.y/J.clientHeight),f.copy(g),r.update()})(re);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(V){M.set(V.clientX,V.clientY),S.subVectors(M,x),S.y>0?W(C()):S.y<0&&K(C()),x.copy(M),r.update()})(re);break;case i.PAN:if(r.enablePan===!1)return;(function(V){y.set(V.clientX,V.clientY),v.subVectors(y,b).multiplyScalar(r.panSpeed),R(v.x,v.y),b.copy(y),r.update()})(re)}})(B))}function ie(B){(function(re){delete I[re.pointerId];for(let V=0;V<N.length;V++)if(N[V].pointerId==re.pointerId)return void N.splice(V,1)})(B),N.length===0&&(r.domElement.releasePointerCapture(B.pointerId),r.domElement.removeEventListener("pointermove",Ne),r.domElement.removeEventListener("pointerup",ie)),r.dispatchEvent(EV),a=i.NONE}function xe(B){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(B.preventDefault(),r.dispatchEvent(kN),(function(re){G(re),re.deltaY<0?K(C()):re.deltaY>0&&W(C()),r.update()})(B),r.dispatchEvent(EV))}function Re(B){r.enabled!==!1&&r.enablePan!==!1&&(function(re){let V=!1;switch(re.code){case r.keys.UP:re.ctrlKey||re.metaKey||re.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),V=!0;break;case r.keys.BOTTOM:re.ctrlKey||re.metaKey||re.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),V=!0;break;case r.keys.LEFT:re.ctrlKey||re.metaKey||re.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),V=!0;break;case r.keys.RIGHT:re.ctrlKey||re.metaKey||re.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),V=!0}V&&(re.preventDefault(),r.update())})(B)}function he(B){r.enabled!==!1&&B.preventDefault()}function ht(B){let re=I[B.pointerId];re===void 0&&(re=new Zt,I[B.pointerId]=re),re.set(B.pageX,B.pageY)}function H(B){const re=B.pointerId===N[0].pointerId?N[1]:N[0];return I[re.pointerId]}r.domElement.addEventListener("contextmenu",he),r.domElement.addEventListener("pointerdown",be),r.domElement.addEventListener("pointercancel",ie),r.domElement.addEventListener("wheel",xe,{passive:!1}),this.update()}}_t.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Zt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Va.line={uniforms:yO.merge([_t.common,_t.fog,_t.line]),vertexShader:`
  7851. #include <common>
  7852. #include <color_pars_vertex>
  7853. #include <fog_pars_vertex>
  7854. #include <logdepthbuf_pars_vertex>
  7855. #include <clipping_planes_pars_vertex>
  7856. uniform float linewidth;
  7857. uniform vec2 resolution;
  7858. attribute vec3 instanceStart;
  7859. attribute vec3 instanceEnd;
  7860. attribute vec3 instanceColorStart;
  7861. attribute vec3 instanceColorEnd;
  7862. #ifdef WORLD_UNITS
  7863. varying vec4 worldPos;
  7864. varying vec3 worldStart;
  7865. varying vec3 worldEnd;
  7866. #ifdef USE_DASH
  7867. varying vec2 vUv;
  7868. #endif
  7869. #else
  7870. varying vec2 vUv;
  7871. #endif
  7872. #ifdef USE_DASH
  7873. uniform float dashScale;
  7874. attribute float instanceDistanceStart;
  7875. attribute float instanceDistanceEnd;
  7876. varying float vLineDistance;
  7877. #endif
  7878. void trimSegment( const in vec4 start, inout vec4 end ) {
  7879. // trim end segment so it terminates between the camera plane and the near plane
  7880. // conservative estimate of the near plane
  7881. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7882. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7883. float nearEstimate = - 0.5 * b / a;
  7884. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7885. end.xyz = mix( start.xyz, end.xyz, alpha );
  7886. }
  7887. void main() {
  7888. #ifdef USE_COLOR
  7889. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7890. #endif
  7891. #ifdef USE_DASH
  7892. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7893. vUv = uv;
  7894. #endif
  7895. float aspect = resolution.x / resolution.y;
  7896. // camera space
  7897. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7898. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7899. #ifdef WORLD_UNITS
  7900. worldStart = start.xyz;
  7901. worldEnd = end.xyz;
  7902. #else
  7903. vUv = uv;
  7904. #endif
  7905. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7906. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7907. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7908. // perhaps there is a more elegant solution -- WestLangley
  7909. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7910. if ( perspective ) {
  7911. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7912. trimSegment( start, end );
  7913. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7914. trimSegment( end, start );
  7915. }
  7916. }
  7917. // clip space
  7918. vec4 clipStart = projectionMatrix * start;
  7919. vec4 clipEnd = projectionMatrix * end;
  7920. // ndc space
  7921. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7922. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7923. // direction
  7924. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7925. // account for clip-space aspect ratio
  7926. dir.x *= aspect;
  7927. dir = normalize( dir );
  7928. #ifdef WORLD_UNITS
  7929. // get the offset direction as perpendicular to the view vector
  7930. vec3 worldDir = normalize( end.xyz - start.xyz );
  7931. vec3 offset;
  7932. if ( position.y < 0.5 ) {
  7933. offset = normalize( cross( start.xyz, worldDir ) );
  7934. } else {
  7935. offset = normalize( cross( end.xyz, worldDir ) );
  7936. }
  7937. // sign flip
  7938. if ( position.x < 0.0 ) offset *= - 1.0;
  7939. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7940. // don't extend the line if we're rendering dashes because we
  7941. // won't be rendering the endcaps
  7942. #ifndef USE_DASH
  7943. // extend the line bounds to encompass endcaps
  7944. start.xyz += - worldDir * linewidth * 0.5;
  7945. end.xyz += worldDir * linewidth * 0.5;
  7946. // shift the position of the quad so it hugs the forward edge of the line
  7947. offset.xy -= dir * forwardOffset;
  7948. offset.z += 0.5;
  7949. #endif
  7950. // endcaps
  7951. if ( position.y > 1.0 || position.y < 0.0 ) {
  7952. offset.xy += dir * 2.0 * forwardOffset;
  7953. }
  7954. // adjust for linewidth
  7955. offset *= linewidth * 0.5;
  7956. // set the world position
  7957. worldPos = ( position.y < 0.5 ) ? start : end;
  7958. worldPos.xyz += offset;
  7959. // project the worldpos
  7960. vec4 clip = projectionMatrix * worldPos;
  7961. // shift the depth of the projected points so the line
  7962. // segments overlap neatly
  7963. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7964. clip.z = clipPose.z * clip.w;
  7965. #else
  7966. vec2 offset = vec2( dir.y, - dir.x );
  7967. // undo aspect ratio adjustment
  7968. dir.x /= aspect;
  7969. offset.x /= aspect;
  7970. // sign flip
  7971. if ( position.x < 0.0 ) offset *= - 1.0;
  7972. // endcaps
  7973. if ( position.y < 0.0 ) {
  7974. offset += - dir;
  7975. } else if ( position.y > 1.0 ) {
  7976. offset += dir;
  7977. }
  7978. // adjust for linewidth
  7979. offset *= linewidth;
  7980. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7981. offset /= resolution.y;
  7982. // select end
  7983. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7984. // back to clip space
  7985. offset *= clip.w;
  7986. clip.xy += offset;
  7987. #endif
  7988. gl_Position = clip;
  7989. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7990. #include <logdepthbuf_vertex>
  7991. #include <clipping_planes_vertex>
  7992. #include <fog_vertex>
  7993. }
  7994. `,fragmentShader:`
  7995. uniform vec3 diffuse;
  7996. uniform float opacity;
  7997. uniform float linewidth;
  7998. #ifdef USE_DASH
  7999. uniform float dashOffset;
  8000. uniform float dashSize;
  8001. uniform float gapSize;
  8002. #endif
  8003. varying float vLineDistance;
  8004. #ifdef WORLD_UNITS
  8005. varying vec4 worldPos;
  8006. varying vec3 worldStart;
  8007. varying vec3 worldEnd;
  8008. #ifdef USE_DASH
  8009. varying vec2 vUv;
  8010. #endif
  8011. #else
  8012. varying vec2 vUv;
  8013. #endif
  8014. #include <common>
  8015. #include <color_pars_fragment>
  8016. #include <fog_pars_fragment>
  8017. #include <logdepthbuf_pars_fragment>
  8018. #include <clipping_planes_pars_fragment>
  8019. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8020. float mua;
  8021. float mub;
  8022. vec3 p13 = p1 - p3;
  8023. vec3 p43 = p4 - p3;
  8024. vec3 p21 = p2 - p1;
  8025. float d1343 = dot( p13, p43 );
  8026. float d4321 = dot( p43, p21 );
  8027. float d1321 = dot( p13, p21 );
  8028. float d4343 = dot( p43, p43 );
  8029. float d2121 = dot( p21, p21 );
  8030. float denom = d2121 * d4343 - d4321 * d4321;
  8031. float numer = d1343 * d4321 - d1321 * d4343;
  8032. mua = numer / denom;
  8033. mua = clamp( mua, 0.0, 1.0 );
  8034. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8035. mub = clamp( mub, 0.0, 1.0 );
  8036. return vec2( mua, mub );
  8037. }
  8038. void main() {
  8039. #include <clipping_planes_fragment>
  8040. #ifdef USE_DASH
  8041. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8042. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8043. #endif
  8044. float alpha = opacity;
  8045. #ifdef WORLD_UNITS
  8046. // Find the closest points on the view ray and the line segment
  8047. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8048. vec3 lineDir = worldEnd - worldStart;
  8049. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8050. vec3 p1 = worldStart + lineDir * params.x;
  8051. vec3 p2 = rayEnd * params.y;
  8052. vec3 delta = p1 - p2;
  8053. float len = length( delta );
  8054. float norm = len / linewidth;
  8055. #ifndef USE_DASH
  8056. #ifdef USE_ALPHA_TO_COVERAGE
  8057. float dnorm = fwidth( norm );
  8058. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8059. #else
  8060. if ( norm > 0.5 ) {
  8061. discard;
  8062. }
  8063. #endif
  8064. #endif
  8065. #else
  8066. #ifdef USE_ALPHA_TO_COVERAGE
  8067. // artifacts appear on some hardware if a derivative is taken within a conditional
  8068. float a = vUv.x;
  8069. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8070. float len2 = a * a + b * b;
  8071. float dlen = fwidth( len2 );
  8072. if ( abs( vUv.y ) > 1.0 ) {
  8073. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8074. }
  8075. #else
  8076. if ( abs( vUv.y ) > 1.0 ) {
  8077. float a = vUv.x;
  8078. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8079. float len2 = a * a + b * b;
  8080. if ( len2 > 1.0 ) discard;
  8081. }
  8082. #endif
  8083. #endif
  8084. vec4 diffuseColor = vec4( diffuse, alpha );
  8085. #include <logdepthbuf_fragment>
  8086. #include <color_fragment>
  8087. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8088. #include <tonemapping_fragment>
  8089. #include <colorspace_fragment>
  8090. #include <fog_fragment>
  8091. #include <premultiplied_alpha_fragment>
  8092. }
  8093. `};class aQ extends pd{constructor(e){super({type:"LineMaterial",uniforms:yO.clone(Va.line.uniforms),vertexShader:Va.line.vertexShader,fragmentShader:Va.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 TV=new ao,R_=new je;class sQ extends GFe{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 Br([-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 Br([-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 zP(n,6,1);return this.setAttribute("instanceStart",new $u(r,3,0)),this.setAttribute("instanceEnd",new $u(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 zP(n,6,1);return this.setAttribute("instanceColorStart",new $u(r,3,0)),this.setAttribute("instanceColorEnd",new $u(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 FFe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ao);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),TV.setFromBufferAttribute(n),this.boundingBox.union(TV))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ul),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,s=e.count;a<s;a++)R_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(R_)),R_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(R_));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 CV=new je,NV=new je,Wi=new Zn,qi=new Zn,Xo=new Zn,PN=new je,RN=new ar,Ki=new WFe,kV=new je,D_=new ao,j_=new ul,Yo=new Zn;let Zo,dh;function PV(t,e,n){return Yo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Yo.multiplyScalar(1/Yo.w),Yo.x=dh/n.width,Yo.y=dh/n.height,Yo.applyMatrix4(t.projectionMatrixInverse),Yo.multiplyScalar(1/Yo.w),Math.abs(Math.max(Yo.x,Yo.y))}class lUe extends jo{constructor(e=new sQ,n=new aQ({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 s=0,o=0,c=n.count;s<c;s++,o+=2)CV.fromBufferAttribute(n,s),NV.fromBufferAttribute(r,s),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+CV.distanceTo(NV);const a=new zP(i,2,1);return e.setAttribute("instanceDistanceStart",new $u(a,1,0)),e.setAttribute("instanceDistanceEnd",new $u(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;Zo=e.ray;const s=this.matrixWorld,o=this.geometry,c=this.material;let u,d;dh=c.linewidth+a,o.boundingSphere===null&&o.computeBoundingSphere(),j_.copy(o.boundingSphere).applyMatrix4(s),r?u=.5*dh:u=PV(i,Math.max(i.near,j_.distanceToPoint(Zo.origin)),c.resolution),j_.radius+=u,Zo.intersectsSphere(j_)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),D_.copy(o.boundingBox).applyMatrix4(s),r?d=.5*dh:d=PV(i,Math.max(i.near,D_.distanceToPoint(Zo.origin)),c.resolution),D_.expandByScalar(d),Zo.intersectsBox(D_)!==!1&&(r?(function(f,g){const m=f.matrixWorld,b=f.geometry,y=b.attributes.instanceStart,v=b.attributes.instanceEnd;for(let x=0,M=Math.min(b.instanceCount,y.count);x<M;x++){Ki.start.fromBufferAttribute(y,x),Ki.end.fromBufferAttribute(v,x),Ki.applyMatrix4(m);const S=new je,A=new je;Zo.distanceSqToSegment(Ki.start,Ki.end,A,S),A.distanceTo(S)<.5*dh&&g.push({point:A,pointOnLine:S,distance:Zo.origin.distanceTo(A),object:f,face:null,faceIndex:x,uv:null,uv1:null})}})(this,n):(function(f,g,m){const b=g.projectionMatrix,y=f.material.resolution,v=f.matrixWorld,x=f.geometry,M=x.attributes.instanceStart,S=x.attributes.instanceEnd,A=Math.min(x.instanceCount,M.count),T=-g.near;Zo.at(1,Xo),Xo.w=1,Xo.applyMatrix4(g.matrixWorldInverse),Xo.applyMatrix4(b),Xo.multiplyScalar(1/Xo.w),Xo.x*=y.x/2,Xo.y*=y.y/2,Xo.z=0,PN.copy(Xo),RN.multiplyMatrices(g.matrixWorldInverse,v);for(let k=0,N=A;k<N;k++){if(Wi.fromBufferAttribute(M,k),qi.fromBufferAttribute(S,k),Wi.w=1,qi.w=1,Wi.applyMatrix4(RN),qi.applyMatrix4(RN),Wi.z>T&&qi.z>T)continue;if(Wi.z>T){const O=Wi.z-qi.z,q=(Wi.z-T)/O;Wi.lerp(qi,q)}else if(qi.z>T){const O=qi.z-Wi.z,q=(qi.z-T)/O;qi.lerp(Wi,q)}Wi.applyMatrix4(b),qi.applyMatrix4(b),Wi.multiplyScalar(1/Wi.w),qi.multiplyScalar(1/qi.w),Wi.x*=y.x/2,Wi.y*=y.y/2,qi.x*=y.x/2,qi.y*=y.y/2,Ki.start.copy(Wi),Ki.start.z=0,Ki.end.copy(qi),Ki.end.z=0;const I=Ki.closestPointToPointParameter(PN,!0);Ki.at(I,kV);const C=FZ.lerp(Wi.z,qi.z,I),D=C>=-1&&C<=1,F=PN.distanceTo(kV)<.5*dh;if(D&&F){Ki.start.fromBufferAttribute(M,k),Ki.end.fromBufferAttribute(S,k),Ki.start.applyMatrix4(v),Ki.end.applyMatrix4(v);const O=new je,q=new je;Zo.distanceSqToSegment(Ki.start,Ki.end,q,O),m.push({point:q,pointOnLine:O,distance:Zo.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class cUe extends qM{constructor(e,n,r,i,a=4473924,s=8947848){a=new $t(a),s=new $t(s);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){c.push(g,0,-1*r,g,0,r);const m=g===0?a:s;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}for(let g=-1*r;g<=r;g+=i){c.push(-1*e,0,g,e,0,g);const m=g===0?a:s;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}const f=new ga;f.setAttribute("position",new Br(c,3)),f.setAttribute("color",new Br(u,3)),super(f,new Xb({vertexColors:!0,toneMapped:!1}))}}function uUe(t,e,n,r){const i=(function(s,o,c){s*=.5,o*=.5,c*=.5;const u=new ga,d=[];return d.push(-s,-o,-c,-s,o,-c,-s,o,-c,s,o,-c,s,o,-c,s,-o,-c,s,-o,-c,-s,-o,-c,-s,-o,c,-s,o,c,-s,o,c,s,o,c,s,o,c,s,-o,c,s,-o,c,-s,-o,c,-s,-o,-c,-s,-o,c,-s,o,-c,-s,o,c,s,o,-c,s,o,c,s,-o,-c,s,-o,c),u.setAttribute("position",new Br(d,3)),u})(t,e,n),a=new qM(i,new zFe({color:new $t(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var Zx=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,s=0,o=n(new Zx.Panel("FPS","#0ff","#002")),c=n(new Zx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Zx.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){s++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(o.update(1e3*s/(d-a),100),a=d,s=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}};Zx.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,c=48*s,u=3*s,d=2*s,f=3*s,g=15*s,m=74*s,b=30*s,y=document.createElement("canvas");y.width=o,y.height=c,y.style.cssText="width:80px;height:48px";var v=y.getContext("2d");return v.font="bold "+9*s+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=n,v.fillRect(0,0,o,c),v.fillStyle=e,v.fillText(t,u,d),v.fillRect(f,g,m,b),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f,g,m,b),{dom:y,update:function(x,M){r=Math.min(r,x),i=Math.max(i,x),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,o,g),v.fillStyle=e,v.fillText(a(x)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),v.drawImage(y,f+s,g,m-s,b,f,g,m-s,b),v.fillRect(f+m-s,g,s,b),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f+m-s,g,s,a((1-x/M)*b))}}};var dUe=Zx;class RV{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new Uw,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 Uw,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 hUe extends ga{constructor(e=[new je],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 je,s=new je,o=new Zt,c=[],u=[],d=[],f=[];function g(m){const[b,y,v]=(function(x){const M=e[x],S=new je,A=new je,T=new je,k=new je;S.copy(M).sub(e[x-1]||M).normalize().add((e[x+1]||M).clone().sub(M).normalize()).normalize();let N=Number.MAX_VALUE;const I=Math.abs(S.x),C=Math.abs(S.y),D=Math.abs(S.z);return I<=N&&(N=I,A.set(1,0,0)),C<=N&&(N=C,A.set(0,1,0)),D<=N&&A.set(0,0,1),k.crossVectors(S,A).normalize(),A.crossVectors(S,k),T.crossVectors(S,A),[M,A,T]})(m);for(let x=0;x<=i;x++){const M=x/i*Math.PI*2,S=Math.sin(M),A=-Math.cos(M);s.x=A*y.x+S*v.x,s.y=A*y.y+S*v.y,s.z=A*y.z+S*v.z,s.normalize(),u.push(s.x,s.y,s.z),a.x=b.x+n*s.x*.5,a.y=b.y+n*s.y*.5,a.z=b.z+r*s.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let m=0;m<e.length;m++)g(m);g(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let b=0;b<=i;b++)o.x=m/e.length,o.y=b/i,d.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let b=1;b<=i;b++){const y=(i+1)*(m-1)+(b-1),v=(i+1)*m+(b-1),x=(i+1)*m+b,M=(i+1)*(m-1)+b;f.push(y,v,M),f.push(v,x,M)}})()})(),this.setIndex(f),this.setAttribute("position",new Br(c,3)),this.setAttribute("normal",new Br(u,3)),this.setAttribute("uv",new Br(d,2))}}class Qx{static get initial(){const e=new Qx;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const DN={h:0,s:0,l:0};class om{constructor(e){var n,r,i,a,s,o,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=Qx.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=om.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new $t(14737632),this._travelColor=new $t(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 zw(this.minLayerThreshold),this.scene=new CFe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new $t(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=(s=e.renderTravel)!==null&&s!==void 0?s:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o: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 dUe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new $t(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new $t(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new $t(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,b]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new $t(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+HM),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 UP({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new UP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ms(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,g=.8*f;this.scene.fog=new wO(this._backgroundColor,g,f),this.resize(),this.controls=new oUe(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 $t(r)}else this._extrusionColor=new $t(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?om.defaultExtrusionColor:this._extrusionColor instanceof $t?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:om.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new $t(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new $t(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new $t(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new $t(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 qFe(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 VFe(13421772,.3*Math.PI),n=new $Fe(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 Ux;return n.name=e,n.quaternion.setFromEuler(new qb(-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=Qx.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 NN(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,s,o,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const m=g;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const m=g,b={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=m.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=m.params.e)!==null&&s!==void 0?s:this.state.e,i:(o=m.params.i)!==null&&o!==void 0?o:this.state.i,j:(c=m.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,b,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,b,y))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const s=.1+.7*n/this.layers.length;a.getHSL(DN),a=new $t().setHSL(DN.h,DN.s,s)}if(n==this.layers.length-1){const s=(r=this._topLayerColor)!==null&&r!==void 0?r:a,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:s,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,s.getHex(),e.height),this.addTubeLine([...u,...c],o.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...u,...c],o.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 cUe(this.buildVolume.x,10,this.buildVolume.y,10));const e=uUe(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 zw(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Qx.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 s=i?e.extrusion:e.travel,o=n.x,c=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let m=r.r,b=r.i,y=r.j;if(m){const W=d-o,K=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));m=Math.max(m,G);const ee=Math.pow(W,2)+Math.pow(K,2),Z=Math.pow(m,2)-ee/4;let Q=Math.sqrt(Z/ee);(a&&m<0||!a&&m>0)&&(Q=-Q),b=W/2+K*Q,y=K/2-W*Q}const v=o==d&&c==f,x=o+b,M=c+y,S=Math.sqrt(b*b+y*y),A=Math.atan2(-y,-b),T=Math.atan2(f-M,d-x);let k;v?k=2*Math.PI:(k=a?A-T:T-A,k<0&&(k+=2*Math.PI));let N=S*k/1.8;this.inches&&(N*=25),N<1&&(N=1);let I=k/N;I*=a?-1:1;const C=[];C.push({x:o,y:c,z:u});const D=(u-g)/N;let F=o,O=c,q=u,R=A;for(let W=0;W<N-1;W++)R+=I,F=x+S*Math.cos(R),O=M+S*Math.sin(R),q+=D,C.push({x:F,y:O,z:q});C.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<C.length-1;W++)s.push(C[W].x,C[W].y,C[W].z,C[W+1].x,C[W+1].y,C[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ga;i.setAttribute("position",new Br(e,3)),this.disposables.push(i);const a=new Xb({color:n});this.disposables.push(a);const s=new qM(i,a);(r=this.group)===null||r===void 0||r.add(s)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let s=0;s<e.length;s+=6){const o=e.slice(s,s+9),c=new je(o[0],o[1],o[2]),u=new je(o[3],o[4],o[5]),d=new je(o[6],o[7],o[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((s=>{var o;const c=new hUe(s,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new sQ;this.disposables.push(i);const a=new aQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new lUe(i,a);(r=this.group)===null||r===void 0||r.add(s)}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=>NN(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 UFe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((o,c)=>3*c.attributes.position.count+o),0),s=new LFe(r.length,a,void 0,i);return this.disposables.push(s),(n=this.group)===null||n===void 0||n.add(s),s}_readFromStream(e){var n,r;return NN(this,void 0,void 0,(function*(){const i=e.getReader();let a,s="",o=0;do{console.debug("reading from stream"),a=yield i.read(),o+=(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(`
  8094. `),f=u.slice(0,d);this.parser.parseGCode(s+f),s=u.slice(d)}while(!a.done);var c;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new RV(this):typeof this.devMode=="object"&&(this.devGui=new RV(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())}}om.defaultExtrusionColor=new $t("hotpink");const fUe=function(t){return new om(t)};function pUe({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=E.useRef(null),a=E.useRef(null),s=E.useRef(null),[o,c]=E.useState(!0),[u,d]=E.useState(null),[f,g]=E.useState(!1),[m,b]=E.useState(0),[y,v]=E.useState(0);E.useEffect(()=>{if(!i.current)return;const S=i.current,A=n&&n.length>0,T=n&&n.length>1,k=A?n[0]:"#00ae42",N=fUe({canvas:S,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:T?n:k,...T?{}:{topLayerColor:k},...T?{disableGradient:!0}:{},lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=N,c(!0),d(null),g(!1),fetch(t).then(async C=>{if(!C.ok)throw C.status===404&&(await C.json().catch(()=>({}))).detail?.includes("sliced")?(g(!0),new Error("not_sliced")):new Error("Failed to load G-code");return C.text()}).then(C=>{let D=C;T&&(D=C.split(`
  8095. `).map(O=>{const q=O.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(q){const R=parseInt(q[2],10);if(R>15)return`${q[1]}; FILTERED: T${R}${q[3]||""}`}return O}).join(`
  8096. `),D=`T0
  8097. ${D}`),N.processGCode(D);const F=N.layers?.length||0;v(F),b(F),N.render(),c(!1)}).catch(C=>{d(C.message),c(!1)});const I=()=>{if(S.parentElement){const C=S.parentElement.getBoundingClientRect();S.width=C.width,S.height=C.height,N.resize()}};return I(),window.addEventListener("resize",I),()=>{window.removeEventListener("resize",I),s.current&&cancelAnimationFrame(s.current),N.dispose()}},[t,e,n]);const x=E.useCallback(S=>{if(!a.current)return;const A=Math.max(1,Math.min(S,y));b(A),s.current&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=A,a.current.render())})},[y]),M=S=>{x(parseInt(S.target.value,10))};return l.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[l.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[l.jsx("canvas",{ref:i,className:"w-full h-full"}),o&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsxs("div",{className:"text-center",children:[l.jsx(Et,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),l.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),f&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsxs("div",{className:"text-center max-w-sm px-4",children:[l.jsx(lle,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),l.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),l.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing the model in Bambu Studio or Orca Slicer."})]})}),u&&!f&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx("div",{className:"text-center text-red-400",children:l.jsx("p",{className:"text-sm",children:u})})})]}),!o&&!u&&!f&&y>0&&l.jsx("div",{className:"mt-4 px-2",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx($h,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.jsx("button",{onClick:()=>x(m-1),disabled:m<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:l.jsx(Bh,{className:"w-4 h-4"})}),l.jsx("input",{type:"range",min:1,max:y,value:m,onChange:M,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),l.jsx("button",{onClick:()=>x(m+1),disabled:m>=y,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:l.jsx(uf,{className:"w-4 h-4"})}),l.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[m," / ",y]})]})})]})}function mUe({archiveId:t,title:e,onClose:n}){const[r,i]=E.useState(null),[a,s]=E.useState(null),[o,c]=E.useState(!0);E.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),E.useEffect(()=>{ke.getArchiveCapabilities(t).then(d=>{s(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{s({has_model:!0,has_gcode:!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}${ke.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:l.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:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:u,children:[l.jsx(As,{className:"w-4 h-4"}),"Open in Slicer"]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),a&&l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.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:[l.jsx(hm,{className:"w-4 h-4"}),"3D Model",!a.has_model&&l.jsx("span",{className:"text-xs",children:"(not available)"})]}),l.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:[l.jsx(Loe,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&l.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),l.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(Et,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?l.jsx(uje,{url:ke.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):r==="gcode"&&a?l.jsx(pUe,{gcodeUrl:ke.getArchiveGcode(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function gUe({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,a]=E.useState(null);E.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);const{data:s,isLoading:o}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),c=wt({mutationFn:()=>{if(!i)throw new Error("No printer selected");return ke.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),u=s?.filter(d=>d.is_active)||[];return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",l.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(Et,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u.length===0?l.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):l.jsx("div",{className:"space-y-2 mb-6",children:u.map(d=>l.jsxs("button",{onClick:()=>a(d.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===d.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[l.jsx("div",{className:`p-2 rounded-lg ${i===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:l.jsx(Ts,{className:`w-5 h-5 ${i===d.id?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-white font-medium",children:d.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),c.isError&&l.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:c.error.message||"Failed to start print"}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{onClick:()=>c.mutate(),disabled:!i||c.isPending,className:"flex-1",children:c.isPending?l.jsxs(l.Fragment,{children:[l.jsx(Et,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Ts,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function xUe({onClose:t,initialFiles:e}){const n=En(),{showToast:r}=ai(),i=E.useRef(null),[a,s]=E.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[o,c]=E.useState(!1),[u,d]=E.useState(),[f,g]=E.useState(null);E.useEffect(()=>{const N=I=>{I.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);const{data:m}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),b=wt({mutationFn:N=>ke.uploadArchivesBulk(N,u),onSuccess:N=>{g(N),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(I=>I.map(C=>{const D=N.results.find(O=>O.filename===C.file.name),F=N.errors.find(O=>O.filename===C.file.name);return D?{...C,status:"success",archiveId:D.id}:F?{...C,status:"error",error:F.error}:C})),N.failed===0?r(`${N.uploaded} file${N.uploaded!==1?"s":""} uploaded`):N.uploaded===0?r(`Failed to upload ${N.failed} file${N.failed!==1?"s":""}`,"error"):r(`${N.uploaded} uploaded, ${N.failed} failed`,"warning")},onError:()=>{s(N=>N.map(I=>({...I,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=E.useCallback(N=>{N.preventDefault(),c(!0)},[]),v=E.useCallback(N=>{N.preventDefault(),c(!1)},[]),x=E.useCallback(N=>{N.preventDefault(),c(!1);const I=Array.from(N.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));I.length>0&&s(C=>[...C,...I.map(D=>({file:D,status:"pending"}))])},[]),M=E.useCallback(N=>{const I=Array.from(N.target.files||[]).filter(C=>C.name.endsWith(".3mf"));I.length>0&&s(C=>[...C,...I.map(D=>({file:D,status:"pending"}))]),i.current&&(i.current.value="")},[]),S=E.useCallback(N=>{s(I=>I.filter((C,D)=>D!==N))},[]),A=()=>{if(a.length===0)return;const N=a.filter(I=>I.status==="pending");N.length!==0&&(s(I=>I.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),b.mutate(N.map(I=>I.file)))},T=a.filter(N=>N.status==="pending").length,k=b.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4",children:l.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:v,onDrop:x,children:[l.jsx(vs,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),l.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),l.jsx(Le,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),l.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),l.jsxs("div",{className:"px-4 pb-4",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),l.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:N=>d(N.target.value?Number(N.target.value):void 0),disabled:k,children:[l.jsx("option",{value:"",children:"No printer"}),m?.map(N=>l.jsx("option",{value:N.id,children:N.name},N.id))]})]}),a.length>0&&l.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:l.jsx("div",{className:"space-y-2",children:a.map((N,I)=>l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[l.jsx(uG,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&l.jsx("button",{onClick:()=>S(I),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:l.jsx(Wt,{className:"w-4 h-4"})}),N.status==="uploading"&&l.jsx(Et,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs text-red-400",children:N.error}),l.jsx(lo,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${I}`))})}),f&&l.jsx("div",{className:"px-4 pb-4",children:l.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:l.jsxs("p",{className:"text-sm text-white",children:[l.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&l.jsxs(l.Fragment,{children:[", ",l.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&l.jsx(Le,{onClick:A,disabled:T===0||k,className:"flex-1",children:k?l.jsxs(l.Fragment,{children:[l.jsx(Et,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vs,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const bUe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],yUe=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function vUe({archive:t,onClose:e,existingTags:n=[]}){E.useEffect(()=>{const X=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e]);const r=En(),[i,a]=E.useState(t.print_name||""),[s,o]=E.useState(t.printer_id),[c,u]=E.useState(t.project_id??null),[d,f]=E.useState(t.notes||""),[g,m]=E.useState(t.tags||""),[b,y]=E.useState(t.failure_reason||""),[v,x]=E.useState(t.status),[M,S]=E.useState(t.photos||[]),[A,T]=E.useState(!1),[k,N]=E.useState(!1),I=E.useRef(null),C=E.useRef(null),D=E.useRef(null),{data:F}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:O}=vt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),{data:q}=vt({queryKey:["archives"],queryFn:()=>ke.getArchives(void 0,1e3,0),enabled:n.length===0}),R=n.length>0?n:[...new Set(q?.flatMap(X=>X.tags?.split(",").map(te=>te.trim())||[]).filter(Boolean)||[])].sort(),W=g.split(",").map(X=>X.trim()).filter(Boolean),K=R.filter(X=>!W.includes(X)),G=X=>{if(!W.includes(X)){const te=[...W,X].join(", ");m(te)}D.current!==null&&clearTimeout(D.current),I.current?.focus()},ee=X=>{const te=W.filter(fe=>fe!==X).join(", ");m(te)},Z=wt({mutationFn:X=>ke.updateArchive(t.id,X),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),Q=async X=>{const te=X.target.files?.[0];if(te){T(!0);try{const fe=await ke.uploadArchivePhoto(t.id,te);S(fe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(fe){console.error("Failed to upload photo:",fe)}finally{T(!1),C.current&&(C.current.value="")}}},U=async X=>{try{const te=await ke.deleteArchivePhoto(t.id,X);S(te.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(te){console.error("Failed to delete photo:",te)}},$=X=>{X.preventDefault();const te={print_name:i||void 0,printer_id:s,project_id:c,notes:d||void 0,tags:g||void 0};v!==t.status&&(te.status=v),v==="failed"||v==="aborted"?te.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(te.failure_reason=null),Z.mutate(te)};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.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:X=>X.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:$,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.jsx("input",{type:"text",value:i,onChange:X=>a(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),l.jsxs("select",{value:s??"",onChange:X=>o(X.target.value?Number(X.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:[l.jsx("option",{value:"",children:"No printer"}),F?.map(X=>l.jsx("option",{value:X.id,children:X.name},X.id))]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(Ku,{className:"w-4 h-4 inline mr-1"}),"Project"]}),l.jsxs("select",{value:c??"",onChange:X=>u(X.target.value?Number(X.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:[l.jsx("option",{value:"",children:"No project"}),O?.map(X=>l.jsx("option",{value:X.id,children:X.name},X.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),l.jsx("textarea",{value:d,onChange:X=>f(X.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..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),W.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:W.map(X=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[l.jsx(E0,{className:"w-3 h-3"}),X,l.jsx("button",{type:"button",onClick:()=>ee(X),className:"ml-0.5 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},X))}),l.jsxs("div",{className:"relative",children:[l.jsx("input",{ref:I,type:"text",value:g,onChange:X=>m(X.target.value),onFocus:()=>{D.current!==null&&clearTimeout(D.current),N(!0)},onBlur:()=>{D.current=window.setTimeout(()=>N(!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:W.length>0?"Add more tags...":"Add tags..."}),k&&K.length>0&&l.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:[l.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),l.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:K.map(X=>l.jsx("button",{type:"button",onClick:()=>G(X),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:X},X))})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),l.jsx("select",{value:v,onChange:X=>{x(X.target.value),X.target.value==="completed"&&y("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:yUe.map(X=>l.jsx("option",{value:X.value,children:X.label},X.value))})]}),(v==="failed"||v==="aborted")&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),l.jsxs("select",{value:b,onChange:X=>y(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"Select reason..."}),bUe.map(X=>l.jsx("option",{value:X,children:X},X))]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(b0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[M.map(X=>l.jsxs("div",{className:"relative group",children:[l.jsx("img",{src:ke.getArchivePhotoUrl(t.id,X),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),l.jsx("button",{type:"button",onClick:()=>U(X),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(Rn,{className:"w-3 h-3 text-white"})})]},X)),l.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:[l.jsx("input",{ref:C,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:Q,className:"hidden",disabled:A}),A?l.jsx(Et,{className:"w-6 h-6 text-bambu-gray animate-spin"}):l.jsx(pr,{className:"w-6 h-6 text-bambu-gray"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:Z.isPending,className:"flex-1",children:[l.jsx(Ro,{className:"w-4 h-4"}),Z.isPending?"Saving...":"Save"]})]})]})]})})}function _Ue({x:t,y:e,items:n,onClose:r}){const i=E.useRef(null),[a,s]=E.useState(null),o=E.useRef(null),[c,u]=E.useState({x:t,y:e,visible:!1}),[d,f]=E.useState(!1);E.useEffect(()=>{const b=x=>{i.current&&!i.current.contains(x.target)&&r()},y=x=>{x.key==="Escape"&&r()},v=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",y),document.addEventListener("scroll",v,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",y),document.removeEventListener("scroll",v,!0),o.current&&clearTimeout(o.current)}},[r]),E.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const b=i.current.getBoundingClientRect(),y=window.innerWidth,v=window.innerHeight,x=8;let M=t,S=e;t+b.width>y-x&&(M=Math.max(x,y-b.width-x)),M<x&&(M=x),e+b.height>v-x&&(S=Math.max(x,v-b.height-x)),S<x&&(S=x);const A=180,T=y-M-b.width,k=M;f(T<A&&k>A),u({x:M,y:S,visible:!0})}},[t,e]);const g=b=>{o.current&&(clearTimeout(o.current),o.current=null),s(b)},m=()=>{o.current=window.setTimeout(()=>{s(null)},150)};return l.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 l.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const v=b.submenu&&b.submenu.length>0;return l.jsxs("div",{className:"relative",onMouseEnter:()=>v&&g(y),onMouseLeave:()=>v&&m(),children:[l.jsxs("button",{onMouseEnter:()=>v&&g(y),onClick:()=>{v?s(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"} ${v&&a===y?"bg-bambu-dark-tertiary":""}`,children:[b.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),l.jsx("span",{className:"flex-1",children:b.label}),v&&l.jsx(uf,{className:"w-4 h-4 text-bambu-gray"})]}),v&&a===y&&l.jsx("div",{className:`absolute top-0 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"}`,onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null)},onMouseLeave:()=>m(),children:b.submenu.map((x,M)=>l.jsxs("button",{onClick:()=>{x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[x.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),x.label]},M))})]},y)})})}function wUe({selectedIds:t,existingTags:e,onClose:n}){const r=En(),{showToast:i}=ai(),[a,s]=E.useState(""),[o,c]=E.useState(new Set),[u,d]=E.useState("add");E.useEffect(()=>{const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=wt({mutationFn:async()=>{const y=Array.from(o);let v=0;for(const x of t)try{const M=await ke.getArchive(x),S=M.tags?M.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...S,...y])]:A=S.filter(T=>!o.has(T)),await ke.updateArchive(x,{tags:A.join(", ")}),v++}catch(M){throw console.error(`Failed to update archive ${x}:`,M),new Error(`Failed on archive ${x}: ${M instanceof Error?M.message:"Unknown error"}`)}return{count:v,mode:u,tags:y}},onSuccess:({count:y,mode:v,tags:x})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${v==="add"?"Added":"Removed"} ${x.length} tag${x.length!==1?"s":""} ${v==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),g=y=>{c(v=>{const x=new Set(v);return x.has(y)?x.delete(y):x.add(y),x})},m=()=>{a.trim()&&!o.has(a.trim())&&(c(y=>new Set([...y,a.trim()])),s(""))},b=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(E0,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),l.jsx(Le,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:y=>s(y.target.value),onKeyDown:b}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:m,disabled:!a.trim(),children:l.jsx(pr,{className:"w-4 h-4"})})]}),e.length>0&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>l.jsx("button",{onClick:()=>g(y),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),o.size>0&&l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(y=>l.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,l.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:l.jsx(Wt,{className:"w-3 h-3"})})]},y))})]})]}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?l.jsxs(l.Fragment,{children:[l.jsx(Et,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):l.jsxs(l.Fragment,{children:[l.jsx(E0,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function SUe(t,e){return new Date(t,e+1,0).getDate()}function MUe(t,e){return new Date(t,e,1).getDay()}const EUe=["January","February","March","April","May","June","July","August","September","October","November","December"],AUe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function TUe({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=E.useState(n.getMonth()),[a,s]=E.useState(n.getFullYear()),[o,c]=E.useState(null),u=E.useMemo(()=>{const x=new Map;return t.forEach(M=>{const S=new Date(M.completed_at||M.created_at),A=`${S.getFullYear()}-${String(S.getMonth()+1).padStart(2,"0")}-${String(S.getDate()).padStart(2,"0")}`,T=x.get(A)||[];T.push(M),x.set(A,T)}),x},[t]),d=SUe(a,r),f=MUe(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},m=()=>{r===11?(i(0),s(a+1)):i(r+1)},b=()=>{i(n.getMonth()),s(n.getFullYear())},y=[];for(let x=0;x<f;x++)y.push(null);for(let x=1;x<=d;x++)y.push(x);const v=o?u.get(o)||[]:[];return l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Bh,{className:"w-5 h-5 text-bambu-gray"})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:[EUe[r]," ",a]}),l.jsx("button",{onClick:b,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"})]}),l.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(uf,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:AUe.map(x=>l.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:x},x))}),l.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((x,M)=>{if(x===null)return l.jsx("div",{className:"aspect-square"},`empty-${M}`);const S=`${a}-${String(r+1).padStart(2,"0")}-${String(x).padStart(2,"0")}`,A=u.get(S)||[],T=A.length>0,k=x===n.getDate()&&r===n.getMonth()&&a===n.getFullYear(),N=S===o,I=A.filter(D=>D.status==="completed").length,C=A.filter(D=>D.status==="failed").length;return l.jsxs("button",{onClick:()=>c(N?null:S),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${N?"bg-bambu-green text-white":k?"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:[l.jsx("span",{className:`text-sm font-medium ${k&&!N?"text-bambu-green":""}`,children:x}),T&&l.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[l.jsx("div",{className:`w-2 h-2 rounded-full ${C>0&&I===0?"bg-red-400":C>0?"bg-yellow-400":"bg-green-400"}`}),l.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},x)})}),l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a&&x.status==="completed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a&&x.status==="failed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),l.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(o+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),v.length>0?l.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(x=>l.jsxs("button",{onClick:()=>e?.(x),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[x.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(x.id),alt:"",className:"w-12 h-12 rounded object-cover"}):l.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:l.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-white truncate",children:x.print_name||x.filename}),l.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[l.jsx("span",{className:x.status==="failed"?"text-red-400":"text-green-400",children:x.status==="failed"?"Failed":"Completed"}),x.filament_color&&l.jsx("div",{className:"flex gap-0.5",children:x.filament_color.split(",").map((M,S)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},S))})]})]})]},x.id))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):l.jsx("div",{className:"text-center py-8",children:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function CUe({archiveId:t,archiveName:e,onClose:n}){const r=ke.getArchiveQRCodeUrl(t,300);E.useEffect(()=>{const a=s=>{s.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 l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 flex flex-col items-center",children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),l.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:l.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),l.jsxs(Le,{onClick:i,className:"w-full",children:[l.jsx(Es,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function NUe({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,s]=E.useState(0),[o,c]=E.useState(!1);if(E.useEffect(()=>{const m=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&s(y=>Math.max(0,y-1)),b.key==="ArrowRight"&&s(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),E.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=ke.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${a+1}.jpg`,m.click()},g=()=>{i&&c(!0)};return l.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[l.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:f,children:[l.jsx(Es,{className:"w-4 h-4"}),"Download"]}),i&&l.jsx(Le,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})}),l.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-6 h-6"})})]})]}),l.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&l.jsx("button",{onClick:()=>s(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:l.jsx(Bh,{className:"w-8 h-8 text-white"})}),l.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&&l.jsx("button",{onClick:()=>s(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:l.jsx(uf,{className:"w-8 h-8 text-white"})})]}),n.length>1&&l.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,b)=>l.jsx("button",{onClick:()=>s(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:l.jsx("img",{src:ke.getArchivePhotoUrl(t,m),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&l.jsx(Qr,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Yi(t){this.content=t}Yi.prototype={constructor:Yi,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 Yi(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 Yi(n)},addToStart:function(t,e){return new Yi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Yi(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 Yi(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=Yi.from(t),t.size?new Yi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Yi.from(t),t.size?new Yi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Yi.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}};Yi.from=function(t){if(t instanceof Yi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Yi(e)};function oQ(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 s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=oQ(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function lQ(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 s=t.child(--i),o=e.child(--a),c=s.nodeSize;if(s==o){n-=c,r-=c;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let u=0,d=Math.min(s.text.length,o.text.length);for(;u<d&&s.text[s.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let u=lQ(s.content,o.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class pt{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 s=0,o=0;o<n;s++){let c=this.content[s],u=o+c.nodeSize;if(u>e&&r(c,i+o,a||null,s)!==!1&&c.content.size){let d=o+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,c)=>{let u=o.isText?o.text.slice(Math.max(e,c)-c,n-c):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!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 pt(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,s=0;s<n;a++){let o=this.content[a],c=s+o.nodeSize;c>e&&((s<e||c>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=c}return new pt(r,i)}cutByIndex(e,n){return e==n?pt.empty:e==0&&n==this.content.length?this:new pt(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 pt(i,a)}addToStart(e){return new pt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new pt(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 oQ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return lQ(this,e,n,r)}findIndex(e){if(e==0)return O_(0,e);if(e==this.size)return O_(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?O_(n+1,a):O_(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 pt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new pt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return pt.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 pt(n||e,r)}static from(e){if(!e)return pt.empty;if(e instanceof pt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new pt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}pt.empty=new pt([],0);const jN={index:0,offset:0};function O_(t,e){return jN.index=t,jN.offset=e,jN}function Bw(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(!Bw(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Bw(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let tr=class HP{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&&Bw(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 HP.none;if(e instanceof HP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};tr.none=[];class Hw extends Error{}class kt{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=uQ(this.content,e+this.openStart,n);return r&&new kt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new kt(cQ(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 kt.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 kt(pt.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 kt(e,r,i)}}kt.empty=new kt(pt.empty,0,0);function cQ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(cQ(a.content,e-i-1,n-i-1)))}function uQ(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=uQ(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function kUe(t,e,n){if(n.openStart>t.depth)throw new Hw("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Hw("Inconsistent open depths");return dQ(t,e,n,0)}function dQ(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=dQ(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Dh(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=PUe(n,t);return Dh(a,fQ(t,s,o,e,r))}else return Dh(a,$w(t,e,r))}function hQ(t,e){if(!e.type.compatibleContent(t.type))throw new Hw("Cannot join "+e.type.name+" onto "+t.type.name)}function $P(t,e,n){let r=t.node(n);return hQ(r,e.node(n)),r}function Rh(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 Jx(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Rh(t.nodeAfter,r),a++));for(let o=a;o<s;o++)Rh(i.child(o),r);e&&e.depth==n&&e.textOffset&&Rh(e.nodeBefore,r)}function Dh(t,e){return t.type.checkContent(e),t.copy(e)}function fQ(t,e,n,r,i){let a=t.depth>i&&$P(t,e,i+1),s=r.depth>i&&$P(n,r,i+1),o=[];return Jx(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(hQ(a,s),Rh(Dh(a,fQ(t,e,n,r,i+1)),o)):(a&&Rh(Dh(a,$w(t,e,i+1)),o),Jx(e,n,i,o),s&&Rh(Dh(s,$w(n,r,i+1)),o)),Jx(r,null,i,o),new pt(o)}function $w(t,e,n){let r=[];if(Jx(null,t,n,r),t.depth>n){let i=$P(t,e,n+1);Rh(Dh(i,$w(t,e,n+1)),r)}return Jx(e,null,n,r),new pt(r)}function PUe(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(pt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class J0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let 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 tr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].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 Vw(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 s=e;;){let{index:o,offset:c}=s.content.findIndex(a),u=a-c;if(r.push(s,o,i+c),!u||(s=s.child(o),s.isText))break;a=u-1,i+=c+1}return new J0(n,r,a)}static resolveCached(e,n){let r=DV.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else DV.set(e,r=new RUe);let i=r.elts[r.i]=J0.resolve(e,n);return r.i=(r.i+1)%DUe,i}}class RUe{constructor(){this.elts=[],this.i=0}}const DUe=12,DV=new WeakMap;class Vw{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 jUe=Object.create(null);let ed=class VP{constructor(e,n,r,i=tr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||pt.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&&Bw(this.attrs,n||e.defaultAttrs||jUe)&&tr.sameSet(this.marks,r||tr.none)}copy(e=null){return e==this.content?this:new VP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new VP(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 kt.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),u=i.node(s).content.cut(i.pos-o,a.pos-o);return new kt(u,i.depth-s,a.depth-s)}replace(e,n,r){return kUe(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return J0.resolveCached(this,e)}resolveNoCache(e){return J0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,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()+")"),pQ(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=pt.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.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),s=a&&a.matchFragment(this.content,n);return s?s.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=tr.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(!tr.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=pt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};ed.prototype.text=void 0;class Gw extends ed{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):pQ(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 Gw(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Gw(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 pQ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class af{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new OUe(e,n);if(r.next==null)return af.empty;let i=mQ(r);r.next&&r.err("Unexpected trailing text");let a=HUe(BUe(i));return $Ue(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(s,o){let c=s.matchFragment(e,r);if(c&&(!n||c.validEnd))return pt.from(o.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:d,next:f}=s.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=a(f,o.concat(d));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:c}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||c.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.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 s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
  8098. `)}}af.empty=new af(!0);class OUe{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 mQ(t){let e=[];do e.push(LUe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function LUe(t){let e=[];do e.push(IUe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function IUe(t){let e=zUe(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=FUe(t,e);else break;return e}function jV(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function FUe(t,e){let n=jV(t),r=n;return t.eat(",")&&(t.next!="}"?r=jV(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function UUe(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let s=n[a];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function zUe(t){if(t.eat("(")){let e=mQ(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=UUe(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 BUe(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,c){let u={term:c,to:o};return e[s].push(u),u}function i(s,o){s.forEach(c=>c.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((c,u)=>c.concat(a(u,o)),[]);if(s.type=="seq")for(let c=0;;c++){let u=a(s.exprs[c],o);if(c==s.exprs.length-1)return u;i(u,o=n())}else if(s.type=="star"){let c=n();return r(o,c),i(a(s.expr,c),c),[r(c)]}else if(s.type=="plus"){let c=n();return i(a(s.expr,o),c),i(a(s.expr,c),c),[r(c)]}else{if(s.type=="opt")return[r(o)].concat(a(s.expr,o));if(s.type=="range"){let c=o;for(let u=0;u<s.min;u++){let d=n();i(a(s.expr,c),d),c=d}if(s.max==-1)i(a(s.expr,c),c);else for(let u=s.min;u<s.max;u++){let d=n();r(c,d),i(a(s.expr,c),d),c=d}return[r(c)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function gQ(t,e){return e-t}function OV(t,e){let n=[];return r(e),n.sort(gQ);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:o,to:c}=a[s];!o&&n.indexOf(c)==-1&&r(c)}}}function HUe(t){let e=Object.create(null);return n(OV(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:o,to:c})=>{if(!o)return;let u;for(let d=0;d<i.length;d++)i[d][0]==o&&(u=i[d][1]);OV(t,c).forEach(d=>{u||i.push([o,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new af(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let o=i[s][1].sort(gQ);a.next.push({type:i[s][0],next:e[o.join(",")]||n(o)})}return a}}function $Ue(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let o=0;o<i.next.length;o++){let{type:c,next:u}=i.next[o];s.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function xQ(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 bQ(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 yQ(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 vQ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new GUe(t,r,e[r]);return n}let LV=class _Q{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=vQ(e,r.attrs),this.defaultAttrs=xQ(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==af.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:bQ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ed(this,this.computeAttrs(e),pt.from(n),tr.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new ed(this,this.computeAttrs(e),n,tr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=pt.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(pt.empty,!0);return a?new ed(this,e,n.append(a),tr.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){yQ(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:tr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new _Q(a,n,s));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 VUe(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 GUe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?VUe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class KM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=vQ(e,i.attrs),this.excluded=null;let a=xQ(this.attrs);this.instance=a?new tr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new tr(this,bQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new KM(a,i++,n,s)),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){yQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class wQ{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=Yi.from(e.nodes),n.marks=Yi.from(e.marks||{}),this.nodes=LV.compile(this.spec.nodes,this),this.marks=KM.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],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=af.parse(s,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=o=="_"?null:o?IV(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:IV(this,s.split(" "))}this.nodeFromJSON=i=>ed.fromJSON(this,i),this.markFromJSON=i=>tr.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 LV){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 Gw(r,r.defaultAttrs,e,tr.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 IV(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let o in t.marks){let c=t.marks[o];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function WUe(t){return t.tag!=null}function qUe(t){return t.style!=null}let e0=class GP{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(WUe(i))this.tags.push(i);else if(qUe(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 UV(this,n,!1);return r.addAll(e,tr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new UV(this,n,!0);return r.addAll(e,tr.none,n.from,n.to),kt.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(YUe(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||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 s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let c=s.getAttrs(n);if(c===!1)continue;s.attrs=c||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=zV(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(s=>{r(s=zV(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new GP(e,GP.schemaRules(e)))}};const SQ={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},KUe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},MQ={ol:!0,ul:!0},eb=1,WP=2,t0=4;function FV(t,e,n){return e!=null?(e?eb:0)|(e==="full"?WP:0):t&&t.whitespace=="pre"?eb|WP:n&~t0}class L_{constructor(e,n,r,i,a,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=tr.none,this.match=a||(s&t0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(pt.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&eb)){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=pt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(pt.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&&!SQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class UV{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,s=FV(null,n.preserveWhitespace,0)|(r?t0:0);i?a=new L_(i.type,i.attrs,tr.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new L_(null,null,tr.none,!0,null,s):a=new L_(e.schema.topNodeType,null,tr.none,!0,null,s),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&WP?"full":this.localPreserveWS||(i.options&eb)>0,{schema:s}=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,`
  8099. `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(s.text(o[c]),n,!/\S/.test(o[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 o=i.content[i.content.length-1],c=e.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.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 s=e.nodeName.toLowerCase(),o;MQ.hasOwnProperty(s)&&this.parser.normalizeLists&&XUe(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(c?c.ignore:KUe.hasOwnProperty(s))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(SQ.hasOwnProperty(s))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?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
  8100. `),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],s=r.getPropertyValue(a);if(s)for(let o=void 0;;){let c=this.parser.matchStyle(a,s,this,o);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)o=c;else break}}return n}addElementByRule(e,n,r,i){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(s,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 o=this.top;if(s&&s.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(o)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,o=0;s>=0;s--){let c=this.nodes[s],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;o+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],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 s=tr.none;for(let o of i.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):BV(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!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 s=this.top;s.match=s.match&&s.match.matchType(e);let o=FV(e,a,s.options);s.options&t0&&s.content.length==0&&(o|=t0);let c=tr.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):BV(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new L_(e,n,c,i,null,o)),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|=eb)}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),s=(o,c)=>{for(;o>=0;o--){let u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;c>=a;c--)if(s(o-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 s(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 XUe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&MQ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function YUe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function zV(t){let e={};for(let n in t)e[n]=t[n];return e}function BV(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let c=0;c<o.edgeCount;c++){let{type:u,next:d}=o.edge(c);if(u==e||a.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class gf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=ON(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,c=0;for(;o<a.length&&c<s.marks.length;){let u=s.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[o][0])||u.type.spec.spanning===!1)break;o++,c++}for(;o<a.length;)i=a.pop()[1];for(;c<s.marks.length;){let u=s.marks[c++],d=this.serializeMark(u,s.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=m1(ON(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&&m1(ON(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return m1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new gf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=HV(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return HV(e.marks)}}function HV(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function ON(t){return t.document||window.document}const $V=new WeakMap;function ZUe(t){let e=$V.get(t);return e===void 0&&$V.set(t,e=QUe(t)),e}function QUe(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 m1(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=ZUe(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 s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:b}=m1(t,g,n,r);if(c.appendChild(m),b){if(o)throw new RangeError("Multiple content holes");o=b}}}return{dom:c,contentDOM:o}}const EQ=65535,AQ=Math.pow(2,16);function JUe(t,e){return t+e*AQ}function VV(t){return t&EQ}function eze(t){return(t-(t&EQ))/AQ}const TQ=1,CQ=2,g1=4,NQ=8;class qP{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&NQ)>0}get deletedBefore(){return(this.delInfo&(TQ|g1))>0}get deletedAfter(){return(this.delInfo&(CQ|g1))>0}get deletedAcross(){return(this.delInfo&g1)>0}}class bs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&bs.empty)return bs.empty}recover(e){let n=0,r=VV(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+eze(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,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[o+a],d=this.ranges[o+s],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,m=c+i+(g<0?0:d);if(r)return m;let b=e==(n<0?c:f)?null:JUe(o/3,e-c),y=e==c?CQ:e==f?TQ:g1;return(n<0?e!=c:e!=f)&&(y|=NQ),new qP(m,y,b)}i+=d-u}return r?e+i:new qP(e+i,0,null)}touches(e,n){let r=0,i=VV(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[o+a],d=c+u;if(e<=d&&o==i*3)return!0;r+=this.ranges[o+s]-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 s=this.ranges[i],o=s-(this.inverted?a:0),c=s+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(o,o+u,c,c+d),a+=d-u}}invert(){return new bs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?bs.empty:new bs(e<0?[0,-e,0]:[0,0,e])}}bs.empty=new bs([]);class tb{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 tb(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 tb;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 s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new qP(e,i,null)}}const LN=Object.create(null);class xa{getMap(){return bs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=LN[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 LN)throw new RangeError("Duplicate use of step JSON ID "+e);return LN[e]=n,n.prototype.jsonID=e,n}}class ei{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ei(e,null)}static fail(e){return new ei(null,e)}static fromReplace(e,n,r,i){try{return ei.ok(e.replace(n,r,i))}catch(a){if(a instanceof Hw)return ei.fail(a.message);throw a}}}function EO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(EO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return pt.fromArray(r)}class Vu extends xa{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 kt(EO(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return ei.fromReplace(e,this.from,this.to,a)}invert(){return new Oo(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 Vu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Vu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Vu(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 Vu(n.from,n.to,e.markFromJSON(n.mark))}}xa.jsonID("addMark",Vu);class Oo extends xa{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 kt(EO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ei.fromReplace(e,this.from,this.to,r)}invert(){return new Vu(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 Oo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Oo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oo(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 Oo(n.from,n.to,e.markFromJSON(n.mark))}}xa.jsonID("removeMark",Oo);class Gu extends xa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ei.fromReplace(e,this.pos,this.pos+1,new kt(pt.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 Gu(this.pos,n.marks[i]);return new Gu(this.pos,this.mark)}}return new sf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Gu(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 Gu(n.pos,e.markFromJSON(n.mark))}}xa.jsonID("addNodeMark",Gu);class sf extends xa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ei.fromReplace(e,this.pos,this.pos+1,new kt(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Gu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new sf(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 sf(n.pos,e.markFromJSON(n.mark))}}xa.jsonID("removeNodeMark",sf);class Oi extends xa{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&KP(e,this.from,this.to)?ei.fail("Structure replace would overwrite content"):ei.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new bs([this.from,this.to-this.from,this.slice.size])}invert(e){return new Oi(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 Oi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Oi)||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?kt.empty:new kt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Oi(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?kt.empty:new kt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Oi(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 Oi(n.from,n.to,kt.fromJSON(e,n.slice),!!n.structure)}}xa.jsonID("replace",Oi);class Ii extends xa{constructor(e,n,r,i,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(KP(e,this.from,this.gapFrom)||KP(e,this.gapTo,this.to)))return ei.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ei.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ei.fromReplace(e,this.from,this.to,r):ei.fail("Content does not fit in gap")}getMap(){return new bs([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 Ii(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 Ii(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 Ii(n.from,n.to,n.gapFrom,n.gapTo,kt.fromJSON(e,n.slice),n.insert,!!n.structure)}}xa.jsonID("replaceAround",Ii);function KP(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 s=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function tze(t,e,n,r){let i=[],a=[],s,o;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),m=Math.min(u+c.nodeSize,n),b=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(b)||(s&&s.to==g&&s.mark.eq(f[y])?s.to=m:i.push(s=new Oo(g,m,f[y])));o&&o.to==g?o.to=m:a.push(o=new Vu(g,m,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function nze(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let c=null;if(r instanceof KM){let u=s.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(s.marks)&&(c=[r]):c=s.marks;if(c&&c.length){let u=Math.min(o+s.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],g;for(let m=0;m<i.length;m++){let b=i[m];b.step==a-1&&f.eq(i[m].style)&&(g=b)}g?(g.to=u,g.step=a):i.push({style:f,from:Math.max(o,e),to:u,step:a})}}}),i.forEach(s=>t.step(new Oo(s.from,s.to,s.style)))}function AO(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=o+u.nodeSize,f=r.matchType(u.type);if(!f)s.push(new Oi(o,d,kt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Oo(o,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,b;for(;g=m.exec(u.text);)b||(b=new kt(pt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new Oi(o+g.index,o+g.index+g[0].length,b))}}o=d}if(!r.validEnd){let c=r.fillBefore(pt.empty,!0);t.replace(o,o,new kt(c,0,0))}for(let c=s.length-1;c>=0;c--)t.step(s[c])}function rze(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function dg(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(o,c,n))return r;if(r==0||s.type.spec.isolating||!rze(s,o,c))break;o&&(i=1),c<s.childCount&&(a=1)}return null}function ize(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),o=i.after(a+1),c=s,u=o,d=pt.empty,f=0;for(let b=a,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,d=pt.from(r.node(b).copy(d)),f++):c--;let g=pt.empty,m=0;for(let b=a,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!0,g=pt.from(i.node(b).copy(g)),m++):u++;t.step(new Ii(c,u,s,o,new kt(d.append(g),f,m),d.size-f,!0))}function TO(t,e,n=null,r=t){let i=aze(t,e),a=i&&sze(r,e);return a?i.map(GV).concat({type:e,attrs:n}).concat(a.map(GV)):null}function GV(t){return{type:t,attrs:null}}function aze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(r,i,s)?a:null}function sze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let c=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:s}function oze(t,e,n){let r=pt.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=pt.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Ii(i,a,i,a,new kt(r,0,0),n.length,!0))}function lze(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,(s,o)=>{let c=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,c)&&cze(t.doc,t.mapping.slice(a).map(o),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!b?u=!1:!m&&b&&(u=!0)}u===!1&&PQ(t,s,o,a),AO(t,t.mapping.slice(a).map(o,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(o,1),g=d.map(o+s.nodeSize,1);return t.step(new Ii(f,g,f+1,g-1,new kt(pt.from(r.create(c,null,s.marks)),0,0),1,!0)),u===!0&&kQ(t,s,o,a),!1}})}function kQ(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function PQ(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
  8101. `))}})}function cze(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function uze(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 s=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,s);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ii(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new kt(pt.from(s),0,0),1,!0))}function Ec(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,s=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(g,f.childCount),b=r&&r[d+1];b&&(m=m.replaceChild(0,b.type.create(b.attrs)));let y=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!y.type.validContent(m))return!1}let o=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(o,o,c?c.type:i.node(a+1).type)}function dze(t,e,n=1,r){let i=t.doc.resolve(e),a=pt.empty,s=pt.empty;for(let o=i.depth,c=i.depth-n,u=n-1;o>c;o--,u--){a=pt.from(i.node(o).copy(a));let d=r&&r[u];s=pt.from(d?d.type.create(d.attrs,s):i.node(o).copy(s))}t.step(new Oi(e,e,new kt(a.append(s),n,n),!0))}function Md(t,e){let n=t.resolve(e),r=n.index();return RQ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function hze(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),s=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function RQ(t,e){return!!(t&&e&&!t.isLeaf&&hze(t,e))}function XM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,s,o=r.index(i);if(i==r.depth?(a=r.nodeBefore,s=r.nodeAfter):n>0?(a=r.node(i+1),o++,s=r.node(i).maybeChild(o)):(a=r.node(i).maybeChild(o-1),s=r.node(i+1)),a&&!a.isTextblock&&RQ(a,s)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function fze(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),s=a.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);PQ(t,d.node(),d.before(),o)}s.inlineContent&&AO(t,e+n-1,s,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(o),u=c.map(e-n);if(t.step(new Oi(u,c.map(e+n,-1),kt.empty,!0)),r===!0){let d=t.doc.resolve(u);kQ(t,d.node(),d.before(),t.steps.length)}return t}function pze(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 DQ(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 s=r.depth;s>=0;s--){let o=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(o>0?1:0),u=r.node(s),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 o==0?r.pos:o<0?r.before(s+1):r.after(s+1)}return null}function YM(t,e,n=e,r=kt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return jQ(i,a,r)?new Oi(e,n,r):new mze(i,a,r).fit()}function jQ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class mze{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=pt.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=pt.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,s=r.depth,o=i.depth;for(;s&&o&&a.childCount==1;)a=a.firstChild.content,s--,o--;let c=new kt(a,s,o);return e>-1?new Ii(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Oi(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=IN(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let s=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:c,match:u}=this.frontier[o],d,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(pt.from(s),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:o,parent:a,inject:f};if(n==2&&s&&(d=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:o,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=IN(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new kt(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=IN(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new kt(zx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new kt(zx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let y=0;y<a.length;y++)this.openFrontierNode(a[y]);let s=this.unplaced,o=r?r.content:s.content,c=s.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let m=o.size+e-(s.content.size-s.openEnd);for(;u<o.childCount;){let y=o.child(u),v=f.matchType(y.type);if(!v)break;u++,(u>1||c==0||y.content.size)&&(f=v,d.push(OQ(y.mark(g.allowedMarks(y.marks)),u==1?c:0,u==o.childCount?m:-1)))}let b=u==o.childCount;b||(m=-1),this.placed=Bx(this.placed,n,pt.from(d)),this.frontier[n].match=f,b&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,v=o;y<m;y++){let x=v.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),v=x.content}this.unplaced=b?e==0?kt.empty:new kt(zx(s.content,e-1,1),e-1,m<0?s.openEnd:e-1):new kt(zx(s.content,e,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!FN(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)),s=FN(e,n,i,r,a);if(s){for(let o=n-1;o>=0;o--){let{match:c,type:u}=this.frontier[o],d=FN(e,o,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,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=Bx(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=Bx(this.placed,this.depth,pt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(pt.empty,!0);n.childCount&&(this.placed=Bx(this.placed,this.frontier.length,n))}}function zx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(zx(t.firstChild.content,e-1,n)))}function Bx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Bx(t.lastChild.content,e-1,n)))}function IN(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function OQ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,OQ(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(pt.empty,!0)))),t.copy(r)}function FN(t,e,n,r,i){let a=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==a.childCount&&!n.compatibleContent(a.type))return null;let o=r.fillBefore(a.content,!0,s);return o&&!gze(n,a.content,s)?o:null}function gze(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function xze(t){return t.spec.defining||t.spec.definingForContent}function bze(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(jQ(i,a,r))return t.step(new Oi(e,n,r));let s=IQ(i,a);s[s.length-1]==0&&s.pop();let o=-(i.depth+1);s.unshift(o);for(let g=i.depth,m=i.pos-1;g>0;g--,m--){let b=i.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;s.indexOf(g)>-1?o=g:i.before(g)==m&&s.splice(1,0,-g)}let c=s.indexOf(o),u=[],d=r.openStart;for(let g=r.content,m=0;;m++){let b=g.firstChild;if(u.push(b),m==r.openStart)break;g=b.content}for(let g=d-1;g>=0;g--){let m=u[g],b=xze(m.type);if(b&&!m.sameMarkup(i.node(Math.abs(o)-1)))d=g;else if(b||!m.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let m=(g+d+1)%(r.openStart+1),b=u[m];if(b)for(let y=0;y<s.length;y++){let v=s[(y+c)%s.length],x=!0;v<0&&(x=!1,v=-v);let M=i.node(v-1),S=i.index(v-1);if(M.canReplaceWith(S,S,b.type,b.marks))return t.replace(i.before(v),x?a.after(v):n,new kt(LQ(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let g=s.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let m=s[g];m<0||(e=i.before(m),n=a.after(m))}}function LQ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(LQ(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),s=a.fillBefore(t).append(t);t=s.append(a.matchFragment(s).fillBefore(pt.empty,!0))}return t}function yze(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=pze(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new kt(pt.from(r),0,0))}function vze(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=IQ(r,i);for(let s=0;s<a.length;s++){let o=a[s],c=s==a.length-1;if(c&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(c||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function IQ(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 lm extends xa{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 ei.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 ei.fromReplace(e,this.pos,this.pos+1,new kt(pt.from(i),0,n.isLeaf?0:1))}getMap(){return bs.empty}invert(e){return new lm(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 lm(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 lm(n.pos,n.attr,n.value)}}xa.jsonID("attr",lm);class nb extends xa{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 ei.ok(r)}getMap(){return bs.empty}invert(e){return new nb(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 nb(n.attr,n.value)}}xa.jsonID("docAttr",nb);let Om=class extends Error{};Om=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Om.prototype=Object.create(Error.prototype);Om.prototype.constructor=Om;Om.prototype.name="TransformError";class FQ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Om(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=kt.empty){let i=YM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new kt(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,kt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return bze(this,e,n,r),this}replaceRangeWith(e,n,r){return yze(this,e,n,r),this}deleteRange(e,n){return vze(this,e,n),this}lift(e,n){return ize(this,e,n),this}join(e,n=1){return fze(this,e,n),this}wrap(e,n){return oze(this,e,n),this}setBlockType(e,n=e,r,i=null){return lze(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return uze(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new lm(e,n,r)),this}setDocAttribute(e,n){return this.step(new nb(e,n)),this}addNodeMark(e,n){return this.step(new Gu(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 tr)n.isInSet(r.marks)&&this.step(new sf(e,n));else{let i=r.marks,a,s=[];for(;a=n.isInSet(i);)s.push(new sf(e,a)),i=a.removeFromSet(i);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,r){return dze(this,e,n,r),this}addMark(e,n,r){return tze(this,e,n,r),this}removeMark(e,n,r){return nze(this,e,n,r),this}clearIncompatible(e,n,r){return AO(this,e,n,r),this}}const UN=Object.create(null);class un{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new _ze(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=kt.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let a=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:c,$to:u}=s[o],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),o?kt.empty:n),o==0&&KV(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:s,$to:o}=i[a],c=e.mapping.slice(r),u=c.map(s.pos),d=c.map(o.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),KV(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Kt(e):Up(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 s=n<0?Up(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Up(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ms(e.node(0))}static atStart(e){return Up(e,e,0,0,1)||new Ms(e)}static atEnd(e){return Up(e,e,e.content.size,e.childCount,-1)||new Ms(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=UN[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 UN)throw new RangeError("Duplicate use of selection JSON ID "+e);return UN[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Kt.between(this.$anchor,this.$head).getBookmark()}}un.prototype.visible=!0;class _ze{constructor(e,n){this.$from=e,this.$to=n}}let WV=!1;function qV(t){!WV&&!t.parent.inlineContent&&(WV=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Kt extends un{constructor(e,n=e){qV(e),qV(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 un.near(r);let i=e.resolve(n.map(this.anchor));return new Kt(i.parent.inlineContent?i:r,r)}replace(e,n=kt.empty){if(super.replace(e,n),n==kt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Kt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ZM(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 Kt(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=un.findFrom(n,r,!0)||un.findFrom(n,-r,!0);if(a)n=a.$head;else return un.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(un.findFrom(e,-r,!0)||un.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Kt(e,n)}}un.jsonID("text",Kt);class ZM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ZM(e.map(this.anchor),e.map(this.head))}resolve(e){return Kt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends un{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?un.near(a):new Ht(a)}content(){return new kt(pt.from(this.node),0,0)}eq(e){return e instanceof Ht&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new CO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ht(e.resolve(n.anchor))}static create(e,n){return new Ht(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ht.prototype.visible=!1;un.jsonID("node",Ht);class CO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ZM(r,r):new CO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ht.isSelectable(r)?new Ht(n):un.near(n)}}class Ms extends un{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=kt.empty){if(n==kt.empty){e.delete(0,e.doc.content.size);let r=un.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ms(e)}map(e){return new Ms(e)}eq(e){return e instanceof Ms}getBookmark(){return wze}}un.jsonID("all",Ms);const wze={map(){return this},resolve(t){return new Ms(t)}};function Up(t,e,n,r,i,a=!1){if(e.inlineContent)return Kt.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let o=e.child(s);if(o.isAtom){if(!a&&Ht.isSelectable(o))return Ht.create(t,n-(i<0?o.nodeSize:0))}else{let c=Up(t,o,n+i,i<0?o.childCount:0,i,a);if(c)return c}n+=o.nodeSize*i}return null}function KV(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Oi||i instanceof Ii))return;let a=t.mapping.maps[r],s;a.forEach((o,c,u,d)=>{s==null&&(s=d)}),t.setSelection(un.near(t.doc.resolve(s),n))}const XV=1,I_=2,YV=4;class Sze extends FQ{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|XV)&~I_,this.storedMarks=null,this}get selectionSet(){return(this.updated&XV)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=I_,this}ensureMarks(e){return tr.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&I_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~I_,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)||tr.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 s=this.doc.resolve(n);a=r==n?s.marks():s.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(un.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|=YV,this}get scrolledIntoView(){return(this.updated&YV)>0}}function ZV(t,e){return!e||!t?t:t.bind(e)}class Hx{constructor(e,n,r){this.name=e,this.init=ZV(n.init,r),this.apply=ZV(n.apply,r)}}const Mze=[new Hx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Hx("selection",{init(t,e){return t.selection||un.atStart(e.doc)},apply(t){return t.selection}}),new Hx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Hx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class zN{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Mze.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 Hx(r.key,r.spec.state,r))})}}class Xp{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 s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let c=i?i[s].n:0,u=i?i[s].state:this,d=c<n.length&&o.spec.appendTransaction.call(o,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[s]={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 Xp(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 Sze(this)}static create(e){let n=new zN(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Xp(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 zN(this.schema,e.plugins),r=n.fields,i=new Xp(n);for(let a=0;a<r.length;a++){let s=r[a].name;i[s]=this.hasOwnProperty(s)?this[s]: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 zN(e.schema,e.plugins),a=new Xp(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=ed.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=un.fromJSON(a.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let c=r[o],u=c.spec.state;if(c.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){a[s.name]=u.fromJSON.call(c,e,n[o],a);return}}a[s.name]=s.init(e,a)}}),a}}function UQ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=UQ(i,e,{})),n[r]=i}return n}class Er{constructor(e){this.spec=e,this.props={},e.props&&UQ(e.props,this,this.props),this.key=e.key?e.key.key:zQ("plugin")}getState(e){return e[this.key]}}const BN=Object.create(null);function zQ(t){return t in BN?t+"$"+ ++BN[t]:(BN[t]=0,t+"$")}class Si{constructor(e="key"){this.key=zQ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const NO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function BQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const HQ=(t,e,n)=>{let r=BQ(t,n);if(!r)return!1;let i=kO(r);if(!i){let s=r.blockRange(),o=s&&dg(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let a=i.nodeBefore;if(ZQ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Lm(a,"end")||Ht.isSelectable(a)))for(let s=r.depth;;s--){let o=YM(t.doc,r.before(s),r.after(s),kt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(Lm(a,"end")?un.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Ht.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(s==1||r.node(s-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},Eze=(t,e,n)=>{let r=BQ(t,n);if(!r)return!1;let i=kO(r);return i?$Q(t,i,e):!1},Aze=(t,e,n)=>{let r=GQ(t,n);if(!r)return!1;let i=PO(r);return i?$Q(t,i,e):!1};function $Q(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 s=e.nodeAfter,o=s,c=e.pos+1;for(;!o.isTextblock;c++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let u=YM(t.doc,a,c,kt.empty);if(!u||u.from!=a||u instanceof Oi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(Kt.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Lm(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 VQ=(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=kO(r)}let s=a&&a.nodeBefore;return!s||!Ht.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function kO(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 GQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const WQ=(t,e,n)=>{let r=GQ(t,n);if(!r)return!1;let i=PO(r);if(!i)return!1;let a=i.nodeAfter;if(ZQ(t,i,e,1))return!0;if(r.parent.content.size==0&&(Lm(a,"start")||Ht.isSelectable(a))){let s=YM(t.doc,r.before(),r.after(),kt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(Lm(a,"start")?un.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ht.create(o.doc,o.mapping.map(i.pos))),e(o.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},qQ=(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=PO(r)}let s=a&&a.nodeAfter;return!s||!Ht.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,a.pos)).scrollIntoView()),!0)};function PO(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 Tze=(t,e)=>{let n=t.selection,r=n instanceof Ht,i;if(r){if(n.node.isTextblock||!Md(t.doc,n.from))return!1;i=n.from}else if(i=XM(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Ht.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},Cze=(t,e)=>{let n=t.selection,r;if(n instanceof Ht){if(n.node.isTextblock||!Md(t.doc,n.to))return!1;r=n.to}else if(r=XM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Nze=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&dg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},KQ=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8102. `).scrollIntoView()),!0)};function RO(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 kze=(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),s=RO(i.contentMatchAt(a));if(!s||!i.canReplaceWith(a,a,s))return!1;if(e){let o=n.after(),c=t.tr.replaceWith(o,o,s.createAndFill());c.setSelection(un.near(c.doc.resolve(o),1)),e(c.scrollIntoView())}return!0},XQ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ms||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=RO(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(s,a.createAndFill());o.setSelection(Kt.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},YQ=(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(Ec(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&dg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Pze(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ht&&e.selection.node.isBlock)return!r.parentOffset||!Ec(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],s,o,c=!1,u=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){c=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),o=RO(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),a.unshift(c&&o?{type:o}:null),s=m;break}else{if(m==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof Kt||e.selection instanceof Ms)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Ec(d.doc,f,a.length,a);if(g||(a[0]=o?{type:o}:null,g=Ec(d.doc,f,a.length,a)),!g)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(s).type!=o){let m=d.mapping.map(r.before(s)),b=d.doc.resolve(m);o&&r.node(s-1).canReplaceWith(b.index(),b.index()+1,o)&&d.setNodeMarkup(d.mapping.map(r.before(s)),o)}return n&&n(d.scrollIntoView()),!0}}const Rze=Pze(),Dze=(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(Ht.create(t.doc,i))),!0)};function jze(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||Md(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ZQ(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,o,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&jze(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(s=(o=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&o.matchType(s[0]||a.type).validEnd){if(n){let m=e.pos+a.nodeSize,b=pt.empty;for(let x=s.length-1;x>=0;x--)b=pt.from(s[x].create(null,b));b=pt.from(i.copy(b));let y=t.tr.step(new Ii(e.pos-1,m,e.pos,m,new kt(b,1,0),s.length,!0)),v=y.doc.resolve(m+2*s.length);v.nodeAfter&&v.nodeAfter.type==i.type&&Md(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:un.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&dg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&Lm(a,"start",!0)&&Lm(i,"end")){let m=i,b=[];for(;b.push(m),!m.isTextblock;)m=m.lastChild;let y=a,v=1;for(;!y.isTextblock;y=y.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let x=pt.empty;for(let S=b.length-1;S>=0;S--)x=pt.from(b[S].copy(x));let M=t.tr.step(new Ii(e.pos-b.length,e.pos+a.nodeSize,e.pos+v,e.pos+a.nodeSize-v,new kt(x,b.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function QQ(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(Kt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const Oze=QQ(-1),Lze=QQ(1);function Ize(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),o=s&&TO(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function QV(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[a];n.doc.nodesBetween(s,o,(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 s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[s];a.setBlockType(o,c,t,e)}r(a.scrollIntoView())}return!0}}function DO(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}DO(NO,HQ,VQ);DO(NO,WQ,qQ);DO(KQ,XQ,YQ,Rze);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Fze(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a);if(!s)return!1;let o=r?n.tr:null;return Uze(o,s,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function Uze(t,e,n,r=null){let i=!1,a=e,s=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=s.resolve(e.start-2);a=new Vw(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new Vw(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=TO(a,n,r,e);return o?(t&&zze(t,e,o,i,n),!0):!1}function zze(t,e,n,r,i){let a=pt.empty;for(let d=n.length-1;d>=0;d--)a=pt.from(n[d].type.create(n[d].attrs,a));t.step(new Ii(e.start-(r?2:0),e.end,e.start,e.end,new kt(a,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==i&&(s=d+1);let o=n.length-s,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&Ec(t.doc,c,o)&&(t.split(c,o),c+=2*o),c+=u.child(d).nodeSize;return t}function Bze(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?Hze(e,n,t,a):$ze(e,n,a):!0:!1}}function Hze(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new Ii(a-1,s,a,s,new kt(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Vw(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const o=dg(r);if(o==null)return!1;i.lift(r,o);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return Md(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function $ze(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,b=n.endIndex-1,y=n.startIndex;b>y;b--)m-=i.child(b).nodeSize,r.delete(m-1,m+1);let a=r.doc.resolve(n.start),s=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(o?0:1),d+1,s.content.append(c?pt.empty:pt.from(i))))return!1;let f=a.pos,g=f+s.nodeSize;return r.step(new Ii(f-(o?1:0),g+(c?1:0),f+1,g-1,new kt((o?pt.empty:pt.from(i.copy(pt.empty))).append(c?pt.empty:pt.from(i.copy(pt.empty))),o?0:1,c?0:1),o?0:1)),e(r.scrollIntoView()),!0}function Vze(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 s=a.startIndex;if(s==0)return!1;let o=a.parent,c=o.child(s-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==o.type,d=pt.from(u?t.create():null),f=new kt(pt.from(t.create(null,pt.from(o.type.create(null,d)))),u?3:1,0),g=a.start,m=a.end;n(e.tr.step(new Ii(g-(u?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}const ea=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Im=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let XP=null;const oc=function(t,e,n){let r=XP||(XP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Gze=function(){XP=null},of=function(t,e,n,r){return n&&(JV(t,e,n,r,-1)||JV(t,e,n,r,1))},Wze=/^(img|br|input|textarea|hr)$/i;function JV(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:eo(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Yb(t)||Wze.test(t.nodeName)||t.contentEditable=="false")return!1;e=ea(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((a=s.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?eo(t):0}else return!1}}function eo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function qze(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=eo(t)}else if(t.parentNode&&!Yb(t))e=ea(t),t=t.parentNode;else return null}}function Kze(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&&!Yb(t))e=ea(t)+1,t=t.parentNode;else return null}}function Xze(t,e,n){for(let r=e==0,i=e==eo(t);r||i;){if(t==n)return!0;let a=ea(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==eo(t)}}function Yb(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 QM=function(t){return t.focusNode&&of(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function hh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Yze(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Zze(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(eo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(eo(r.startContainer),r.startOffset)}}}const bl=typeof navigator<"u"?navigator:null,e7=typeof document<"u"?document:null,Ed=bl&&bl.userAgent||"",YP=/Edge\/(\d+)/.exec(Ed),JQ=/MSIE \d/.exec(Ed),ZP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ed),Ya=!!(JQ||ZP||YP),td=JQ?document.documentMode:ZP?+ZP[1]:YP?+YP[1]:0,so=!Ya&&/gecko\/(\d+)/i.test(Ed);so&&+(/Firefox\/(\d+)/.exec(Ed)||[0,0])[1];const QP=!Ya&&/Chrome\/(\d+)/.exec(Ed),fa=!!QP,eJ=QP?+QP[1]:0,ka=!Ya&&!!bl&&/Apple Computer/.test(bl.vendor),Fm=ka&&(/Mobile\/\w+/.test(Ed)||!!bl&&bl.maxTouchPoints>2),Ks=Fm||(bl?/Mac/.test(bl.platform):!1),Qze=bl?/Win/.test(bl.platform):!1,bc=/Android \d/.test(Ed),Zb=!!e7&&"webkitFontSmoothing"in e7.documentElement.style,Jze=Zb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function eBe(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 tc(t,e){return typeof t=="number"?t:t[e]}function tBe(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 t7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Im(s);continue}let o=s,c=o==a.body,u=c?eBe(a):tBe(o),d=0,f=0;if(e.top<u.top+tc(r,"top")?f=-(u.top-e.top+tc(i,"top")):e.bottom>u.bottom-tc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+tc(i,"top")-u.top:e.bottom-u.bottom+tc(i,"bottom")),e.left<u.left+tc(r,"left")?d=-(u.left-e.left+tc(i,"left")):e.right>u.right-tc(r,"right")&&(d=e.right-u.right+tc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let m=o.scrollLeft,b=o.scrollTop;f&&(o.scrollTop+=f),d&&(o.scrollLeft+=d);let y=o.scrollLeft-m,v=o.scrollTop-b;e={left:e.left-y,top:e.top-v,right:e.right-y,bottom:e.bottom-v}}let g=c?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:Im(s)}}function nBe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(a,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let c=o.getBoundingClientRect();if(c.top>=n-20){r=o,i=c.top;break}}return{refDOM:r,refTop:i,stack:tJ(t.dom)}}function tJ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Im(r));return e}function rBe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;nJ(n,r==0?0:r-e)}function nJ(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 Dp=null;function iBe(t){if(t.setActive)return t.setActive();if(Dp)return t.focus(Dp);let e=tJ(t);t.focus(Dp==null?{get preventScroll(){return Dp={preventScroll:!0},!0}}:void 0),Dp||(Dp=!1,nJ(e,0))}function rJ(t,e){let n,r=2e8,i,a=0,s=e.top,o=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=oc(d).getClientRects();else continue;for(let m=0;m<g.length;m++){let b=g[m];if(b.top<=s&&b.bottom>=o){s=Math.max(b.bottom,s),o=Math.min(b.top,o);let y=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&y&&(a=f+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!c&&b.left<=e.left&&b.right>=e.left&&(c=d,u={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?aBe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:rJ(n,i)}function aBe(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=Tu(r,1);if(a.top!=a.bottom&&jO(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function jO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function sBe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function oBe(t,e,n){let{node:r,offset:i}=rJ(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function lBe(t,e,n,r){let i=-1;for(let a=e,s=!1;a!=t.dom;){let o=t.docView.nearestDesc(a,!0),c;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((c=o.dom.getBoundingClientRect()).width||c.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&c.left>r.left||c.top>r.top?i=o.posBefore:(!s&&c.right<r.left||c.bottom<r.top)&&(i=o.posAfter),s=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?o.posBefore:o.posAfter;a=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function iJ(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 s=t.childNodes[a];if(s.nodeType==1){let o=s.getClientRects();for(let c=0;c<o.length;c++){let u=o[c];if(jO(e,u))return iJ(s,e,u)}}if((a=(a+1)%r)==i)break}return t}function cBe(t,e){let n=t.dom.ownerDocument,r,i=0,a=Zze(n,e.left,e.top);a&&({node:r,offset:i}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let u=t.dom.getBoundingClientRect();if(!jO(e,u)||(s=iJ(t.dom,e,u),!s))return null}if(ka)for(let u=s;r&&u;u=Im(u))u.draggable&&(r=void 0);if(s=sBe(s,e),r){if(so&&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;Zb&&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?o=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(o=lBe(t,r,i,e))}o==null&&(o=oBe(t,s,e));let c=t.docView.nearestDesc(s,!0);return{pos:o,inside:c?c.posAtStart-c.border:-1}}function n7(t){return t.top<t.bottom||t.left<t.right}function Tu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(n7(r))return r}return Array.prototype.find.call(n,n7)||t.getBoundingClientRect()}const uBe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function aJ(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=Zb||so;if(r.nodeType==3)if(s&&(uBe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Tu(oc(r,i,i),n);if(so&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Tu(oc(r,i-1,i-1),-1);if(u.top==c.top){let d=Tu(oc(r,i,i+1),-1);if(d.top!=c.top)return Nx(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++,Nx(Tu(oc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==eo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return HN(c.getBoundingClientRect(),!1)}if(a==null&&i<eo(r)){let c=r.childNodes[i];if(c.nodeType==1)return HN(c.getBoundingClientRect(),!0)}return HN(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==eo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?oc(c,eo(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Nx(Tu(u,1),!1)}if(a==null&&i<eo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?oc(c,0,s?0:1):c.nodeType==1?c:null:null;if(u)return Nx(Tu(u,-1),!0)}return Nx(Tu(r.nodeType==3?oc(r):r,-n),n>=0)}function Nx(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 HN(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 sJ(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 dBe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return sJ(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(a,!0);if(!o)break;if(o.node.isBlock){a=o.contentDOM||o.dom;break}a=o.dom.parentNode}let s=aJ(t,i.pos,1);for(let o=a.firstChild;o;o=o.nextSibling){let c;if(o.nodeType==1)c=o.getClientRects();else if(o.nodeType==3)c=oc(o,0,o.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"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const hBe=/[\u0590-\u08ac]/;function fBe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,s=i==r.parent.content.size,o=t.domSelection();return o?!hBe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:s:sJ(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:y}=t.domSelectionRange(),v=b&&!m.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==y;try{o.collapse(d,f),c&&(c!=d||u!=f)&&o.extend&&o.extend(c,u)}catch{}return g!=null&&(o.caretBidiLevel=g),v}):r.pos==r.start()||r.pos==r.end()}let r7=null,i7=null,a7=!1;function pBe(t,e,n){return r7==e&&i7==n?a7:(r7=e,i7=n,a7=n=="up"||n=="down"?dBe(t,e,n):fBe(t,e,n))}const oo=0,s7=1,bh=2,yl=3;class Qb{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=oo,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,s;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(s)+s.size:this.posAtStart}else{let a,s;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>ea(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),s;if(a&&(!n||a.node))if(r&&(s=a.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==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 s=0;s<i.children.length;s++){let o=i.children[s];if(o.size){i=o;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 s=this.children[r],o=a+s.size;if(o>e||s instanceof lJ){i=e-a;break}a=o}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 oJ&&a.side>=0;r--);if(n<=0){let a,s=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,s=!1);return a&&n&&s&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?ea(a.dom)+1:0}}else{let a,s=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,s=!1);return a&&s&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?ea(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 s=r,o=0;;o++){let c=this.children[o],u=s+c.size;if(i==-1&&e<=u){let d=s+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=s;for(let f=o;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=ea(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||o==this.children.length-1)){n=u;for(let d=o+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=ea(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}s=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),s=Math.max(e,n);for(let m=0,b=0;m<this.children.length;m++){let y=this.children[m],v=b+y.size;if(a>b&&s<v)return y.setSelection(e-b-y.border,n-b-y.border,r,i);b=v}let o=this.domFromPos(e,e?-1:1),c=n==e?o:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((so||ka)&&e==n){let{node:m,offset:b}=o;if(m.nodeType==3){if(f=!!(b&&m.nodeValue[b-1]==`
  8103. `),f&&b==m.nodeValue.length)for(let y=m,v;y;y=y.parentNode){if(v=y.nextSibling){v.nodeName=="BR"&&(o=c={node:v.parentNode,offset:ea(v)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=m.childNodes[b-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(so&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&ka)&&of(o.node,o.offset,d.anchorNode,d.anchorOffset)&&of(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&so)){u.collapse(o.node,o.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let b=o;o=c,c=b}let m=document.createRange();m.setEnd(c.node,c.offset),m.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],s=r+a.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let o=r+a.border,c=s-a.border;if(e>=o&&n<=c){this.dirty=e==r||n==s?bh:s7,e==o&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=yl:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?bh:yl}r=s}this.dirty=bh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?bh:s7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class oJ extends Qb{constructor(e,n,r,i){let a,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==oo&&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 mBe extends Qb{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 lf extends Qb{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],s=a&&a(n,i,r);return(!s||!s.dom)&&(s=gf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new lf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&yl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=yl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=oo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=oo}}slice(e,n,r){let i=lf.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=eR(a,n,s,r)),e>0&&(a=eR(a,0,e,r));for(let o=0;o<a.length;o++)a[o].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 nd extends Qb{constructor(e,n,r,i,a,s,o,c,u){super(e,[],a,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,a,s){let o=a.nodeViews[n.type.name],c,u=o&&o(n,a,()=>{if(!c)return s;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}=gf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let g=d;return d=dJ(d,r,n),u?c=new gBe(e,n,r,i,d,f||null,g,u,a,s+1):n.isText?new JM(e,n,r,i,d,g,a):new nd(e,n,r,i,d,f||null,g,a,s+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=()=>pt.empty)}return e}matchesNode(e,n,r){return this.dirty==oo&&e.eq(this.node)&&Ww(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,s=a&&a.pos>-1?a:null,o=a&&a.pos<0,c=new bBe(this,s&&s.node,e);_Be(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?tr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,g)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,f,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,m,e)||c.updateNextNode(u,d,f,e,g,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==bh)&&(s&&this.protectLocalComposition(e,s),cJ(this.contentDOM,this.children,e),Fm&&wBe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Kt)||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 s=a.nodeValue,o=SBe(this.node.content,s,r-n,i-n);return o<0?null:{node:a,pos:o,text:s}}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 s=new mBe(this,a,n,i);e.input.compositionNodes.push(s),this.children=eR(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==yl||!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=oo}updateOuterDeco(e){if(Ww(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=uJ(this.dom,this.nodeDOM,JP(this.outerDeco,this.node,n),JP(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function o7(t,e,n,r,i){dJ(r,e,t);let a=new nd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class JM extends nd{constructor(e,n,r,i,a,s,o){super(e,n,r,i,a,null,s,o,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==yl||this.dirty!=oo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=oo||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=oo,!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 JM(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=yl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class lJ extends Qb{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==oo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class gBe extends nd{constructor(e,n,r,i,a,s,o,c,u,d){super(e,n,r,i,a,s,o,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==yl)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 cJ(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let s=e[a],o=s.dom;if(o.parentNode==t){for(;o!=r;)r=l7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(s instanceof lf){let c=r?r.previousSibling:t.lastChild;cJ(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=l7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const n0=function(t){t&&(this.nodeName=t)};n0.prototype=Object.create(null);const yh=[new n0];function JP(t,e,n){if(t.length==0)return yh;let r=n?yh[0]:new n0,i=[r];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&i.push(r=new n0(s.nodeName));for(let o in s){let c=s[o];c!=null&&(n&&i.length==1&&i.push(r=new n0(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+c:o=="style"?r.style=(r.style?r.style+";":"")+c:o!="nodeName"&&(r[o]=c))}}}return i}function uJ(t,e,n,r){if(n==yh&&r==yh)return e;let i=e;for(let a=0;a<r.length;a++){let s=r[a],o=n[a];if(a){let c;o&&o.nodeName==s.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||(c=document.createElement(s.nodeName),c.pmIsDeco=!0,c.appendChild(i),o=yh[0]),i=c}xBe(i,o||yh[0],s)}return i}function xBe(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 dJ(t,e,n){return uJ(t,t,yh,JP(e,n,t.nodeType!=1))}function Ww(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 l7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class bBe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=yBe(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,s=Math.min(a,e.length);for(;i<s&&(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=oo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let o=-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)){o=c;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let c=lf.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,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))a=this.top.children.indexOf(s,this.index);else for(let o=this.index,c=Math.min(this.top.children.length,o+5);o<c;o++){let u=this.top.children[o];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=o;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let s=this.top.children[i];return s.dirty==yl&&s.dom==s.contentDOM&&(s.dirty=bh),s.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,s){for(let o=this.index;o<this.top.children.length;o++){let c=this.top.children[o];if(c instanceof nd){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,g=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=yl&&Ww(n,c.outerDeco));if(!g&&c.update(e,n,r,i))return this.destroyBetween(this.index,o),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(c,e,n,r,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=bh,f.updateChildren(i,s+1),f.dirty=oo),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Ww(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=nd.create(this.top,n,r,i,a,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let c of o.children)c.parent=o}return e.destroy(),o}addNode(e,n,r,i,a){let s=nd.create(this.top,e,n,r,i,a);s.contentDOM&&s.updateChildren(i,a+1),this.top.children.splice(this.index++,0,s),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 oJ(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 lf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof JM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ka||fa)&&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 lJ(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 yBe(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,s=[];e:for(;i>0;){let o;for(;;)if(r){let u=n.children[r-1];if(u instanceof lf)n=u,r=u.children.length;else{o=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=o.node;if(c){if(c!=t.child(i-1))break;--i,a.set(o,i),s.push(o)}}return{index:i,matched:a,matches:s.reverse()}}function vBe(t,e){return t.type.side-e.type.side}function _Be(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 s=0,o=[],c=null;for(let u=0;;){let d,f;for(;s<i.length&&i[s].to==a;){let v=i[s++];v.widget&&(d?(f||(f=[d])).push(v):d=v)}if(d)if(f){f.sort(vBe);for(let v=0;v<f.length;v++)n(f[v],u,!!c)}else n(d,u,!!c);let g,m;if(c)m=-1,g=c,c=null;else if(u<t.childCount)m=u,g=t.child(u++);else break;for(let v=0;v<o.length;v++)o[v].to<=a&&o.splice(v--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)o.push(i[s++]);let b=a+g.nodeSize;if(g.isText){let v=b;s<i.length&&i[s].from<v&&(v=i[s].from);for(let x=0;x<o.length;x++)o[x].to<v&&(v=o[x].to);v<b&&(c=g.cut(v-a),g=g.cut(0,v-a),b=v,m=-1)}else for(;s<i.length&&i[s].to<b;)s++;let y=g.isInline&&!g.isLeaf?o.filter(v=>!v.inline):o.slice();r(g,y,e.forChild(a,g),m),a=b}}function wBe(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 SBe(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let s=t.child(i++),o=a;if(a+=s.nodeSize,!s.isText)continue;let c=s.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-o,r-o)==e)return r-e.length;let u=o<r?c.lastIndexOf(e,r-o-1):-1;if(u>=0&&u+e.length+o>=n)return o+u;if(n==r&&c.length>=r+e.length-o&&c.slice(r-o,r-o+e.length)==e)return r}}return-1}function eR(t,e,n,r,i){let a=[];for(let s=0,o=0;s<t.length;s++){let c=t[s],u=o,d=o+=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 OO(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,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=r.resolve(s),c,u;if(QM(n)){for(c=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ht.isSelectable(f)&&i.parent&&!(f.isInline&&Xze(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new Ht(s==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,g=s;for(let m=0;m<n.rangeCount;m++){let b=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(f<0)return null;[c,s]=g==t.state.selection.anchor?[g,f]:[f,g],o=r.resolve(s)}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<o.pos&&!a?1:-1;u=LO(t,d,o,f)}return u}function hJ(t){return t.editable?t.hasFocus():pJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ac(t,e=!1){let n=t.state.selection;if(fJ(t,n),!!hJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&fa){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&of(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)EBe(t);else{let{anchor:r,head:i}=n,a,s;c7&&!(n instanceof Kt)&&(n.$from.parent.inlineContent||(a=u7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=u7(t,n.to))),t.docView.setSelection(r,i,t,e),c7&&(a&&d7(a),s&&d7(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&MBe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const c7=ka||fa&&eJ<63;function u7(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(ka&&i&&i.contentEditable=="false")return $N(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return $N(i);if(a)return $N(a)}}function $N(t){return t.contentEditable="true",ka&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function d7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function MBe(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(()=>{(!hJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function EBe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ea(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ya&&td<=11&&(n.disabled=!0,n.disabled=!1)}function fJ(t,e){if(e instanceof Ht){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(h7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else h7(t)}function h7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function LO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Kt.between(e,n,r)}function f7(t){return t.editable&&!t.hasFocus()?!1:pJ(t)}function pJ(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 ABe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return of(e.node,e.offset,n.anchorNode,n.anchorOffset)}function tR(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&&un.findFrom(a,e)}function Ru(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function p7(t,e,n){let r=t.state.selection;if(r instanceof Kt)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 s=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Ru(t,new Kt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=tR(t.state,e);return i&&i instanceof Ht?Ru(t,i):!1}else if(!(Ks&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!a||a.isText)return!1;let o=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?Ht.isSelectable(a)?Ru(t,new Ht(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Zb?Ru(t,new Kt(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Ru(t,new Kt(e>0?r.$to:r.$from));{let i=tR(t.state,e);return i?Ru(t,i):!1}}}function qw(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function r0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function jp(t,e){return e<0?TBe(t):CBe(t)}function TBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(so&&n.nodeType==1&&r<qw(n)&&r0(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(r0(o,-1))i=n,a=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(mJ(n))break;{let o=n.previousSibling;for(;o&&r0(o,-1);)i=n.parentNode,a=ea(o),o=o.previousSibling;if(o)n=o,r=qw(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?nR(t,n,r):i&&nR(t,i,a)}function CBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=qw(n),a,s;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(r0(o,1))a=n,s=++r;else break}else{if(mJ(n))break;{let o=n.nextSibling;for(;o&&r0(o,1);)a=o.parentNode,s=ea(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=qw(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&nR(t,a,s)}function mJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function NBe(t,e){for(;t&&e==t.childNodes.length&&!Yb(t);)e=ea(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 kBe(t,e){for(;t&&!e&&!Yb(t);)e=ea(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 nR(t,e,n){if(e.nodeType!=3){let a,s;(s=NBe(e,n))?(e=s,n=0):(a=kBe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(QM(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&&Ac(t)},50)}function m7(t,e){let n=t.state.doc.resolve(e);if(!(fa||Qze)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),s=(a.top+a.bottom)/2;if(s>i.top&&s<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),s=(a.top+a.bottom)/2;if(s>i.top&&s<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 g7(t,e,n){let r=t.state.selection;if(r instanceof Kt&&!r.empty||n.indexOf("s")>-1||Ks&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=tR(t.state,e);if(s&&s instanceof Ht)return Ru(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,o=r instanceof Ms?un.near(s,e):un.findFrom(s,e);return o?Ru(t,o):!1}return!1}function x7(t,e){if(!(t.state.selection instanceof Kt))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 s=t.state.tr;return e<0?s.delete(n.pos-a.nodeSize,n.pos):s.delete(n.pos,n.pos+a.nodeSize),t.dispatch(s),!0}return!1}function b7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function PBe(t){if(!ka||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;b7(t,r,"true"),setTimeout(()=>b7(t,r,"false"),20)}return!1}function RBe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function DBe(t,e){let n=e.keyCode,r=RBe(e);if(n==8||Ks&&n==72&&r=="c")return x7(t,-1)||jp(t,-1);if(n==46&&!e.shiftKey||Ks&&n==68&&r=="c")return x7(t,1)||jp(t,1);if(n==13||n==27)return!0;if(n==37||Ks&&n==66&&r=="c"){let i=n==37?m7(t,t.state.selection.from)=="ltr"?-1:1:-1;return p7(t,i,r)||jp(t,i)}else if(n==39||Ks&&n==70&&r=="c"){let i=n==39?m7(t,t.state.selection.from)=="ltr"?1:-1:1;return p7(t,i,r)||jp(t,i)}else{if(n==38||Ks&&n==80&&r=="c")return g7(t,-1,r)||jp(t,-1);if(n==40||Ks&&n==78&&r=="c")return PBe(t)||g7(t,1,r)||jp(t,1);if(r==(Ks?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function IO(t,e){t.someProp("transformCopied",m=>{e=m(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 m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let s=t.someProp("clipboardSerializer")||gf.fromSchema(t.state.schema),o=_J(),c=o.createElement("div");c.appendChild(s.serializeFragment(r,{document:o}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=vJ[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let b=o.createElement(d[m]);for(;c.firstChild;)b.appendChild(c.firstChild);c.appendChild(b),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
  8104. `);return{dom:c,text:g,slice:e}}function gJ(t,e,n,r,i){let a=i.parent.type.spec.code,s,o;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return o=new kt(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8105. `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)o=f;else{let g=i.marks(),{schema:m}=t.state,b=gf.fromSchema(m);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let v=s.appendChild(document.createElement("p"));y&&v.appendChild(b.serializeNode(m.text(y,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=IBe(n),Zb&&FBe(s);let u=s&&s.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||e0.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!jBe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=UBe(y7(o,+d[1],+d[2]),d[4]);else if(o=kt.maxOpen(OBe(o.content,i),!0),o.openStart||o.openEnd){let f=0,g=0;for(let m=o.content.firstChild;f<o.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=o.content.lastChild;g<o.openEnd&&!m.type.spec.isolating;g++,m=m.lastChild);o=y7(o,f,g)}return t.someProp("transformPasted",f=>{o=f(o,t,c)}),o}const jBe=/^(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 OBe(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,s=[];if(t.forEach(o=>{if(!s)return;let c=i.findWrapping(o.type),u;if(!c)return s=null;if(u=s.length&&a.length&&bJ(c,a,o,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=yJ(s[s.length-1],a.length));let d=xJ(o,c);s.push(d),i=i.matchType(d.type),a=c}}),s)return pt.from(s)}return t}function xJ(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function bJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=bJ(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(pt.from(xJ(n,t,i+1))))}}function yJ(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,yJ(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function rR(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,o=s.content;return t.childCount>1&&(a=0),i<r-1&&(o=rR(o,e,n,r,i+1,a)),i>=n&&(o=e<0?s.contentMatchAt(0).fillBefore(o,a<=i).append(o):o.append(s.contentMatchAt(s.childCount).fillBefore(pt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function y7(t,e,n){return e<t.openStart&&(t=new kt(rR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new kt(rR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const vJ={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 v7=null;function _J(){return v7||(v7=document.implementation.createHTMLDocument("title"))}let VN=null;function LBe(t){let e=window.trustedTypes;return e?(VN||(VN=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),VN.createHTML(t)):t}function IBe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=_J().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&vJ[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=LBe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function FBe(t){let e=t.querySelectorAll(fa?"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 UBe(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:s}=t;for(let o=r.length-2;o>=0;o-=2){let c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;i=pt.from(c.create(r[o+1],i)),a++,s++}return new kt(i,a,s)}const Pa={},Ra={},zBe={touchstart:!0,touchmove:!0};class BBe{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 HBe(t){for(let e in Pa){let n=Pa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{VBe(t,r)&&!FO(t,r)&&(t.editable||!(r.type in Ra))&&n(t,r)},zBe[e]?{passive:!0}:void 0)}ka&&t.dom.addEventListener("input",()=>null),iR(t)}function Wu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function $Be(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 iR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>FO(t,r))})}function FO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function VBe(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 GBe(t,e){!FO(t,e)&&Pa[e.type]&&(t.editable||!(e.type in Ra))&&Pa[e.type](t,e)}Ra.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!SJ(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(bc&&fa&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Fm&&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,hh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||DBe(t,n)?n.preventDefault():Wu(t,"key")};Ra.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ra.keypress=(t,e)=>{let n=e;if(SJ(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ks&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Kt)||!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",s=>s(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function eE(t){return{left:t.clientX,top:t.clientY}}function WBe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function UO(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,o=>s>a.depth?o(t,n,a.nodeAfter,a.before(s),i,!0):o(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function cm(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 qBe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ht.isSelectable(r)?(cm(t,new Ht(n)),!0):!1}function KBe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ht&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let o=s>a.depth?a.nodeAfter:a.node(s);if(Ht.isSelectable(o)){r&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(s);break}}return i!=null?(cm(t,Ht.create(t.state.doc,i)),!0):!1}function XBe(t,e,n,r,i){return UO(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?KBe(t,n):qBe(t,n))}function YBe(t,e,n,r){return UO(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function ZBe(t,e,n,r){return UO(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||QBe(t,n,r)}function QBe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(cm(t,Kt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let s=a>i.depth?i.nodeAfter:i.node(a),o=i.before(a);if(s.inlineContent)cm(t,Kt.create(r,o+1,o+1+s.content.size));else if(Ht.isSelectable(s))cm(t,Ht.create(r,o));else continue;return!0}}function zO(t){return Kw(t)}const wJ=Ks?"metaKey":"ctrlKey";Pa.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&&WBe(n,t.input.lastClick)&&!n[wJ]&&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 s=t.posAtCoords(eE(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new JBe(t,s,n,!!r)):(a=="doubleClick"?YBe:ZBe)(t,s.pos,s.inside,n)?n.preventDefault():Wu(t,"pointer"))};class JBe{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[wJ],this.allowDefault=r.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,s=d.depth?d.before():0}const o=i?null:r.target,c=o?e.docView.nearestDesc(o,!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 Ht&&u.from<=s&&u.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&so&&!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)),Wu(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(()=>Ac(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(eE(e))),this.updateAllowDefault(e),this.allowDefault||!n?Wu(this.view,"pointer"):XBe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ka&&this.mightDrag&&!this.mightDrag.node.isAtom||fa&&!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)?(cm(this.view,un.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Wu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wu(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)}}Pa.touchstart=t=>{t.input.lastTouch=Date.now(),zO(t),Wu(t,"pointer")};Pa.touchmove=t=>{t.input.lastTouch=Date.now(),Wu(t,"pointer")};Pa.contextmenu=t=>zO(t);function SJ(t,e){return t.composing?!0:ka&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const e8e=bc?5e3:-1;Ra.compositionstart=Ra.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Kt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Kw(t,!0),t.markCursor=null;else if(Kw(t,!e.selection.empty),so&&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 s=a<0?i.lastChild:i.childNodes[a-1];if(!s)break;if(s.nodeType==3){let o=t.domSelection();o&&o.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}MJ(t,e8e)};Ra.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++,MJ(t,20))};function MJ(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Kw(t),e))}function EJ(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=n8e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function t8e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=qze(e.focusNode,e.focusOffset),r=Kze(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 s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function n8e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Kw(t,e=!1){if(!(bc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),EJ(t),e||t.docView&&t.docView.dirty){let n=OO(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 r8e(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 rb=Ya&&td<15||Fm&&Jze<604;Pa.copy=Ra.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=rb?null:n.clipboardData,s=r.content(),{dom:o,text:c}=IO(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",c)):r8e(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function i8e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function a8e(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?ib(t,r.value,null,i,e):ib(t,r.textContent,r.innerHTML,i,e)},50)}function ib(t,e,n,r,i){let a=gJ(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||kt.empty)))return!0;if(!a)return!1;let s=i8e(a),o=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function AJ(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," "):""}Ra.paste=(t,e)=>{let n=e;if(t.composing&&!bc)return;let r=rb?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ib(t,AJ(r),r.getData("text/html"),i,n)?n.preventDefault():a8e(t,n)};class TJ{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const s8e=Ks?"altKey":"ctrlKey";function CJ(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[s8e]}Pa.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(eE(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Ht?i.to-1:i.to))){if(r&&r.mightDrag)s=Ht.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&&(s=Ht.create(t.state.doc,f.posBefore))}}let o=(s||t.state.selection).content(),{dom:c,text:u,slice:d}=IO(t,o);(!n.dataTransfer.files.length||!fa||eJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(rb?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",rb||n.dataTransfer.setData("text/plain",u),t.dragging=new TJ(d,CJ(t,n),s)};Pa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ra.dragover=Ra.dragenter=(t,e)=>e.preventDefault();Ra.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(eE(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",b=>{s=b(s,t,!1)}):s=gJ(t,AJ(n.dataTransfer),rb?null:n.dataTransfer.getData("text/html"),!1,a);let o=!!(r&&CJ(t,n));if(t.someProp("handleDrop",b=>b(t,n,s||kt.empty,o))){n.preventDefault();return}if(!s)return;n.preventDefault();let c=s?DQ(t.state.doc,a.pos,s):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:b}=r;b?b.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,s.content.firstChild):u.replaceRange(d,d,s),u.doc.eq(g))return;let m=u.doc.resolve(d);if(f&&Ht.isSelectable(s.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new Ht(m));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,v,x,M)=>b=M),u.setSelection(LO(t,m,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Pa.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())&&Ac(t)},20))};Pa.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)};Pa.beforeinput=(t,e)=>{if(fa&&bc&&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,hh(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 Ra)Pa[t]=Ra[t];function ab(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 Xw{constructor(e,n){this.toDOM=e,this.spec=n||jh,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Ea(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xw&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ab(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class rd{constructor(e,n){this.attrs=e,this.spec=n||jh}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=s?null:new Ea(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof rd&&ab(this.attrs,e.attrs)&&ab(this.spec,e.spec)}static is(e){return e.type instanceof rd}destroy(){}}class BO{constructor(e,n){this.attrs=e,this.spec=n||jh}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=a.pos?null:new Ea(a.pos-r,s.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 BO&&ab(this.attrs,e.attrs)&&ab(this.spec,e.spec)}destroy(){}}class Ea{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ea(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 Ea(e,e,new Xw(n,r))}static inline(e,n,r,i){return new Ea(e,n,new rd(r,i))}static node(e,n,r,i){return new Ea(e,n,new BO(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof rd}get widget(){return this.type instanceof Xw}}const zp=[],jh={};class yr{constructor(e,n){this.local=e.length?e:zp,this.children=n.length?n:zp}static create(e,n){return n.length?Yw(n,e,0,jh):da}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 s=0;s<this.local.length;s++){let o=this.local[s];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,n-o,r,i+o,a)}}map(e,n,r){return this==da||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jh)}mapInner(e,n,r,i,a){let s;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(e,r,i);c&&c.type.valid(n,c)?(s||(s=[])).push(c):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?o8e(this.children,s||[],e,n,r,i,a):s?new yr(s.sort(Oh),zp):da}add(e,n){return n.length?this==da?yr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((o,c)=>{let u=c+r,d;if(d=kJ(n,o,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(o,d,u+1):i.splice(a,0,c,c+o.nodeSize,Yw(d,o,u+1,jh)),a+=3}});let s=NJ(a?PJ(n):n,-r);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new yr(s.length?this.local.concat(s).sort(Oh):this.local,i||this.children)}remove(e){return e.length==0||this==da?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 s,o=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>o&&f.to<c&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(s,o+1);u!=da?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let o=0;o<i.length;o++)i[o].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new yr(i,r):da}forChild(e,n){if(this==da)return this;if(n.isLeaf)return yr.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let a=e+1,s=a+n.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<s&&c.to>a&&c.type instanceof rd){let u=Math.max(a,c.from)-a,d=Math.min(s,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let o=new yr(i.sort(Oh),zp);return r?new Fu([o,r]):o}return r||da}eq(e){if(this==e)return!0;if(!(e instanceof yr)||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 HO(this.localsInner(e))}localsInner(e){if(this==da)return zp;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)}}yr.empty=new yr([],[]);yr.removeOverlap=HO;const da=yr.empty;class Fu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,jh));return Fu.from(r)}forChild(e,n){if(n.isLeaf)return yr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=da&&(a instanceof Fu?r=r.concat(a.members):r.push(a))}return Fu.from(r)}eq(e){if(!(e instanceof Fu)||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 s=0;s<a.length;s++)n.push(a[s])}}return n?HO(r?n:n.sort(Oh)):zp}static from(e){switch(e.length){case 0:return da;case 1:return e[0];default:return new Fu(e.every(n=>n instanceof yr)?e:e.reduce((n,r)=>n.concat(r instanceof yr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function o8e(t,e,n,r,i,a,s){let o=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,m,b,y)=>{let v=y-b-(m-g);for(let x=0;x<o.length;x+=3){let M=o[x+1];if(M<0||g>M+d-f)continue;let S=o[x]+d-f;m>=S?o[x+1]=g<=S?-2:-1:g>=d&&v&&(o[x]+=v,o[x+1]+=v)}f+=v}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){c=!0,o[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let g=n.map(t[u+1]+a,-1),m=g-i,{index:b,offset:y}=r.content.findIndex(f),v=r.maybeChild(b);if(v&&y==f&&y+v.nodeSize==m){let x=o[u+2].mapInner(n,v,d+1,t[u]+a+1,s);x!=da?(o[u]=f,o[u+1]=m,o[u+2]=x):(o[u+1]=-2,c=!0)}else c=!0}if(c){let u=l8e(o,t,e,n,i,a,s),d=Yw(u,r,0,s);e=d.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let m=d.children[f];for(;g<o.length&&o[g]<m;)g+=3;o.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new yr(e.sort(Oh),o)}function NJ(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 Ea(i.from+e,i.to+e,i.type))}return n}function l8e(t,e,n,r,i,a,s){function o(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):s.onRemove&&s.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)o(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&o(t[c+2],e[c]+a+1);return n}function kJ(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,s;a<t.length;a++)(s=t[a])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[a]=null);return i}function PJ(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Yw(t,e,n,r){let i=[],a=!1;e.forEach((o,c)=>{let u=kJ(t,o,c+n);if(u){a=!0;let d=Yw(u,o,n+c+1,r);d!=da&&i.push(c,c+o.nodeSize,d)}});let s=NJ(a?PJ(t):t,-n).sort(Oh);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||(r.onRemove&&r.onRemove(s[o].spec),s.splice(o--,1));return s.length||i.length?new yr(s,i):da}function Oh(t,e){return t.from-e.from||t.to-e.to}function HO(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),_7(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),_7(e,i,r.copy(a.from,r.to)));break}}}return e}function _7(t,e,n){for(;e<t.length&&Oh(n,t[e])>0;)e++;t.splice(e,0,n)}function GN(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=da&&e.push(r)}),t.cursorWrapper&&e.push(yr.create(t.state.doc,[t.cursorWrapper.deco])),Fu.from(e)}const c8e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},u8e=Ya&&td<=11;class d8e{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 h8e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new d8e,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]);Ya&&td<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),u8e&&(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,c8e)),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(f7(this.view)){if(this.suppressingSelectionUpdates)return Ac(this.view);if(Ya&&td<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&of(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=Im(a))n.add(a);for(let a=e.anchorNode;a;a=Im(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)&&f7(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,o=!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),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(o=!0))}if(so&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let m=g.parentNode;m&&m.nodeName=="LI"&&(!f||m8e(e,f)!=m)&&g.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&QM(r)&&(u=OO(e))&&u.eq(un.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ac(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),f8e(e)),this.handleDOMChange(a,s,o,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ac(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(Ya&&td<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:g}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(a=g)}let s=i&&i.parentNode==e.target?ea(i)+1:0,o=r.localPosFromDOM(e.target,s,-1),c=a&&a.parentNode==e.target?ea(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:o,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 w7=new WeakMap,S7=!1;function f8e(t){if(!w7.has(t)&&(w7.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=so,S7)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."),S7=!0}}function M7(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return of(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function p8e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return M7(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?M7(t,n):null}function m8e(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 g8e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:o}=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}],QM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),fa&&t.input.lastKeyCode===8)for(let v=a;v>i;v--){let x=r.childNodes[v-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){a=v;break}if(!M||M.size)break}let f=t.state.doc,g=t.someProp("domParser")||e0.fromSchema(t.state.schema),m=f.resolve(s),b=null,y=g.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:x8e,context:m});if(u&&u[0].pos!=null){let v=u[0].pos,x=u[1]&&u[1].pos;x==null&&(x=v),b={anchor:v+s,head:x+s}}return{doc:y,sel:b,from:s,to:o}}function x8e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ka&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ka&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const b8e=/^(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 y8e(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=OO(t,N);if(I&&!t.state.selection.eq(I)){if(fa&&bc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,hh(13,"Enter"))))return;let C=t.state.tr.setSelection(I);N=="pointer"?C.setMeta("pointer",!0):N=="key"&&C.scrollIntoView(),a&&C.setMeta("composition",a),t.dispatch(C)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let c=t.state.selection,u=g8e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),g,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,m="end"):(g=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let b=w8e(f.content,u.doc.content,u.from,g,m);if(b&&t.input.domChangeCount++,(Fm&&t.input.lastIOSEnter>Date.now()-225||bc)&&i.some(N=>N.nodeType==1&&!b8e.test(N.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",N=>N(t,hh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&c instanceof Kt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let N=E7(t,t.state.doc,u.sel);if(N&&!N.eq(t.state.selection)){let I=t.state.tr.setSelection(N);a&&I.setMeta("composition",a),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof Kt&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Ya&&td<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let y=u.doc.resolveNoCache(b.start-u.from),v=u.doc.resolveNoCache(b.endB-u.from),x=d.resolve(b.start),M=y.sameParent(v)&&y.parent.inlineContent&&x.end()>=b.endA;if((Fm&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!M&&y.pos<u.doc.content.size&&(!y.sameParent(v)||!y.parent.inlineContent)&&y.pos<v.pos&&!/\S/.test(u.doc.textBetween(y.pos,v.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,hh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&_8e(d,b.start,b.endA,y,v)&&t.someProp("handleKeyDown",N=>N(t,hh(8,"Backspace")))){bc&&fa&&t.domObserver.suppressSelectionUpdates();return}fa&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),bc&&!M&&y.start()!=v.start()&&v.parentOffset==0&&y.depth==v.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,v=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,hh(13,"Enter"))})},20));let S=b.start,A=b.endA,T=N=>{let I=N||t.state.tr.replace(S,A,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let C=E7(t,I.doc,u.sel);C&&!(fa&&t.composing&&C.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==S||C.head==I.mapping.map(A)-1)||Ya&&C.empty&&C.head==S)&&I.setSelection(C)}return a&&I.setMeta("composition",a),I.scrollIntoView()},k;if(M)if(y.pos==v.pos){Ya&&td<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ac(t),20));let N=T(t.state.tr.delete(S,A)),I=d.resolve(b.start).marksAcross(d.resolve(b.endA));I&&N.ensureMarks(I),t.dispatch(N)}else if(b.endA==b.endB&&(k=v8e(y.parent.content.cut(y.parentOffset,v.parentOffset),x.parent.content.cut(x.parentOffset,b.endA-x.start())))){let N=T(t.state.tr);k.type=="add"?N.addMark(S,A,k.mark):N.removeMark(S,A,k.mark),t.dispatch(N)}else if(y.parent.child(y.index()).isText&&y.index()==v.index()-(v.textOffset?0:1)){let N=y.parent.textBetween(y.parentOffset,v.parentOffset),I=()=>T(t.state.tr.insertText(N,S,A));t.someProp("handleTextInput",C=>C(t,S,A,N,I))||t.dispatch(I())}else t.dispatch(T());else t.dispatch(T())}function E7(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:LO(t,e.resolve(n.anchor),e.resolve(n.head))}function v8e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,o,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)o=i[0],s="add",c=d=>d.mark(o.addToSet(d.marks));else if(i.length==0&&a.length==1)o=a[0],s="remove",c=d=>d.mark(o.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(pt.from(u).eq(t))return{mark:o,type:s}}function _8e(t,e,n,r,i){if(n-e<=i.pos-r.pos||WN(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(WN(a,!0,!0));return!s.parent.isTextblock||s.pos>n||WN(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function WN(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 w8e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(s,o));r-=s+c-a}if(s<a&&t.size<e.size){let c=r<=a&&r>=s?a-r:0;a-=c,a&&a<e.size&&A7(e.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-s),s=a}else if(o<a){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<t.size&&A7(t.textBetween(a-1,a+1))&&(a+=c?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function A7(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 RJ{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 BBe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(P7),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=N7(this),C7(this),this.nodeViews=k7(this),this.docView=o7(this.state.doc,T7(this),GN(this),this.dom,this),this.domObserver=new h8e(this,(r,i,a,s)=>y8e(this,r,i,a,s)),this.domObserver.start(),HBe(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&&iR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(P7),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,s=!1;e.storedMarks&&this.composing&&(EJ(this),s=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=k7(this);M8e(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&iR(this),this.editable=N7(this),C7(this);let c=GN(this),u=T7(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))&&(s=!0);let g=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&nBe(this);if(s){this.domObserver.stop();let m=f&&(Ya||fa)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&S8e(i.selection,e.selection);if(f){let b=fa?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=t8e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=o7(e.doc,u,c,this.dom,this)),b&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ABe(this))?Ac(this,m):(fJ(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():g&&rBe(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Ht){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&t7(this,n.getBoundingClientRect(),e)}else t7(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 TJ(e.slice,e.move,i<0?void 0:Ht.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 s=0;s<this.directPlugins.length;s++){let o=this.directPlugins[s].props[e];if(o!=null&&(i=n?n(o):o))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let o=a[s].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Ya){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&&iBe(this.dom),Ac(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 cBe(this,e)}coordsAtPos(e,n=1){return aJ(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 pBe(this,n||this.state,e)}pasteHTML(e,n){return ib(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ib(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return IO(this,e)}destroy(){this.docView&&($Be(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],GN(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Gze())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return GBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?ka&&this.root.nodeType===11&&Yze(this.dom.ownerDocument)==this.dom&&p8e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}RJ.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function T7(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"),[Ea.node(0,t.state.doc.content.size,e)]}function C7(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:Ea.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function N7(t){return!t.someProp("editable",e=>e(t.state)===!1)}function S8e(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 k7(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 M8e(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 P7(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 md={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:"'"},Zw={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},E8e=typeof navigator<"u"&&/Mac/.test(navigator.platform),A8e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ta=0;ta<10;ta++)md[48+ta]=md[96+ta]=String(ta);for(var ta=1;ta<=24;ta++)md[ta+111]="F"+ta;for(var ta=65;ta<=90;ta++)md[ta]=String.fromCharCode(ta+32),Zw[ta]=String.fromCharCode(ta);for(var qN in md)Zw.hasOwnProperty(qN)||(Zw[qN]=md[qN]);function T8e(t){var e=E8e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||A8e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Zw:md)[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 C8e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),N8e=typeof navigator<"u"&&/Win/.test(navigator.platform);function k8e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o++){let c=e[o];if(/^(cmd|meta|m)$/i.test(c))s=!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))C8e?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function P8e(t){let e=Object.create(null);for(let n in t)e[k8e(n)]=t[n];return e}function KN(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 R8e(t){return new Er({props:{handleKeyDown:DJ(t)}})}function DJ(t){let e=P8e(t);return function(n,r){let i=T8e(r),a,s=e[KN(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[KN(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(N8e&&r.ctrlKey&&r.altKey)&&(a=md[r.keyCode])&&a!=i){let o=e[KN(a,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var D8e=Object.defineProperty,$O=(t,e)=>{for(var n in e)D8e(t,n,{get:e[n],enumerable:!0})};function tE(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var nE=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(([s,o])=>[s,(...u)=>{const d=o(...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,s=[],o=!!t,c=t||i.tr,u=()=>(!o&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),s.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...b)=>{const y=this.buildProps(c,e),v=g(...b)(y);return s.push(v),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(([o,c])=>[o,(...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,s={tr:t,editor:r,view:a,state:tE({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,c])=>[o,(...u)=>c(...u)(s)]))}};return s}},jJ={};$O(jJ,{blur:()=>j8e,clearContent:()=>O8e,clearNodes:()=>L8e,command:()=>I8e,createParagraphNear:()=>F8e,cut:()=>U8e,deleteCurrentNode:()=>z8e,deleteNode:()=>B8e,deleteRange:()=>H8e,deleteSelection:()=>$8e,enter:()=>V8e,exitCode:()=>G8e,extendMarkRange:()=>W8e,first:()=>q8e,focus:()=>X8e,forEach:()=>Y8e,insertContent:()=>Z8e,insertContentAt:()=>e6e,joinBackward:()=>r6e,joinDown:()=>n6e,joinForward:()=>i6e,joinItemBackward:()=>a6e,joinItemForward:()=>s6e,joinTextblockBackward:()=>o6e,joinTextblockForward:()=>l6e,joinUp:()=>t6e,keyboardShortcut:()=>u6e,lift:()=>d6e,liftEmptyBlock:()=>h6e,liftListItem:()=>f6e,newlineInCode:()=>p6e,resetAttributes:()=>m6e,scrollIntoView:()=>g6e,selectAll:()=>x6e,selectNodeBackward:()=>b6e,selectNodeForward:()=>y6e,selectParentNode:()=>v6e,selectTextblockEnd:()=>_6e,selectTextblockStart:()=>w6e,setContent:()=>S6e,setMark:()=>B6e,setMeta:()=>H6e,setNode:()=>$6e,setNodeSelection:()=>V6e,setTextDirection:()=>G6e,setTextSelection:()=>W6e,sinkListItem:()=>q6e,splitBlock:()=>K6e,splitListItem:()=>X6e,toggleList:()=>Y6e,toggleMark:()=>Z6e,toggleNode:()=>Q6e,toggleWrap:()=>J6e,undoInputRule:()=>eHe,unsetAllMarks:()=>tHe,unsetMark:()=>nHe,unsetTextDirection:()=>rHe,updateAttributes:()=>iHe,wrapIn:()=>aHe,wrapInList:()=>sHe});var j8e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),O8e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),L8e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(o,c)=>{if(o.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+o.nodeSize)),m=f.blockRange(g);if(!m)return;const b=dg(m);if(o.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,y)}(b||b===0)&&e.lift(m,b)})}),!0},I8e=t=>e=>t(e),F8e=()=>({state:t,dispatch:e})=>XQ(t,e),U8e=(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 s=r.mapping.map(e);return r.insert(s,a.content),r.setSelection(new Kt(r.doc.resolve(Math.max(s-1,0)))),!0},z8e=()=>({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 o=i.before(a),c=i.after(a);t.delete(o,c).scrollIntoView()}return!0}return!1};function ii(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 B8e=t=>({tr:e,state:n,dispatch:r})=>{const i=ii(t,n.schema),a=e.selection.$anchor;for(let s=a.depth;s>0;s-=1)if(a.node(s).type===i){if(r){const c=a.before(s),u=a.after(s);e.delete(c,u).scrollIntoView()}return!0}return!1},H8e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},$8e=()=>({state:t,dispatch:e})=>NO(t,e),V8e=()=>({commands:t})=>t.keyboardShortcut("Enter"),G8e=()=>({state:t,dispatch:e})=>kze(t,e);function VO(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Qw(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:VO(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function OJ(t,e,n={}){return t.find(r=>r.type===e&&Qw(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function R7(t,e,n={}){return!!OJ(t,e,n)}function GO(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),!OJ([...i.node.marks],e,n)))return;let s=i.index,o=t.start()+i.offset,c=s+1,u=o+i.node.nodeSize;for(;s>0&&R7([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;c<t.parent.childCount&&R7([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:o,to:u}}function Hc(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 W8e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Hc(t,r.schema),{doc:s,selection:o}=n,{$from:c,from:u,to:d}=o;if(i){const f=GO(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=Kt.create(s,f.from,f.to);n.setSelection(g)}}return!0},q8e=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 LJ(t){return t instanceof Kt}function vh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function IJ(t,e=null){if(!e)return null;const n=un.atStart(t),r=un.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Kt.create(t,vh(0,i,a),vh(t.content.size,i,a)):Kt.create(t,vh(e,i,a),vh(e,i,a))}function K8e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function WO(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var X8e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(WO()||K8e())&&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&&!LJ(n.state.selection))return s(),!0;const o=IJ(i.doc,t)||n.state.selection,c=n.state.selection.eq(o);return a&&(c||i.setSelection(o),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},Y8e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),Z8e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),FJ=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&&FJ(r)}return t};function F_(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 FJ(n)}function sb(t,e,n){if(t instanceof ed||t instanceof pt)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 pt.fromArray(t.map(o=>e.nodeFromJSON(o)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}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),sb("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,o="";const c=new wQ({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=>(s=!0,o=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?e0.fromSchema(c).parseSlice(F_(t),n.parseOptions):e0.fromSchema(c).parse(F_(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=e0.fromSchema(e);return n.slice?a.parseSlice(F_(t),n.parseOptions).content:a.parse(F_(t),n.parseOptions)}return sb("",e,n)}function Q8e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Oi||i instanceof Ii))return;const a=t.mapping.maps[r];let s=0;a.forEach((o,c,u,d)=>{s===0&&(s=d)}),t.setSelection(un.near(t.doc.resolve(s),n))}var J8e=t=>!("type"in t),e6e=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var s;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const c=v=>{a.emit("contentError",{editor:a,error:v,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{sb(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(v){c(v)}try{o=sb(e,a.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(v){return c(v),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((J8e(o)?o:[o]).forEach(v=>{v.check(),g=g?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),d===f&&m){const{parent:v}=r.doc.resolve(d);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(d-=1,f+=1)}let y;if(g){if(Array.isArray(e))y=e.map(v=>v.text||"").join("");else if(e instanceof pt){let v="";e.forEach(x=>{x.text&&(v+=x.text)}),y=v}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=o;const v=r.doc.resolve(d),x=v.node(),M=v.parentOffset===0,S=x.isText||x.isTextblock,A=x.content.size>0;M&&S&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&Q8e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},t6e=()=>({state:t,dispatch:e})=>Tze(t,e),n6e=()=>({state:t,dispatch:e})=>Cze(t,e),r6e=()=>({state:t,dispatch:e})=>HQ(t,e),i6e=()=>({state:t,dispatch:e})=>WQ(t,e),a6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=XM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},s6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=XM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},o6e=()=>({state:t,dispatch:e})=>Eze(t,e),l6e=()=>({state:t,dispatch:e})=>Aze(t,e);function UJ(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function c6e(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o+=1){const c=e[o];if(/^(cmd|meta|m)$/i.test(c))s=!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))WO()||UJ()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var u6e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=c6e(t).split(/-(?!$)/),s=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),o=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,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,o))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function gd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?ii(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const m=Math.max(r,g),b=Math.min(i,g+f.nodeSize);o.push({node:f,from:m,to:b})});const c=i-r,u=o.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>Qw(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var d6e=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?Nze(n,r):!1},h6e=()=>({state:t,dispatch:e})=>YQ(t,e),f6e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Bze(r)(e,n)},p6e=()=>({state:t,dispatch:e})=>KQ(t,e);function rE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function D7(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 m6e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=rE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=ii(t,r.schema)),o==="mark"&&(s=Hc(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,D7(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(g=>{s===g.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,s.create(D7(g.attrs,e))))})})}),c},g6e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),x6e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ms(t.doc);t.setSelection(n)}return!0},b6e=()=>({state:t,dispatch:e})=>VQ(t,e),y6e=()=>({state:t,dispatch:e})=>qQ(t,e),v6e=()=>({state:t,dispatch:e})=>Dze(t,e),_6e=()=>({state:t,dispatch:e})=>Lze(t,e),w6e=()=>({state:t,dispatch:e})=>Oze(t,e);function aR(t,e,n={},r={}){return sb(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var S6e=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:o})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=aR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return s&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function zJ(t,e){const n=Hc(e,t.schema),{from:r,to:i,empty:a}=t.selection,s=[];a?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{s.push(...c.marks)});const o=s.find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function BJ(t,e){const n=new FQ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function M6e(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 E6e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function A6e(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 iE(t){return e=>A6e(e.$from,t)}function Bt(t,e,n){return t.config[e]===void 0&&t.parent?Bt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Bt(t.parent,e,n):null}):t.config[e]}function qO(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Bt(e,"addExtensions",n);return r?[e,...qO(r())]:e}).flat(10)}function KO(t,e){const n=gf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function HJ(t){return typeof t=="function"}function Un(t,e=void 0,...n){return HJ(t)?e?t.bind(e)(...n):t(...n):t}function T6e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Um(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 $J(t){const e=[],{nodeExtensions:n,markExtensions:r}=Um(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage,extensions:i},c=Bt(s,"addGlobalAttributes",o);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,m])=>{e.push({type:f,name:g,attribute:{...a,...m}})})})})}),i.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},c=Bt(s,"addAttributes",o);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const g={...a,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:s.name,name:d,attribute:g})})}),e}function Dr(...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 o=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=o.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const o=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,g]=d.split(":").map(m=>m.trim());u.set(f,g)}),o.forEach(d=>{const[f,g]=d.split(":").map(m=>m.trim());u.set(f,g)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function Jw(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)=>Dr(n,r),{})}function C6e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function j7(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,s)=>{const o=s.attribute.parseHTML?s.attribute.parseHTML(n):C6e(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...r,...i}}}}function O7(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&T6e(n)?!1:n!=null))}function L7(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 N6e(t,e){var n;const r=$J(t),{nodeExtensions:i,markExtensions:a}=Um(t),s=(n=i.find(u=>Bt(u,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(u=>{const d=r.filter(x=>x.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((x,M)=>{const S=Bt(M,"extendNodeSchema",f);return{...x,...S?S(u):{}}},{}),m=O7({...g,content:Un(Bt(u,"content",f)),marks:Un(Bt(u,"marks",f)),group:Un(Bt(u,"group",f)),inline:Un(Bt(u,"inline",f)),atom:Un(Bt(u,"atom",f)),selectable:Un(Bt(u,"selectable",f)),draggable:Un(Bt(u,"draggable",f)),code:Un(Bt(u,"code",f)),whitespace:Un(Bt(u,"whitespace",f)),linebreakReplacement:Un(Bt(u,"linebreakReplacement",f)),defining:Un(Bt(u,"defining",f)),isolating:Un(Bt(u,"isolating",f)),attrs:Object.fromEntries(d.map(L7))}),b=Un(Bt(u,"parseHTML",f));b&&(m.parseDOM=b.map(x=>j7(x,d)));const y=Bt(u,"renderHTML",f);y&&(m.toDOM=x=>y({node:x,HTMLAttributes:Jw(x,d)}));const v=Bt(u,"renderText",f);return v&&(m.toText=v),[u.name,m]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((v,x)=>{const M=Bt(x,"extendMarkSchema",f);return{...v,...M?M(u):{}}},{}),m=O7({...g,inclusive:Un(Bt(u,"inclusive",f)),excludes:Un(Bt(u,"excludes",f)),group:Un(Bt(u,"group",f)),spanning:Un(Bt(u,"spanning",f)),code:Un(Bt(u,"code",f)),attrs:Object.fromEntries(d.map(L7))}),b=Un(Bt(u,"parseHTML",f));b&&(m.parseDOM=b.map(v=>j7(v,d)));const y=Bt(u,"renderHTML",f);return y&&(m.toDOM=v=>y({mark:v,HTMLAttributes:Jw(v,d)})),[u.name,m]}));return new wQ({topNode:s,nodes:o,marks:c})}function k6e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function XO(t){return t.sort((n,r)=>{const i=Bt(n,"priority")||100,a=Bt(r,"priority")||100;return i>a?-1:i<a?1:0})}function VJ(t){const e=XO(qO(t)),n=k6e(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 GJ(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8106. `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(r,i,(c,u,d,f)=>{var g;c.isBlock&&u>r&&(o+=a);const m=s?.[c.type.name];if(m)return d&&(o+=m({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(o+=(g=c?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),o}function P6e(t,e){const n={from:0,to:t.content.size};return GJ(t,n,e)}function WJ(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function R6e(t,e){const n=ii(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function qJ(t,e){const n=rE(typeof e=="string"?e:e.name,t.schema);return n==="node"?R6e(t,e):n==="mark"?zJ(t,e):{}}function D6e(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 j6e(t){const e=D6e(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,s)=>s!==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 KJ(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((o,c)=>{s.push({from:o,to:c})});else{const{from:o,to:c}=n[a];if(o===void 0||c===void 0)return;s.push({from:o,to:c})}s.forEach(({from:o,to:c})=>{const u=e.slice(a).map(o,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),j6e(r)}function YO(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=GO(a,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:a,to:a+i.nodeSize,mark:s})))}),r}var O6e=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const o=i.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function XN(t,e){return e.nodes[t]||e.marks[t]||null}function x1(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 L6e=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,o)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:s,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function sR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Hc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>Qw(f.attrs,n,{strict:!1}));let s=0;const o=[];if(i.forEach(({$from:f,$to:g})=>{const m=f.pos,b=g.pos;t.doc.nodesBetween(m,b,(y,v)=>{if(!y.isText&&!y.marks.length)return;const x=Math.max(m,v),M=Math.min(b,v+y.nodeSize),S=M-x;s+=S,o.push(...y.marks.map(A=>({mark:A,from:x,to:M})))})}),s===0)return!1;const c=o.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>Qw(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=o.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=s}function I6e(t,e,n={}){if(!e)return gd(t,null,n)||sR(t,null,n);const r=rE(e,t.schema);return r==="node"?gd(t,e,n):r==="mark"?sR(t,e,n):!1}var F6e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=iE(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},U6e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function I7(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function F7(t,e){const{nodeExtensions:n}=Um(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Un(Bt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function aE(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&&(aE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function XJ(t){return t instanceof Ht}function z6e(t,e,n){var r;const{selection:i}=e;let a=null;if(LJ(i)&&(a=i.$cursor),a){const o=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(u=>u.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:o,$to:c})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const m=!g||g.type.allowsMarkType(n),b=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=m&&b}return!u}),u})}var B6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:o}=a,c=Hc(t,r.schema);if(i)if(s){const u=zJ(r,c);n.addStoredMark(c.create({...u,...e}))}else o.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,m)=>{const b=Math.max(m,d),y=Math.min(m+g.nodeSize,f);g.marks.find(x=>x.type===c)?g.marks.forEach(x=>{c===x.type&&n.addMark(b,y,c.create({...x.attrs,...e}))}):n.addMark(b,y,c.create(e))})});return z6e(r,n,c)},H6e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),$6e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=ii(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:o})=>QV(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>QV(a,{...s,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},V6e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=vh(t,0,r.content.size),a=Ht.create(r,i);e.setSelection(a)}return!0},G6e=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},W6e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Kt.atStart(r).from,o=Kt.atEnd(r).to,c=vh(i,s,o),u=vh(a,s,o),d=Kt.create(r,c,u);e.setSelection(d)}return!0},q6e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Vze(r)(e,n)};function U7(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 K6e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:o,$to:c}=a,u=i.extensionManager.attributes,d=x1(u,o.node().type.name,o.node().attrs);if(a instanceof Ht&&a.node.isBlock)return!o.parentOffset||!Ec(s,o.pos)?!1:(r&&(t&&U7(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=o.depth===0?void 0:M6e(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=f&&g?[{type:g,attrs:d}]:void 0,b=Ec(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!b&&Ec(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(b=!0,m=g?[{type:g,attrs:d}]:void 0),r){if(b&&(a instanceof Kt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!f&&!o.parentOffset&&o.parent.type!==g)){const y=e.mapping.map(o.before()),v=e.doc.resolve(y);o.node(-1).canReplaceWith(v.index(),v.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&U7(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},X6e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const o=ii(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!==o)return!1;const g=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let x=pt.empty;const M=c.index(-1)?1:c.index(-2)?2:3;for(let I=c.depth-M;I>=c.depth-3;I-=1)x=pt.from(c.node(I).copy(x));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...x1(g,c.node().type.name,c.node().attrs),...e},T=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(A))||void 0;x=x.append(pt.from(o.createAndFill(null,T)||void 0));const k=c.before(c.depth-(M-1));n.replace(k,c.after(-S),new kt(x,4-M,0));let N=-1;n.doc.nodesBetween(k,n.doc.content.size,(I,C)=>{if(N>-1)return!1;I.isTextblock&&I.content.size===0&&(N=C+1)}),N>-1&&n.setSelection(Kt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...x1(g,f.type.name,f.attrs),...e},y={...x1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const v=m?[{type:o,attrs:b},{type:m,attrs:y}]:[{type:o,attrs:b}];if(!Ec(n.doc,c.pos,2))return!1;if(i){const{selection:x,storedMarks:M}=r,{splittableMarks:S}=a.extensionManager,A=M||x.$to.parentOffset&&x.$from.marks();if(n.split(c.pos,2,v).scrollIntoView(),!A||!i)return!0;const T=A.filter(k=>S.includes(k.type.name));n.ensureMarks(T)}return!0},YN=(t,e)=>{const n=iE(s=>s.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&&Md(t.doc,n.pos)&&t.join(n.pos),!0},ZN=(t,e)=>{const n=iE(s=>s.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&&Md(t.doc,r)&&t.join(r),!0},Y6e=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:o,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,m=ii(t,s.schema),b=ii(e,s.schema),{selection:y,storedMarks:v}=s,{$from:x,$to:M}=y,S=x.blockRange(M),A=v||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const T=iE(k=>F7(k.type.name,f))(y);if(S.depth>=1&&T&&S.depth-T.depth<=1){if(T.node.type===m)return u.liftListItem(b);if(F7(T.node.type.name,f)&&m.validContent(T.node.content)&&o)return c().command(()=>(a.setNodeMarkup(T.pos,m),!0)).command(()=>YN(a,m)).command(()=>ZN(a,m)).run()}return!n||!A||!o?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>YN(a,m)).command(()=>ZN(a,m)).run():c().command(()=>{const k=d().wrapInList(m,r),N=A.filter(I=>g.includes(I.type.name));return a.ensureMarks(N),k?!0:u.clearNodes()}).wrapInList(m,r).command(()=>YN(a,m)).command(()=>ZN(a,m)).run()},Z6e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=Hc(t,r.schema);return sR(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},Q6e=(t,e,n={})=>({state:r,commands:i})=>{const a=ii(t,r.schema),s=ii(e,r.schema),o=gd(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),o?i.setNode(s,c):i.setNode(a,{...c,...n})},J6e=(t,e={})=>({state:n,commands:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?r.lift(i):r.wrapIn(i,e)},eHe=()=>({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 s=t.tr,o=a.transform;for(let c=o.steps.length-1;c>=0;c-=1)s.step(o.steps[c].invert(o.docs[c]));if(a.text){const c=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else s.delete(a.from,a.to)}return!0}}return!1},tHe=()=>({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},nHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,c=Hc(t,r.schema),{$from:u,empty:d,ranges:f}=o;if(!i)return!0;if(d&&s){let{from:g,to:m}=o;const b=(a=u.marks().find(v=>v.type===c))==null?void 0:a.attrs,y=GO(u,c,b);y&&(g=y.from,m=y.to),n.removeMark(g,m,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},rHe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(o,c)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},iHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=rE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=ii(t,r.schema)),o==="mark"&&(s=Hc(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,m,b,y;n.selection.empty?r.doc.nodesBetween(d,f,(v,x)=>{a&&a===v.type&&(c=!0,b=Math.max(x,d),y=Math.min(x+v.nodeSize,f),g=x,m=v)}):r.doc.nodesBetween(d,f,(v,x)=>{x<d&&a&&a===v.type&&(c=!0,b=Math.max(x,d),y=Math.min(x+v.nodeSize,f),g=x,m=v),x>=d&&x<=f&&(a&&a===v.type&&(c=!0,i&&n.setNodeMarkup(x,void 0,{...v.attrs,...e})),s&&v.marks.length&&v.marks.forEach(M=>{if(s===M.type&&(c=!0,i)){const S=Math.max(x,d),A=Math.min(x+v.nodeSize,f);n.addMark(S,A,s.create({...M.attrs,...e}))}}))}),m&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(v=>{s===v.type&&i&&n.addMark(b,y,s.create({...v.attrs,...e}))}))}),c},aHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return Ize(i,e)(n,r)},sHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return Fze(i,e)(n,r)},oHe=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={}}},sE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},lHe=(t,e)=>{if(VO(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 U_(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:o}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=L6e(u)+a;return s.forEach(g=>{if(d)return;const m=lHe(f,g.find);if(!m)return;const b=c.state.tr,y=tE({state:c.state,transaction:b}),v={from:r-(m[0].length-a.length),to:i},{commands:x,chain:M,can:S}=new nE({editor:n,state:y});g.handler({state:y,range:v,match:m,commands:x,chain:M,can:S})===null||!b.steps.length||(g.undoable&&b.setMeta(o,{transform:b,from:r,to:i,text:a}),c.dispatch(b),d=!0)}),d}function cHe(t){const{editor:e,rules:n}=t,r=new Er({state:{init(){return null},apply(i,a,s){const o=i.getMeta(r);if(o)return o;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=KO(pt.from(d),s.schema);const{from:f}=c,g=f+d.length;U_({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,o){return U_({editor:e,from:a,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&U_({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:s}=i.state.selection;return s?U_({editor:e,from:s.pos,to:s.pos,text:`
  8107. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function uHe(t){return Object.prototype.toString.call(t).slice(8,-1)}function z_(t){return uHe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function YJ(t,e){const n={...t};return z_(t)&&z_(e)&&Object.keys(e).forEach(r=>{z_(e[r])&&z_(t[r])?n[r]=YJ(t[r],e[r]):n[r]=e[r]}),n}var ZO=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{...Un(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Un(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>YJ(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}},Ad=class ZJ extends ZO{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new ZJ(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(u=>u?.type.name===n.name))return!1;const c=s.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 dHe(t){return typeof t=="number"}var hHe=class{constructor(t){this.find=t.find,this.handler=t.handler}},fHe=(t,e,n)=>{if(VO(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 pHe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:c,chain:u,can:d}=new nE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,b)=>{var y,v,x,M,S;if((v=(y=m.type)==null?void 0:y.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const A=(S=(M=(x=m.content)==null?void 0:x.size)!=null?M:m.nodeSize)!=null?S:0,T=Math.max(r,b),k=Math.min(i,b+A);if(T>=k)return;const N=m.isText?m.text||"":m.textBetween(T-b,k-b,void 0,"");fHe(N,a.find,s).forEach(C=>{if(C.index===void 0)return;const D=T+C.index+1,F=D+C[0].length,O={from:n.tr.mapping.map(D),to:n.tr.mapping.map(F)},q=a.handler({state:n,range:O,match:C,commands:c,chain:u,can:d,pasteEvent:s,dropEvent:o});f.push(q)})}),f.every(m=>m!==null)}var B_=null,mHe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function gHe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const c=({state:d,from:f,to:g,rule:m,pasteEvt:b})=>{const y=d.tr,v=tE({state:d,transaction:y});if(!(!pHe({editor:e,state:v,from:Math.max(f-1,0),to:g.b-1,rule:m,pasteEvent:b,dropEvent:o})||!y.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Er({view(f){const g=b=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(b.target)?f.dom.parentElement:null,r&&(B_=e)},m=()=>{B_&&(B_=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(a=r===f.dom.parentElement,o=g,!a){const m=B_;m?.isEditable&&setTimeout(()=>{const b=m.state.selection;b&&m.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,g)=>{var m;const b=(m=g.clipboardData)==null?void 0:m.getData("text/html");return s=g,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,m)=>{const b=f[0],y=b.getMeta("uiEvent")==="paste"&&!i,v=b.getMeta("uiEvent")==="drop"&&!a,x=b.getMeta("applyPasteRules"),M=!!x;if(!y&&!v&&!M)return;if(M){let{text:T}=x;typeof T=="string"?T=T:T=KO(pt.from(T),m.schema);const{from:k}=x,N=k+T.length,I=mHe(T);return c({rule:d,state:m,from:k,to:{b:N},pasteEvt:I})}const S=g.doc.content.findDiffStart(m.doc.content),A=g.doc.content.findDiffEnd(m.doc.content);if(!(!dHe(S)||!A||S===A.b))return c({rule:d,state:m,from:S,to:A,pasteEvt:s})}}))}var oE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=VJ(t),this.schema=N6e(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:XN(e.name,this.schema)},r=Bt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return XO([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:XN(r.name,this.schema)},a=[],s=Bt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Bt(r,"exitable",i)&&(o.ArrowRight=()=>Ad.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([m,b])=>[m,()=>b({editor:t})]));o={...o,...g}}const c=R8e(o);a.push(c);const u=Bt(r,"addInputRules",i);if(I7(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const m=cHe({editor:t,rules:g}),b=Array.isArray(m)?m:[m];a.push(...b)}}const d=Bt(r,"addPasteRules",i);if(I7(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const m=gHe({editor:t,rules:g});a.push(...m)}}const f=Bt(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return $J(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Um(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(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:ii(n.name,this.schema)},a=Bt(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const o=(c,u,d,f,g)=>{const m=Jw(c,r);return s({node:c,view:u,getPos:d,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Um(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Hc(n.name,this.schema)},a=Bt(n,"addMarkView",i);if(!a)return[];const s=(o,c,u)=>{const d=Jw(o,r);return a()({mark:o,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{PHe(o,t,f)}})};return[n.name,s]}))}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:XN(e.name,this.schema)};e.type==="mark"&&((n=Un(Bt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Bt(e,"onBeforeCreate",r),a=Bt(e,"onCreate",r),s=Bt(e,"onUpdate",r),o=Bt(e,"onSelectionUpdate",r),c=Bt(e,"onTransaction",r),u=Bt(e,"onFocus",r),d=Bt(e,"onBlur",r),f=Bt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};oE.resolve=VJ;oE.sort=XO;oE.flatten=qO;var xHe={};$O(xHe,{ClipboardTextSerializer:()=>JJ,Commands:()=>eee,Delete:()=>tee,Drop:()=>nee,Editable:()=>ree,FocusEvents:()=>aee,Keymap:()=>see,Paste:()=>oee,Tabindex:()=>lee,TextDirection:()=>cee,focusEventsPluginKey:()=>iee});var Qn=class QJ extends ZO{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new QJ(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},JJ=Qn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Er({key:new Si("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,s=Math.min(...a.map(d=>d.$from.pos)),o=Math.max(...a.map(d=>d.$to.pos)),c=WJ(n);return GJ(r,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),eee=Qn.create({name:"commands",addCommands(){return{...jJ}}}),tee=Qn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,o,c,u;if((u=(c=(o=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:o.filterTransaction)==null?void 0:c.call(o,t))!=null?u:t.getMeta("y-sync$"))return;const d=BJ(t.before,[t,...e]);KJ(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(b,y)=>{const v=y+b.nodeSize-2,x=m.oldRange.from<=y&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:y,to:v,newFrom:d.mapping.map(y),newTo:d.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((m,b)=>{var y,v;if(m instanceof Oo){const x=g.slice(b).map(m.from,-1),M=g.slice(b).map(m.to),S=g.invert().map(x,-1),A=g.invert().map(M),T=(y=d.doc.nodeAt(x-1))==null?void 0:y.marks.some(N=>N.eq(m.mark)),k=(v=d.doc.nodeAt(M))==null?void 0:v.marks.some(N=>N.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:S,to:A},newRange:{from:x,to:M},partial:!!(k||T),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),nee=Qn.create({name:"drop",addProseMirrorPlugins(){return[new Er({key:new Si("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),ree=Qn.create({name:"editable",addProseMirrorPlugins(){return[new Er({key:new Si("editable"),props:{editable:()=>this.editor.options.editable}})]}}),iee=new Si("focusEvents"),aee=Qn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Er({key:iee,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}}}})]}}),see=Qn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:o})=>{const{selection:c,doc:u}=o,{empty:d,$anchor:f}=c,{pos:g,parent:m}=f,b=f.parent.isTextblock&&g>0?o.doc.resolve(g-1):f,y=b.parent.type.spec.isolating,v=f.pos-f.parentOffset,x=y&&b.parent.childCount===1?v===f.pos:un.atStart(u).from===g;return!d||!m.type.isTextblock||m.textContent.length||!x||x&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.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 WO()||UJ()?a:i},addProseMirrorPlugins(){return[new Er({key:new Si("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:o}=e.selection,c=un.atStart(e.doc).from,u=un.atEnd(e.doc).to;if(a||!(s===c&&o===u)||!aE(n.doc))return;const g=n.tr,m=tE({state:n,transaction:g}),{commands:b}=new nE({editor:this.editor,state:m});if(b.clearNodes(),!!g.steps.length)return g}})]}}),oee=Qn.create({name:"paste",addProseMirrorPlugins(){return[new Er({key:new Si("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),lee=Qn.create({name:"tabindex",addProseMirrorPlugins(){return[new Er({key:new Si("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),cee=Qn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Um(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 Er({key:new Si("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),bHe=class Bp{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 Bp(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 Bp(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 Bp(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,s=this.pos+r+(a?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const c=new Bp(o,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Bp(o,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,s=Object.keys(n);for(let o=0;o<s.length;o+=1){const c=s[o];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(s=>{r&&i.length>0||(s.node.type.name===e&&a.every(c=>n[c]===s.node.attrs[c])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.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)}},yHe=`.ProseMirror {
  8108. position: relative;
  8109. }
  8110. .ProseMirror {
  8111. word-wrap: break-word;
  8112. white-space: pre-wrap;
  8113. white-space: break-spaces;
  8114. -webkit-font-variant-ligatures: none;
  8115. font-variant-ligatures: none;
  8116. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8117. }
  8118. .ProseMirror [contenteditable="false"] {
  8119. white-space: normal;
  8120. }
  8121. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8122. white-space: pre-wrap;
  8123. }
  8124. .ProseMirror pre {
  8125. white-space: pre-wrap;
  8126. }
  8127. img.ProseMirror-separator {
  8128. display: inline !important;
  8129. border: none !important;
  8130. margin: 0 !important;
  8131. width: 0 !important;
  8132. height: 0 !important;
  8133. }
  8134. .ProseMirror-gapcursor {
  8135. display: none;
  8136. pointer-events: none;
  8137. position: absolute;
  8138. margin: 0;
  8139. }
  8140. .ProseMirror-gapcursor:after {
  8141. content: "";
  8142. display: block;
  8143. position: absolute;
  8144. top: -2px;
  8145. width: 20px;
  8146. border-top: 1px solid black;
  8147. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8148. }
  8149. @keyframes ProseMirror-cursor-blink {
  8150. to {
  8151. visibility: hidden;
  8152. }
  8153. }
  8154. .ProseMirror-hideselection *::selection {
  8155. background: transparent;
  8156. }
  8157. .ProseMirror-hideselection *::-moz-selection {
  8158. background: transparent;
  8159. }
  8160. .ProseMirror-hideselection * {
  8161. caret-color: transparent;
  8162. }
  8163. .ProseMirror-focused .ProseMirror-gapcursor {
  8164. display: block;
  8165. }`;function vHe(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 _He=class extends oHe{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=IJ(e,this.options.autofocus);this.editorState=Xp.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=vHe(yHe,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=HJ(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(s=>!s.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?[ree,JJ.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),eee,aee,see,lee,nee,oee,tee,cee.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 oE(r,this)}createCommandManager(){this.commandManager=new nE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=aR(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=aR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new RJ(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 s=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),o=s?.getMeta("focus"),c=s?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:s}),c&&this.emit("blur",{editor:this,event:c.event,transaction:s}),!(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 qJ(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return I6e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return KO(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8166. `,textSerializers:n={}}=t||{};return P6e(this.state.doc,{blockSeparator:e,textSerializers:{...WJ(this.schema),...n}})}get isEmpty(){return aE(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 bHe(e,this)}get $doc(){return this.$pos(0)}};function zm(t){return new sE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Un(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,s=r[r.length-1],o=r[0];if(s){const c=o.search(/\S/),u=n.from+o.indexOf(s),d=u+s.length;if(YO(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const g=n.from+c+s.length;a.addMark(n.from+c,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function uee(t){return new sE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Un(t.getAttributes,void 0,r)||{},{tr:a}=e,s=n.from;let o=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=s+u;d>o?d=o:o=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,s+r[0].length-1),a.replaceWith(d,o,c)}else if(r[0]){const u=t.type.isInline?s:s-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(s),a.mapping.map(o))}a.scrollIntoView()},undoable:t.undoable})}function oR(t){return new sE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Un(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 Bm(t){return new sE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Un(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),c=s.doc.resolve(n.from).blockRange(),u=c&&TO(c,t.type,a);if(!u)return null;if(s.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:m}=t.editor.extensionManager,b=g||f.$to.parentOffset&&f.$from.marks();if(b){const y=b.filter(v=>m.includes(v.type.name));s.ensureMarks(y)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Md(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)},undoable:t.undoable})}var wHe=t=>"touches"in t,SHe=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=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.clientX-this.startX,c=s.clientY-this.startY;this.handleResize(o,c)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.touches[0];if(!o)return;const c=o.clientX-this.startX,u=o.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(s,o),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=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=s=>{s.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,wHe(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"),s=t.includes("left"),o=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:s&&(r=this.startWidth-e),o?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+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,s;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 o=t,c=e;return o<this.minSize.width&&(o=this.minSize.width,c=o/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,o=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&o>this.maxSize.width&&(o=this.maxSize.width,c=o/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&c>this.maxSize.height&&(c=this.maxSize.height,o=c*this.aspectRatio),{width:o,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 MHe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ht){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 EHe={};$O(EHe,{createAtomBlockMarkdownSpec:()=>AHe,createBlockMarkdownSpec:()=>THe,createInlineMarkdownSpec:()=>kHe,parseAttributes:()=>QO,parseIndentedBlocks:()=>lR,renderNestedMarkdownContent:()=>eL,serializeAttributes:()=>JO});function QO(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 s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,u,d])=>{var f;const g=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),m=n[g];m&&(e[u]=m.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function JO(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 AHe(t){const{nodeName:e,name:n,parseAttributes:r=QO,serializeAttributes:i=JO,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:o}=t,c=n||e,u=d=>{if(!o)return d;const f={};return o.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...a,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\s|$)`,"m"),m=(f=d.match(g))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,g){const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=d.match(m);if(!b)return;const y=b[1]||"",v=r(y);if(!s.find(M=>!(M in v)))return{type:e,raw:b[0],attributes:v}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),m=g?` {${g}}`:"";return`:::${c}${m} :::`}}}function THe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=QO,serializeAttributes:a=JO,defaultAttributes:s={},content:o="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const g={};return c.forEach(m=>{m in f&&(g[m]=f[m])}),g};return{parseMarkdown:(f,g)=>{let m;if(r){const y=r(f);m=typeof y=="string"?[{type:"text",text:y}]:y}else o==="block"?m=g.parseChildren(f.tokens||[]):m=g.parseInline(f.tokens||[]);const b={...s,...f.attributes};return g.createNode(e,b,m)},markdownTokenizer:{name:e,level:"block",start(f){var g;const m=new RegExp(`^:::${u}`,"m"),b=(g=f.match(m))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(f,g,m){var b;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=f.match(y);if(!v)return;const[x,M=""]=v,S=i(M);let A=1;const T=x.length;let k="";const N=/^:::([\w-]*)(\s.*)?/gm,I=f.slice(T);for(N.lastIndex=0;;){const C=N.exec(I);if(C===null)break;const D=C.index,F=C[1];if(!((b=C[2])!=null&&b.endsWith(":::"))){if(F)A+=1;else if(A-=1,A===0){const O=I.slice(0,D);k=O.trim();const q=f.slice(0,T+D+C[0].length);let R=[];if(k)if(o==="block")for(R=m.blockTokens(O),R.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=m.inlineTokens(W.text))});R.length>0;){const W=R[R.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))R.pop();else break}else R=m.inlineTokens(k);return{type:e,raw:q,attributes:S,content:k,tokens:R}}}}}},renderMarkdown:(f,g)=>{const m=d(f.attrs||{}),b=a(m),y=b?` {${b}}`:"",v=g.renderChildren(f.content||[],`
  8167. `);return`:::${u}${y}
  8168. ${v}
  8169. :::`}}}function CHe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,s]=r;e[i]=a||s,r=n.exec(t)}return e}function NHe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function kHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=CHe,serializeAttributes:a=NHe,defaultAttributes:s={},selfClosing:o=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const m={};return c.forEach(b=>{b in g&&(m[b]=g[b])}),m},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,m)=>{const b={...s,...g.attributes};if(o)return m.createNode(e,b);const y=r?r(g):g.content||"";return y?m.createNode(e,b,[m.createTextNode(y)]):m.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const m=o?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),b=g.match(m),y=b?.index;return y!==void 0?y:-1},tokenize(g,m,b){const y=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),v=g.match(y);if(!v)return;let x="",M="";if(o){const[,A]=v;M=A}else{const[,A,T]=v;M=A,x=T||""}const S=i(M.trim());return{type:e,raw:v[0],content:x.trim(),attributes:S}}},renderMarkdown:g=>{let m="";r?m=r(g):g.content&&g.content.length>0&&(m=g.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const b=d(g.attrs||{}),y=a(b),v=y?` ${y}`:"";return o?`[${u}${v}]`:`[${u}${v}]${m}[/${u}]`}}}function lR(t,e,n){var r,i,a,s;const o=t.split(`
  8170. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<o.length;){const g=o[d],m=g.match(e.itemPattern);if(!m){if(c.length>0)break;if(g.trim()===""){d+=1,u=`${u}${g}
  8171. `;continue}else return}const b=e.extractItemData(m),{indentLevel:y,mainContent:v}=b;u=`${u}${g}
  8172. `;const x=[v];for(d+=1;d<o.length;){const T=o[d];if(T.trim()===""){const N=o.slice(d+1).findIndex(D=>D.trim()!=="");if(N===-1)break;if((((i=(r=o[d+1+N].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){x.push(T),u=`${u}${T}
  8173. `,d+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>y)x.push(T),u=`${u}${T}
  8174. `,d+=1;else break}let M;const S=x.slice(1);if(S.length>0){const T=S.map(k=>k.slice(y+f)).join(`
  8175. `);T.trim()&&(e.customNestedParser?M=e.customNestedParser(T):M=n.blockTokens(T))}const A=e.createToken(b,M);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function eL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,o=e.renderChildren([a]),c=[`${i}${o}`];return s&&s.length>0&&s.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
  8176. `).map(g=>g?e.indent(g):"").join(`
  8177. `);c.push(f)}}),c.join(`
  8178. `)}function PHe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((o,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+o.nodeSize;let f=null;if(o.marks.forEach(m=>{if(m!==s)return!1;f=m}),!f)return;let g=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(g=!0)}),g){const m=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,m)}}),a.docChanged&&e.view.dispatch(a)}var Ja=class dee extends ZO{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new dee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function cf(t){return new hHe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Un(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,o=r[r.length-1],c=r[0];let u=n.to;if(o){const d=c.search(/\S/),f=n.from+c.indexOf(o),g=f+o.length;if(YO(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(v=>v===t.type&&v!==b.mark.type)).filter(b=>b.to>f).length)return null;g<n.to&&s.delete(g,n.to),f>n.from&&s.delete(n.from+d,f),u=n.from+d+o.length,s.addMark(n.from+d,u,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var QN,z7;function RHe(){return z7||(z7=1,QN=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 s=a[i];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),QN}var DHe=RHe();const jHe=fo(DHe);var OHe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},LHe=({contentComponent:t})=>{const e=CR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return l.jsx(l.Fragment,{children:Object.values(e)})};function IHe(){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]:cse.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 FHe=class extends mr.Component{constructor(t){var e;super(t),this.editorContentRef=mr.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=IHe(),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 l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:OHe(e,this.editorContentRef),...n}),t?.contentComponent&&l.jsx(LHe,{contentComponent:t.contentComponent})]})}},UHe=E.forwardRef((t,e)=>{const n=mr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mr.createElement(FHe,{key:n,innerRef:e,...t})}),zHe=mr.memo(UHe),BHe=typeof window<"u"?E.useLayoutEffect:E.useEffect,HHe=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 $He(t){var e;const[n]=E.useState(()=>new HHe(t.editor)),r=cW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:jHe);return BHe(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var VHe=!1,cR=typeof window>"u",GHe=cR||!!(typeof window<"u"&&window.next),WHe=class hee{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?cR||GHe?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 _He(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 s;return i===((s=n.extensions)==null?void 0:s[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?hee.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 qHe(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new WHe(n)),i=CR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),$He({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var KHe=E.createContext({editor:null});KHe.Consumer;var XHe=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),YHe=()=>E.useContext(XHe);mr.forwardRef((t,e)=>{const{onDragStart:n}=YHe(),r=t.as||"div";return l.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});mr.createContext({markViewContentRef:()=>{}});var eS=(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]},ZHe=/^\s*>\s$/,QHe=Ja.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return eS("blockquote",{...Dr(this.options.HTMLAttributes,t),children:eS("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 o=e.renderChildren([i]).split(`
  8179. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(o.join(`
  8180. `))}),r.join(`
  8181. ${n}
  8182. `)},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[Bm({find:ZHe,type:this.type})]}}),JHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,e$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,t$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,n$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,r$e=Ad.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 eS("strong",{...Dr(this.options.HTMLAttributes,t),children:eS("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[zm({find:JHe,type:this.type}),zm({find:t$e,type:this.type})]},addPasteRules(){return[cf({find:e$e,type:this.type}),cf({find:n$e,type:this.type})]}}),i$e=/(^|[^`])`([^`]+)`(?!`)$/,a$e=/(^|[^`])`([^`]+)`(?!`)/g,s$e=Ad.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Dr(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[zm({find:i$e,type:this.type})]},addPasteRules(){return[cf({find:a$e,type:this.type})]}}),JN=4,o$e=/^```([a-z]+)?[\s\n]$/,l$e=/^~~~([a-z]+)?[\s\n]$/,c$e=Ja.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:JN,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(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Dr(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(`
  8183. `):r=`\`\`\`${i}
  8184. \`\`\``,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:JN,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;if(a.parent.type!==this.type)return!1;const o=" ".repeat(n);return s?t.commands.insertContent(o):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,m=r.doc.textBetween(u,d,`
  8185. `,`
  8186. `).split(`
  8187. `).map(b=>o+b).join(`
  8188. `);return c.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:JN,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:o})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),m=r.doc.textBetween(d,f,`
  8189. `,`
  8190. `).split(`
  8191. `);let b=0,y=0;const v=u-d;for(let k=0;k<m.length;k+=1){if(y+m[k].length>=v){b=k;break}y+=m[k].length+1}const M=((c=m[b].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<b;k+=1)A+=m[k].length+1;return o.delete(A,A+S),u-A<=S&&o.setSelection(Kt.create(o.doc,A)),!0}):t.commands.command(({tr:o})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,u,`
  8192. `,`
  8193. `).split(`
  8194. `).map(m=>{var b;const y=((b=m.match(/^ */))==null?void 0:b[0])||"",v=Math.min(y.length,n);return m.slice(v)}).join(`
  8195. `);return o.replaceWith(c,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
  8196. `);return!a||!s?!1:t.chain().command(({tr:o})=>(o.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 o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:u})=>(u.setSelection(un.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[oR({find:o$e,type:this.type,getAttributes:t=>({language:t[1]})}),oR({find:l$e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Er({key:new Si("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:s,schema:o}=t.state,c=o.text(n.replace(/\r\n?/g,`
  8197. `));return s.replaceSelectionWith(this.type.create({language:a},c)),s.selection.$from.parent.type!==this.type&&s.setSelection(Kt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),u$e=Ja.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8198. `):""}),d$e=Ja.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",Dr(this.options.HTMLAttributes,t)]},renderText(){return`
  8199. `},renderMarkdown:()=>`
  8200. `,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:s}=this.options,{splittableMarks:o}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&s){const f=c.filter(g=>o.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),h$e=Ja.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]}`,Dr(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=>oR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),f$e=Ja.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Dr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!MHe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return XJ(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:s,dispatch:o})=>{if(o){const{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Kt.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Ht.create(s.doc,c.pos)):s.setSelection(Kt.create(s.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(s.insert(u,f),s.setSelection(Kt.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[uee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),p$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,m$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,g$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,x$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,b$e=Ad.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",Dr(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[zm({find:p$e,type:this.type}),zm({find:g$e,type:this.type})]},addPasteRules(){return[cf({find:m$e,type:this.type}),cf({find:x$e,type:this.type})]}});const y$e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",v$e="ελ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",uR="numeric",dR="ascii",hR="alpha",i0="asciinumeric",$x="alphanumeric",fR="domain",fee="emoji",_$e="scheme",w$e="slashscheme",ek="whitespace";function S$e(t,e){return t in e||(e[t]=[]),e[t]}function _h(t,e,n){e[uR]&&(e[i0]=!0,e[$x]=!0),e[dR]&&(e[i0]=!0,e[hR]=!0),e[i0]&&(e[$x]=!0),e[hR]&&(e[$x]=!0),e[$x]&&(e[fR]=!0),e[fee]&&(e[fR]=!0);for(const r in e){const i=S$e(r,n);i.indexOf(t)<0&&i.push(t)}}function M$e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ga(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ga.groups={};Ga.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||Ga.groups;let i;return e&&e.j?i=e:(i=new Ga(e),n&&r&&_h(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 s=0;s<a-1;s++)i=i.tt(t[s]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||Ga.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let s,o=i.go(t);if(o?(s=new Ga,Object.assign(s.j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new Ga,a){if(r)if(s.t&&typeof s.t=="string"){const c=Object.assign(M$e(s.t,r),n);_h(a,c,r)}else n&&_h(a,n,r);s.t=a}return i.j[t]=s,s}};const sn=(t,e,n,r,i)=>t.ta(e,n,r,i),Nr=(t,e,n,r,i)=>t.tr(e,n,r,i),B7=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),sc="WORD",pR="UWORD",pee="ASCIINUMERICAL",mee="ALPHANUMERICAL",ob="LOCALHOST",mR="TLD",gR="UTLD",b1="SCHEME",Hp="SLASH_SCHEME",tL="NUM",xR="WS",nL="NL",a0="OPENBRACE",s0="CLOSEBRACE",tS="OPENBRACKET",nS="CLOSEBRACKET",rS="OPENPAREN",iS="CLOSEPAREN",aS="OPENANGLEBRACKET",sS="CLOSEANGLEBRACKET",oS="FULLWIDTHLEFTPAREN",lS="FULLWIDTHRIGHTPAREN",cS="LEFTCORNERBRACKET",uS="RIGHTCORNERBRACKET",dS="LEFTWHITECORNERBRACKET",hS="RIGHTWHITECORNERBRACKET",fS="FULLWIDTHLESSTHAN",pS="FULLWIDTHGREATERTHAN",mS="AMPERSAND",gS="APOSTROPHE",xS="ASTERISK",Du="AT",bS="BACKSLASH",yS="BACKTICK",vS="CARET",Uu="COLON",rL="COMMA",_S="DOLLAR",Qo="DOT",wS="EQUALS",iL="EXCLAMATION",Gs="HYPHEN",o0="PERCENT",SS="PIPE",MS="PLUS",ES="POUND",l0="QUERY",aL="QUOTE",gee="FULLWIDTHMIDDLEDOT",sL="SEMI",Jo="SLASH",c0="TILDE",AS="UNDERSCORE",xee="EMOJI",TS="SYM";var bee=Object.freeze({__proto__:null,ALPHANUMERICAL:mee,AMPERSAND:mS,APOSTROPHE:gS,ASCIINUMERICAL:pee,ASTERISK:xS,AT:Du,BACKSLASH:bS,BACKTICK:yS,CARET:vS,CLOSEANGLEBRACKET:sS,CLOSEBRACE:s0,CLOSEBRACKET:nS,CLOSEPAREN:iS,COLON:Uu,COMMA:rL,DOLLAR:_S,DOT:Qo,EMOJI:xee,EQUALS:wS,EXCLAMATION:iL,FULLWIDTHGREATERTHAN:pS,FULLWIDTHLEFTPAREN:oS,FULLWIDTHLESSTHAN:fS,FULLWIDTHMIDDLEDOT:gee,FULLWIDTHRIGHTPAREN:lS,HYPHEN:Gs,LEFTCORNERBRACKET:cS,LEFTWHITECORNERBRACKET:dS,LOCALHOST:ob,NL:nL,NUM:tL,OPENANGLEBRACKET:aS,OPENBRACE:a0,OPENBRACKET:tS,OPENPAREN:rS,PERCENT:o0,PIPE:SS,PLUS:MS,POUND:ES,QUERY:l0,QUOTE:aL,RIGHTCORNERBRACKET:uS,RIGHTWHITECORNERBRACKET:hS,SCHEME:b1,SEMI:sL,SLASH:Jo,SLASH_SCHEME:Hp,SYM:TS,TILDE:c0,TLD:mR,UNDERSCORE:AS,UTLD:gR,UWORD:pR,WORD:sc,WS:xR});const nc=/[a-z]/,kx=new RegExp("\\p{L}","u"),tk=new RegExp("\\p{Emoji}","u"),rc=/\d/,nk=/\s/,H7="\r",rk=`
  8201. `,E$e="️",A$e="‍",ik="";let H_=null,$_=null;function T$e(t=[]){const e={};Ga.groups=e;const n=new Ga;H_==null&&(H_=$7(y$e)),$_==null&&($_=$7(v$e)),gt(n,"'",gS),gt(n,"{",a0),gt(n,"}",s0),gt(n,"[",tS),gt(n,"]",nS),gt(n,"(",rS),gt(n,")",iS),gt(n,"<",aS),gt(n,">",sS),gt(n,"(",oS),gt(n,")",lS),gt(n,"「",cS),gt(n,"」",uS),gt(n,"『",dS),gt(n,"』",hS),gt(n,"<",fS),gt(n,">",pS),gt(n,"&",mS),gt(n,"*",xS),gt(n,"@",Du),gt(n,"`",yS),gt(n,"^",vS),gt(n,":",Uu),gt(n,",",rL),gt(n,"$",_S),gt(n,".",Qo),gt(n,"=",wS),gt(n,"!",iL),gt(n,"-",Gs),gt(n,"%",o0),gt(n,"|",SS),gt(n,"+",MS),gt(n,"#",ES),gt(n,"?",l0),gt(n,'"',aL),gt(n,"/",Jo),gt(n,";",sL),gt(n,"~",c0),gt(n,"_",AS),gt(n,"\\",bS),gt(n,"・",gee);const r=Nr(n,rc,tL,{[uR]:!0});Nr(r,rc,r);const i=Nr(r,nc,pee,{[i0]:!0}),a=Nr(r,kx,mee,{[$x]:!0}),s=Nr(n,nc,sc,{[dR]:!0});Nr(s,rc,i),Nr(s,nc,s),Nr(i,rc,i),Nr(i,nc,i);const o=Nr(n,kx,pR,{[hR]:!0});Nr(o,nc),Nr(o,rc,a),Nr(o,kx,o),Nr(a,rc,a),Nr(a,nc),Nr(a,kx,a);const c=gt(n,rk,nL,{[ek]:!0}),u=gt(n,H7,xR,{[ek]:!0}),d=Nr(n,nk,xR,{[ek]:!0});gt(n,ik,d),gt(u,rk,c),gt(u,ik,d),Nr(u,nk,d),gt(d,H7),gt(d,rk),Nr(d,nk,d),gt(d,ik,d);const f=Nr(n,tk,xee,{[fee]:!0});gt(f,"#"),Nr(f,tk,f),gt(f,E$e,f);const g=gt(f,A$e);gt(g,"#"),Nr(g,tk,f);const m=[[nc,s],[rc,i]],b=[[nc,null],[kx,o],[rc,a]];for(let y=0;y<H_.length;y++)Au(n,H_[y],mR,sc,m);for(let y=0;y<$_.length;y++)Au(n,$_[y],gR,pR,b);_h(mR,{tld:!0,ascii:!0},e),_h(gR,{utld:!0,alpha:!0},e),Au(n,"file",b1,sc,m),Au(n,"mailto",b1,sc,m),Au(n,"http",Hp,sc,m),Au(n,"https",Hp,sc,m),Au(n,"ftp",Hp,sc,m),Au(n,"ftps",Hp,sc,m),_h(b1,{scheme:!0,ascii:!0},e),_h(Hp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,v)=>y[0]>v[0]?1:-1);for(let y=0;y<t.length;y++){const v=t[y][0],M=t[y][1]?{[_$e]:!0}:{[w$e]:!0};v.indexOf("-")>=0?M[fR]=!0:nc.test(v)?rc.test(v)?M[i0]=!0:M[dR]=!0:M[uR]=!0,B7(n,v,v,M)}return B7(n,"localhost",ob,{ascii:!0}),n.jd=new Ga(TS),{start:n,tokens:Object.assign({groups:e},bee)}}function yee(t,e){const n=C$e(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let a=0,s=0;for(;s<r;){let o=t,c=null,u=0,d=null,f=-1,g=-1;for(;s<r&&(c=o.go(n[s]));)o=c,o.accepts()?(f=0,g=0,d=o):f>=0&&(f+=n[s].length,g++),u+=n[s].length,a+=n[s].length,s++;a-=f,s-=g,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function C$e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,s=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Au(t,e,n,r,i){let a;const s=e.length;for(let o=0;o<s-1;o++){const c=e[o];t.j[c]?a=t.j[c]:(a=new Ga(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Ga(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function $7(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 s=parseInt(t.substring(r,r+a),10);s>0;s--)n.pop();r+=a}else n.push(t[r]),r++}return e}const lb={defaultProtocol:"http",events:null,format:V7,formatHref:V7,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function oL(t,e=null){let n=Object.assign({},lb);t&&(n=Object.assign(n,t instanceof oL?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}oL.prototype={o:lb,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]:lb[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 V7(t){return t}function vee(t,e){this.t="token",this.v=t,this.tk=e}vee.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=lb.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),s={},o=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 s.href=r,o&&(s.class=o),c&&(s.target=c),u&&(s.rel=u),d&&Object.assign(s,d),{tagName:i,attributes:s,content:a,eventListeners:f}}};function lE(t,e){class n extends vee{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 G7=lE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),W7=lE("text"),N$e=lE("nl"),V_=lE("url",{isLink:!0,toHref(t=lb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ob&&t[1].t===Uu}}),Hs=t=>new Ga(t);function k$e({groups:t}){const e=t.domain.concat([mS,xS,Du,bS,yS,vS,_S,wS,Gs,tL,o0,SS,MS,ES,Jo,TS,c0,AS]),n=[gS,Uu,rL,Qo,iL,o0,l0,aL,sL,aS,sS,a0,s0,nS,tS,rS,iS,oS,lS,cS,uS,dS,hS,fS,pS],r=[mS,gS,xS,bS,yS,vS,_S,wS,Gs,a0,s0,o0,SS,MS,ES,l0,Jo,TS,c0,AS],i=Hs(),a=gt(i,c0);sn(a,r,a),sn(a,t.domain,a);const s=Hs(),o=Hs(),c=Hs();sn(i,t.domain,s),sn(i,t.scheme,o),sn(i,t.slashscheme,c),sn(s,r,a),sn(s,t.domain,s);const u=gt(s,Du);gt(a,Du,u),gt(o,Du,u),gt(c,Du,u);const d=gt(a,Qo);sn(d,r,a),sn(d,t.domain,a);const f=Hs();sn(u,t.domain,f),sn(f,t.domain,f);const g=gt(f,Qo);sn(g,t.domain,f);const m=Hs(G7);sn(g,t.tld,m),sn(g,t.utld,m),gt(u,ob,m);const b=gt(f,Gs);gt(b,Gs,b),sn(b,t.domain,f),sn(m,t.domain,f),gt(m,Qo,g),gt(m,Gs,b);const y=gt(m,Uu);sn(y,t.numeric,G7);const v=gt(s,Gs),x=gt(s,Qo);gt(v,Gs,v),sn(v,t.domain,s),sn(x,r,a),sn(x,t.domain,s);const M=Hs(V_);sn(x,t.tld,M),sn(x,t.utld,M),sn(M,t.domain,s),sn(M,r,a),gt(M,Qo,x),gt(M,Gs,v),gt(M,Du,u);const S=gt(M,Uu),A=Hs(V_);sn(S,t.numeric,A);const T=Hs(V_),k=Hs();sn(T,e,T),sn(T,n,k),sn(k,e,T),sn(k,n,k),gt(M,Jo,T),gt(A,Jo,T);const N=gt(o,Uu),I=gt(c,Uu),C=gt(I,Jo),D=gt(C,Jo);sn(o,t.domain,s),gt(o,Qo,x),gt(o,Gs,v),sn(c,t.domain,s),gt(c,Qo,x),gt(c,Gs,v),sn(N,t.domain,T),gt(N,Jo,T),gt(N,l0,T),sn(D,t.domain,T),sn(D,e,T),gt(D,Jo,T);const F=[[a0,s0],[tS,nS],[rS,iS],[aS,sS],[oS,lS],[cS,uS],[dS,hS],[fS,pS]];for(let O=0;O<F.length;O++){const[q,R]=F[O],W=gt(T,q);gt(k,q,W),gt(W,R,T);const K=Hs(V_);sn(W,e,K);const G=Hs();sn(W,n),sn(K,e,K),sn(K,n,G),sn(G,e,K),sn(G,n,G),gt(K,R,T),gt(G,R,T)}return gt(i,ob,M),gt(i,nL,N$e),{start:i,tokens:bee}}function P$e(t,e,n){let r=n.length,i=0,a=[],s=[];for(;i<r;){let o=t,c=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(c=o.go(n[i].t));)s.push(n[i++]);for(;i<r&&(u=c||o.go(n[i].t));)c=null,o=u,o.accepts()?(g=0,f=o):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(s.push(n[i]),i++);else{s.length>0&&(a.push(ak(W7,e,s)),s=[]),i-=g,d-=g;const m=f.t,b=n.slice(i-d,i);a.push(ak(m,e,b))}}return s.length>0&&a.push(ak(W7,e,s)),a}function ak(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 R$e=typeof console<"u"&&console&&console.warn||(()=>{}),D$e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",cr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function j$e(){return Ga.groups={},cr.scanner=null,cr.parser=null,cr.tokenQueue=[],cr.pluginQueue=[],cr.customSchemes=[],cr.initialized=!1,cr}function q7(t,e=!1){if(cr.initialized&&R$e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${D$e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8202. 1. Must only contain digits, lowercase ASCII letters or "-"
  8203. 2. Cannot start or end with "-"
  8204. 3. "-" cannot repeat`);cr.customSchemes.push([t,e])}function O$e(){cr.scanner=T$e(cr.customSchemes);for(let t=0;t<cr.tokenQueue.length;t++)cr.tokenQueue[t][1]({scanner:cr.scanner});cr.parser=k$e(cr.scanner.tokens);for(let t=0;t<cr.pluginQueue.length;t++)cr.pluginQueue[t][1]({scanner:cr.scanner,parser:cr.parser});return cr.initialized=!0,cr}function lL(t){return cr.initialized||O$e(),P$e(cr.parser.start,t,yee(cr.scanner.start,t))}lL.scan=yee;function _ee(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 oL(n),i=lL(t),a=[];for(let s=0;s<i.length;s++){const o=i[s];o.isLink&&(!e||o.t===e)&&r.check(o)&&a.push(o.toFormattedObject(r))}return a}var cL="[\0-   ᠎ -\u2029  ]",L$e=new RegExp(cL),I$e=new RegExp(`${cL}$`),F$e=new RegExp(cL,"g");function U$e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function z$e(t){return new Er({key:new Si("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:s}=r,o=BJ(n.doc,[...e]);if(KJ(o).forEach(({newRange:u})=>{const d=E6e(r.doc,u,m=>m.isTextblock);let f,g;if(d.length>1)f=d[0],g=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!I$e.test(m))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const m=g.split(L$e).filter(Boolean);if(m.length<=0)return!1;const b=m[m.length-1],y=f.pos+g.lastIndexOf(b);if(!b)return!1;const v=lL(b).map(x=>x.toObject(t.defaultProtocol));if(!U$e(v))return!1;v.filter(x=>x.isLink).map(x=>({...x,from:y+x.start+1,to:y+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{YO(x.from,x.to,r.doc).some(M=>M.mark.type===t.type)||s.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!s.steps.length)return s}})}function B$e(t){return new Er({key:new Si("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;s=f.find(g=>g.nodeName==="A")}if(!s)return!1;const o=qJ(e.state,t.type.name),c=(i=s?.href)!=null?i:o.href,u=(a=s?.target)!=null?a:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&c?(window.open(c,u),!0):!1}}})}function H$e(t){return new Er({key:new Si("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:s}=a,{empty:o}=s;if(o)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=_ee(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 eh(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(F$e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var wee=Ad.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"){q7(t);return}q7(t.scheme,t.optionalSlashes)})},onDestroy(){j$e()},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)=>!!eh(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=>!!eh(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=>!!eh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Dr(this.options.HTMLAttributes,t),0]:["a",Dr(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=>!!eh(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=>!!eh(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[cf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=_ee(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!eh(s,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(z$e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!eh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(B$e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(H$e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),$$e=wee,V$e=Object.defineProperty,G$e=(t,e)=>{for(var n in e)V$e(t,n,{get:e[n],enumerable:!0})},W$e="listItem",K7="textStyle",X7=/^\s*([-+*])\s$/,See=Ja.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",Dr(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,`
  8205. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(W$e,this.editor.getAttributes(K7)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Bm({find:X7,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Bm({find:X7,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(K7),editor:this.editor})),[t]}}),Mee=Ja.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Dr(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 s=t.tokens.slice(1),o=e.parseChildren(s);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>eL(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)}}}),q$e={};G$e(q$e,{findListItemPos:()=>Jb,getNextListDepth:()=>uL,handleBackspace:()=>bR,handleDelete:()=>yR,hasListBefore:()=>Eee,hasListItemAfter:()=>K$e,hasListItemBefore:()=>Aee,listItemHasSubList:()=>Tee,nextListIsDeeper:()=>Cee,nextListIsHigher:()=>Nee});var Jb=(t,e)=>{const{$from:n}=e.selection,r=ii(t,e.schema);let i=null,a=n.depth,s=n.pos,o=null;for(;a>0&&o===null;)i=n.node(a),i.type===r?o=a:(a-=1,s-=1);return o===null?null:{$pos:e.doc.resolve(s),depth:o}},uL=(t,e)=>{const n=Jb(t,e);if(!n)return!1;const[,r]=O6e(e,t,n.$pos.pos+4);return r},Eee=(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))},Aee=(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)},Tee=(t,e,n)=>{if(!n)return!1;const r=ii(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},bR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!gd(t.state,e)&&Eee(t.state,e,n)){const{$anchor:o}=t.state.selection,c=t.state.doc.resolve(o.before()-1),u=[];c.node().descendants((g,m)=>{g.type.name===e&&u.push({node:g,pos:m})});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:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!gd(t.state,e)||!U6e(t.state))return!1;const r=Jb(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=Tee(e,t.state,a);return Aee(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Cee=(t,e)=>{const n=uL(t,e),r=Jb(t,e);return!r||!n?!1:n>r.depth},Nee=(t,e)=>{const n=uL(t,e),r=Jb(t,e);return!r||!n?!1:n<r.depth},yR=(t,e)=>{if(!gd(t.state,e)||!F6e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Cee(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Nee(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},K$e=(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)},kee=Qn.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&&yR(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&&yR(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&&bR(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&&bR(t,n,r)&&(e=!0)}),e}}}}),Y7=/^(\s*)(\d+)\.\s+(.*)$/,X$e=/^\s/;function Y$e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(Y7);if(!a)break;const[,s,o,c]=a,u=s.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const m=t[f];if(m.match(Y7))break;if(m.trim()==="")g.push(m),d+=`
  8206. `,f+=1;else if(m.match(X$e))g.push(m),d+=`
  8207. ${m.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(o,10),content:d.trim(),raw:g.join(`
  8208. `)}),r=f,n=f}return[e,r]}function Pee(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const o=s.content.split(`
  8209. `),c=((r=o[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=o.slice(1).join(`
  8210. `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let f=a+1;const g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const m=Math.min(...g.map(y=>y.indent)),b=Pee(g,m,n);u.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(y=>y.raw).join(`
  8211. `)})}i.push({type:"list_item",raw:s.raw,tokens:u}),a=f}else a+=1}return i}function Z$e(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 Q$e="listItem",Z7="textStyle",Q7=/^(\d+)\.\s$/,Ree=Ja.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",Dr(this.options.HTMLAttributes,n),0]:["ol",Dr(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?Z$e(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,`
  8212. `):"",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(`
  8213. `),[a,s]=Y$e(i);if(a.length===0)return;const o=Pee(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,s).join(`
  8214. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Q$e,this.editor.getAttributes(Z7)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Bm({find:Q7,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=Bm({find:Q7,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Z7)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),J$e=/^\s*(\[([( |x])?\])\s$/,eVe=Ja.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",Dr(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 eL(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"),s=document.createElement("span"),o=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,g;o.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const m=n();if(typeof m!="number")return!1;const b=g.doc.nodeAt(m);return g.setNodeMarkup(m,void 0,{...b?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),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,o.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Bm({find:J$e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),tVe=Ja.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",Dr(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,`
  8215. `):"",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 s=lR(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,c)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:c}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=lR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),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()}}});Qn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(See.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Mee.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(kee.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Ree.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(eVe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(tVe.configure(this.options.taskList)),t}});var nVe=Ja.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Dr(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()}}}),rVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,iVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,aVe=Ad.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",Dr(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[zm({find:rVe,type:this.type})]},addPasteRules(){return[cf({find:iVe,type:this.type})]}}),sVe=Ja.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Dee=Ad.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",Dr(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()}}}),oVe=Dee;function lVe(t={}){return new Er({view(e){return new cVe(e,t)}})}class cVe{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=s=>{this[i](s)};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(),s=a.width/i.offsetWidth,o=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let b=m.getBoundingClientRect(),y=f?b.bottom:b.top;f&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*o;r={left:b.left,right:b.right,top:y-v,bottom:y+v}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*s;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,m=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,d=f.top-c.scrollTop*m}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-d)/o+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/o+"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 s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=DQ(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Pr extends un{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Pr.valid(r)?new Pr(r):un.near(r)}content(){return kt.empty}eq(e){return e instanceof Pr&&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 Pr(e.resolve(n.pos))}getBookmark(){return new dL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!uVe(e)||!dVe(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&&Pr.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let c=e.doc.resolve(i);if(Pr.valid(c))return c}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!Ht.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let o=e.doc.resolve(i);if(Pr.valid(o))return o}return null}}}Pr.prototype.visible=!1;Pr.findFrom=Pr.findGapCursorFrom;un.jsonID("gapcursor",Pr);class dL{constructor(e){this.pos=e}map(e){return new dL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Pr.valid(n)?new Pr(n):un.near(n)}}function jee(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function uVe(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||jee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function dVe(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||jee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function hVe(){return new Er({props:{decorations:gVe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Pr.valid(n)?new Pr(n):null},handleClick:pVe,handleKeyDown:fVe,handleDOMEvents:{beforeinput:mVe}}})}const fVe=DJ({ArrowLeft:G_("horiz",-1),ArrowRight:G_("horiz",1),ArrowUp:G_("vert",-1),ArrowDown:G_("vert",1)});function G_(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,o=e>0?s.$to:s.$from,c=s.empty;if(s instanceof Kt){if(!a.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=Pr.findGapCursorFrom(o,e,c);return u?(i&&i(r.tr.setSelection(new Pr(u))),!0):!1}}function pVe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Pr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ht.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Pr(r))),!0)}function mVe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Pr))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=pt.empty;for(let s=r.length-1;s>=0;s--)i=pt.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new kt(i,0,0));return a.setSelection(Kt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function gVe(t){if(!(t.selection instanceof Pr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",yr.create(t.doc,[Ea.widget(t.selection.head,e,{key:"gapcursor"})])}var CS=200,Fi=function(){};Fi.prototype.append=function(e){return e.length?(e=Fi.from(e),!this.length&&e||e.length<CS&&this.leafAppend(e)||this.length<CS&&e.leafPrepend(this)||this.appendInner(e)):this};Fi.prototype.prepend=function(e){return e.length?Fi.from(e).append(this):this};Fi.prototype.appendInner=function(e){return new xVe(this,e)};Fi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Fi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Fi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Fi.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)};Fi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,s){return i.push(e(a,s))},n,r),i};Fi.from=function(e){return e instanceof Fi?e:e&&e.length?new Oee(e):Fi.empty};var Oee=(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,s,o){for(var c=a;c<s;c++)if(i(this.values[c],o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,o){for(var c=a-1;c>=s;c--)if(i(this.values[c],o+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=CS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=CS)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})(Fi);Fi.empty=new Oee([]);var xVe=(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,s){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(r,Math.min(i,o),a,s)===!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})(Fi);const bVe=500;class Po{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 s=e.tr,o,c,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new el(f.map));let m=f.step.map(i.slice(a)),b;m&&s.maybeStep(m).doc&&(b=s.mapping.maps[s.mapping.maps.length-1],u.push(new el(b,void 0,void 0,u.length+d.length))),a--,b&&i.appendMap(b,a)}else s.maybeStep(f.step);if(f.selection)return o=i?f.selection.map(i.slice(a)):f.selection,c=new Po(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:s,selection:o}}addTransform(e,n,r,i){let a=[],s=this.eventCount,o=this.items,c=!i&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new el(e.mapping.maps[d],f,n),m;(m=c&&c.merge(g))&&(g=m,d?a.pop():o=o.slice(0,o.length-1)),a.push(g),n&&(s++,n=void 0),i||(c=g)}let u=s-r.depth;return u>vVe&&(o=yVe(o,u),s-=u),new Po(o.append(a),s)}remapping(e,n){let r=new tb;return this.items.forEach((i,a)=>{let s=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new Po(this.items.append(e.map(n=>new el(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let c=n;this.items.forEach(g=>{let m=a.getMirror(--c);if(m==null)return;s=Math.min(s,m);let b=a.maps[m];if(g.step){let y=e.steps[m].invert(e.docs[m]),v=g.selection&&g.selection.map(a.slice(c+1,m));v&&o++,r.push(new el(b,y,v))}else r.push(new el(b))},i);let u=[];for(let g=n;g<s;g++)u.push(new el(a.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Po(d,o);return f.emptyItemCount()>bVe&&(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((s,o)=>{if(o>=e)i.push(s),s.selection&&a++;else if(s.step){let c=s.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=s.selection&&s.selection.map(n.slice(r));d&&a++;let f=new el(u.invert(),c,d),g,m=i.length-1;(g=i.length&&i[m].merge(f))?i[m]=g:i.push(f)}}else s.map&&r--},this.items.length,0),new Po(Fi.from(i.reverse()),a)}}Po.empty=new Po(Fi.empty,0);function yVe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class el{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 el(n.getMap().invert(),n,this.selection)}}}class ju{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const vVe=20;function _Ve(t,e,n,r){let i=n.getMeta(Lh),a;if(i)return i.historyState;n.getMeta(MVe)&&(t=new ju(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Lh))return s.getMeta(Lh).redo?new ju(t.done.addTransform(n,void 0,r,y1(e)),t.undone,J7(n.mapping.maps),t.prevTime,t.prevComposition):new ju(t.done,t.undone.addTransform(n,void 0,r,y1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!wVe(n,t.prevRanges)),u=s?sk(t.prevRanges,n.mapping):J7(n.mapping.maps);return new ju(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,y1(e)),Po.empty,u,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new ju(t.done.rebased(n,a),t.undone.rebased(n,a),sk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ju(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),sk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function wVe(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 J7(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,s)=>e.push(a,s));return e}function sk(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 SVe(t,e,n){let r=y1(e),i=Lh.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new ju(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(Lh,{redo:n,historyState:c})}let ok=!1,e9=null;function y1(t){let e=t.plugins;if(e9!=e){ok=!1,e9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){ok=!0;break}}return ok}const Lh=new Si("history"),MVe=new Si("closeHistory");function EVe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Er({key:Lh,state:{init(){return new ju(Po.empty,Po.empty,null,0,-1)},apply(e,n,r){return _Ve(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Iee:r=="historyRedo"?Fee:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Lee(t,e){return(n,r)=>{let i=Lh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=SVe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const Iee=Lee(!1,!0),Fee=Lee(!0,!0);Qn.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 Er({key:new Si("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 s=a-i,o=0,c=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(o,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 o=e.selection.$head.pos,c=a-r,u=o-c,d=o;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var AVe=Qn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[lVe(this.options)]}});Qn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Er({key:new Si("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return yr.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(Ea.node(u,u+c.nodeSize,{class:this.options.className}))}),yr.create(t,a)}}})]}});var TVe=Qn.create({name:"gapCursor",addProseMirrorPlugins(){return[hVe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Un(Bt(t,"allowGapCursor",n)))!=null?e:null}}});Qn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Er({key:new Si("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((s,o)=>{const c=r>=o&&r<=o+s.nodeSize,u=!s.isLeaf&&aE(s);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ea.node(o,o+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:o,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),yr.create(t,i)}}})]}});Qn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Er({key:new Si("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||XJ(n.selection)||t.view.dragging?null:yr.create(n.doc,[Ea.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function t9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var CVe=Qn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Si(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 Er({key:e,appendTransaction:(i,a,s)=>{const{doc:o,tr:c,schema:u}=s,d=e.getState(s),f=o.content.size,g=u.nodes[n];if(d)return c.insert(f,g.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!t9({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!t9({node:s,types:r})}}})]}}),NVe=Qn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Iee(t,e),redo:()=>({state:t,dispatch:e})=>Fee(t,e)}},addProseMirrorPlugins(){return[EVe(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()}}}),kVe=Qn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(r$e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(QHe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(See.configure(this.options.bulletList)),this.options.code!==!1&&i.push(s$e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(c$e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(u$e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(AVe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(TVe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(d$e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(h$e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(NVe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(f$e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(b$e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Mee.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(kee.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(wee.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Ree.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(nVe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(aVe.configure(this.options.strike)),this.options.text!==!1&&i.push(sVe.configure(this.options.text)),this.options.underline!==!1&&i.push(Dee.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(CVe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),PVe=kVe,RVe=Qn.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")}}}),DVe=RVe,jVe=20,Uee=(t,e=0)=>{const n=[];return!t.children.length||e>jVe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Uee(r,e+1))}),n},OVe=t=>{if(!t.children.length)return;const e=Uee(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),s=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${s};${a}`)})},zee=Ad.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&OVe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Dr(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}}}}),LVe=Qn.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 s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="background-color")return o.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()}}}),Bee=Qn.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 s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="color")return o.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()}}}),IVe=Qn.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()}}}),FVe=Qn.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()}}}),UVe=Qn.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()}}});Qn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(LVe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Bee.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(IVe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(FVe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(UVe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(zee.configure(this.options.textStyle)),t}});var zVe=Bee,BVe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,HVe=Ja.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",Dr(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,s;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return u?`![${c}](${o} "${u}")`:`![${c}](${o})`},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:s})=>{const o=document.createElement("img");Object.entries(s).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:o.setAttribute(d,f);break}}),o.src=s.src;const c=new SHe({element:o,node:i,getPos:a,onResize:(d,f)=>{o.style.width=`${d}px`,o.style.height=`${f}px`},onCommit:(d,f)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",o.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[uee({find:BVe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),$Ve=HVe;function n9({content:t,onChange:e,placeholder:n}){const r=qHe({extensions:[PVe.configure({heading:!1,codeBlock:!1,code:!1}),oVe,$$e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),DVe.configure({types:["paragraph"]}),zee,zVe,$Ve.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:s})=>{e(s.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:s,isActive:o=!1,children:c,title:u})=>l.jsx("button",{type:"button",onClick:s,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const s=window.prompt("Enter URL:");s&&r.chain().focus().setLink({href:s}).run()};return l.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[l.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[l.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:l.jsx(ioe,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:l.jsx(Lle,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:l.jsx(Cue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:l.jsx(VR,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:l.jsx(fG,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:l.jsx(vue,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:l.jsx(gue,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:l.jsx(bue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:l.jsx(zS,{className:"w-4 h-4"})}),r.isActive("link")&&l.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:l.jsx(vG,{className:"w-4 h-4"})})]}),l.jsx(zHe,{editor:r})]})}function VVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),[i,a]=E.useState(!1),[s,o]=E.useState(null),[c,u]=E.useState({}),{data:d,isLoading:f,error:g}=vt({queryKey:["archive-project-page",t],queryFn:()=>ke.getArchiveProjectPage(t)}),m=wt({mutationFn:T=>ke.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});E.useEffect(()=>{const T=k=>{k.key==="Escape"&&(s!==null?o(null):i?x():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,i,n]);const b=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},v=()=>{m.mutate(c)},x=()=>{a(!1),u({})},M=T=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],N=new DOMParser().parseFromString(T,"text/html"),I=C=>{if(C.nodeType===Node.TEXT_NODE)return C.textContent||"";if(C.nodeType===Node.ELEMENT_NODE){const D=C,F=D.tagName.toLowerCase();if(!k.includes(F))return Array.from(D.childNodes).map(I).join("");let O="";if(F==="a"&&D.getAttribute("href")){const R=D.getAttribute("href");R?.toLowerCase().startsWith("http")&&(O=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const R=D.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";O=` src="${R}" style="max-width: 100%; height: auto;"`}const q=Array.from(D.childNodes).map(I).join("");return["br","img"].includes(F)?`<${F}${O} />`:`<${F}${O}>${q}</${F}>`}return""};return Array.from(N.body.childNodes).map(I).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||b.length>0),A=T=>{T.target===T.currentTarget&&n()};return l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(to,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&l.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[!i&&S&&l.jsxs(Le,{variant:"ghost",size:"sm",onClick:y,children:[l.jsx(S0,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),l.jsxs(Le,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[l.jsx(Ro,{className:"w-4 h-4 mr-1"}),"Save"]})]}),l.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&l.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&l.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[l.jsx(to,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No project page data found in this 3MF file."}),l.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&S&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-4",children:[i?l.jsx("input",{type:"text",value:c.title||"",onChange:T=>u({...c,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&l.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),l.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ok,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:c.designer||"",onChange:T=>u({...c,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(Ok,{className:"w-4 h-4"}),l.jsx("span",{children:d.designer}),d.designer_user_id&&l.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:l.jsx(As,{className:"w-3 h-3"})})]}),d.creation_date&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(Zr,{className:"w-4 h-4"}),l.jsx("span",{children:d.creation_date})]}),i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(to,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:c.license||"",onChange:T=>u({...c,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(to,{className:"w-4 h-4"}),l.jsx("span",{children:d.license})]}),d.origin&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?l.jsx(n9,{content:c.description||"",onChange:T=>u({...c,description:T}),placeholder:"Enter description..."}):l.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)&&l.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?l.jsxs("div",{className:"space-y-2",children:[l.jsx("input",{type:"text",value:c.profile_title||"",onChange:T=>u({...c,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),l.jsx(n9,{content:c.profile_description||"",onChange:T=>u({...c,profile_description:T}),placeholder:"Profile description..."})]}):l.jsxs(l.Fragment,{children:[d.profile_title&&l.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&l.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&&l.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),b.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[l.jsx(gb,{className:"w-4 h-4"}),"Images (",b.length,")"]}),l.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:b.map((T,k)=>l.jsx("button",{onClick:()=>o(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:l.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.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:[l.jsx(As,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&b[s]&&l.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,s-1))},disabled:s===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:l.jsx(Bh,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:b[s].url,alt:b[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(b.length-1,s+1))},disabled:s===b.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:l.jsx(uf,{className:"w-6 h-6 text-white"})}),l.jsx("button",{onClick:()=>o(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:l.jsx(Wt,{className:"w-6 h-6 text-white"})}),l.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",b.length]})]})]})}const GVe=[.25,.5,.75,1,1.5,2,3,4];function WVe({src:t,title:e,downloadFilename:n,onClose:r}){const i=E.useRef(null),[a,s]=E.useState(!0),[o,c]=E.useState(2),[u,d]=E.useState(0),[f,g]=E.useState(0);E.useEffect(()=>{const S=i.current;S&&(S.playbackRate=o)},[o]),E.useEffect(()=>{const S=A=>{A.key==="Escape"&&r()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r]),E.useEffect(()=>{const S=i.current;if(!S)return;const A=()=>d(S.currentTime),T=()=>g(S.duration),k=()=>s(!0),N=()=>s(!1);return S.addEventListener("timeupdate",A),S.addEventListener("durationchange",T),S.addEventListener("play",k),S.addEventListener("pause",N),()=>{S.removeEventListener("timeupdate",A),S.removeEventListener("durationchange",T),S.removeEventListener("play",k),S.removeEventListener("pause",N)}},[]);const m=()=>{const S=i.current;S&&(a?S.pause():S.play())},b=S=>{const A=i.current;A&&(A.currentTime=parseFloat(S.target.value))},y=()=>{const S=i.current;S&&(S.currentTime=Math.max(0,S.currentTime-5))},v=()=>{const S=i.current;S&&(S.currentTime=Math.min(f,S.currentTime+5))},x=S=>{const A=Math.floor(S/60),T=Math.floor(S%60);return`${A}:${T.toString().padStart(2,"0")}`},M=()=>{const S=document.createElement("a");S.href=t,S.download=n,S.click()};return l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:l.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Yp,{className:"w-5 h-5 text-bambu-green"}),e]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:M,children:[l.jsx(Es,{className:"w-4 h-4"}),"Download"]}),l.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"p-4",children:[l.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),l.jsxs("div",{className:"mt-4 space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:x(u)}),l.jsx("input",{type:"range",min:0,max:f||100,value:u,onChange:b,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8216. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8217. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8218. [&::-webkit-slider-thumb]:cursor-pointer`}),l.jsx("span",{className:"text-xs text-bambu-gray w-12",children:x(f)})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:l.jsx(rue,{className:"w-5 h-5 text-bambu-gray"})}),l.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:a?l.jsx(Mce,{className:"w-5 h-5 text-white"}):l.jsx(BS,{className:"w-5 h-5 text-white"})}),l.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:l.jsx(N1,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),l.jsx("div",{className:"flex gap-1",children:GVe.map(S=>l.jsxs("button",{onClick:()=>c(S),className:`px-2 py-1 text-xs rounded transition-colors ${o===S?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[S,"x"]},S))})]})]})]})]})]})})}function qVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),{showToast:i}=ai(),[a,s]=E.useState(null),[o,c]=E.useState("asap"),[u,d]=E.useState(""),[f,g]=E.useState(!1),[m,b]=E.useState(!1),{data:y}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()});E.useEffect(()=>{y?.length===1&&!a&&s(y[0].id)},[y,a]),E.useEffect(()=>{const S=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]);const v=wt({mutationFn:S=>ke.addToQueue(S),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:S=>{i(S.message||"Failed to add to queue","error")}}),x=S=>{if(S.preventDefault(),!a){i("Please select a printer","error");return}const A={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u&&(A.scheduled_time=new Date(u).toISOString()),v.mutate(A)},M=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zr,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:e})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),"No printers configured"]}):l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:S=>s(S.target.value?Number(S.target.value):null),required:!0,children:[l.jsx("option",{value:"",children:"Select printer..."}),y?.map(S=>l.jsx("option",{value:S.id,children:S.name},S.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_r,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[l.jsx(Zr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:M(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>b(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(yd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:v.isPending||!a||y?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function KVe({archiveIds:t,onClose:e}){E.useEffect(()=>{const a=s=>{s.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=vt({queryKey:["archive-comparison",t],queryFn:()=>ke.compareArchives(t)});return l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:l.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:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?l.jsxs("div",{className:"text-center py-12 text-red-400",children:[l.jsx(ti,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"Failed to load comparison"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?l.jsx(XVe,{comparison:n}):null}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Le,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function XVe({comparison:t}){return l.jsxs("div",{className:"space-y-6",children:[l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.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=>l.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[l.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),l.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))]})}),l.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>l.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[l.jsx("td",{className:"py-2 pr-4 text-sm",children:l.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&l.jsx(ti,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),l.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>l.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??l.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&l.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&l.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[l.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[l.jsx(ti,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),l.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>l.jsxs("li",{children:[l.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&l.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[l.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[l.jsx(zh,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[l.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),l.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?l.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>l.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[l.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",l.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):l.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:l.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function vR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Px(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function r9(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function YVe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a}){const s=En(),{showToast:o}=ai(),c=EG(),[u,d]=E.useState(!1),[f,g]=E.useState(!1),[m,b]=E.useState(!1),[y,v]=E.useState(!1),[x,M]=E.useState(!1),[S,A]=E.useState(!1),[T,k]=E.useState([]),[N,I]=E.useState(!1),[C,D]=E.useState(!1),[F,O]=E.useState(!1),[q,R]=E.useState(!1),[W,K]=E.useState(!1),[G,ee]=E.useState(null),Z=E.useRef(null),Q=wt({mutationFn:ie=>ke.uploadSource3mf(t.id,ie),onSuccess:ie=>{s.invalidateQueries({queryKey:["archives"]}),o(`Source 3MF attached: ${ie.filename}`)},onError:ie=>{o(ie.message||"Failed to upload source 3MF","error")}}),U=wt({mutationFn:()=>ke.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),o("Source 3MF removed")},onError:ie=>{o(ie.message||"Failed to remove source 3MF","error")}}),$=wt({mutationFn:()=>ke.scanArchiveTimelapse(t.id),onSuccess:ie=>{ie.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${ie.filename}`)):ie.status==="exists"?o("Timelapse already attached"):ie.status==="not_found"&&ie.available_files&&ie.available_files.length>0?(k(ie.available_files),A(!0)):o(ie.message||"No matching timelapse found","warning")},onError:ie=>{o(ie.message||"Failed to scan for timelapse","error")}}),X=wt({mutationFn:ie=>ke.selectArchiveTimelapse(t.id,ie),onSuccess:ie=>{s.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${ie.filename}`),A(!1),k([])},onError:ie=>{o(ie.message||"Failed to attach timelapse","error")}}),te=wt({mutationFn:()=>ke.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),o("Archive deleted")},onError:()=>{o("Failed to delete archive","error")}}),fe=wt({mutationFn:()=>ke.toggleFavorite(t.id),onSuccess:ie=>{s.invalidateQueries({queryKey:["archives"]}),o(ie.is_favorite?"Added to favorites":"Removed from favorites")}}),pe=wt({mutationFn:ie=>ke.updateArchive(t.id,{project_id:ie}),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),s.invalidateQueries({queryKey:["projects"]}),o("Project updated")},onError:()=>{o("Failed to update project","error")}}),be=ie=>{ie.preventDefault(),ee({x:ie.clientX,y:ie.clientY})},Ne=[{label:"Print",icon:l.jsx(Ts,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"Schedule",icon:l.jsx(Zr,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"Open in Bambu Studio",icon:l.jsx(As,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",xe=`${window.location.origin}${ke.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(xe)}`}},{label:"View on MakerWorld",icon:l.jsx(y0,{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:l.jsx(hm,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:l.jsx(Yp,{className:"w-4 h-4"}),onClick:()=>M(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:l.jsx(Vce,{className:"w-4 h-4"}),onClick:()=>$.mutate(),disabled:!t.printer_id||!!t.timelapse_path||$.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:l.jsx(YF,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ie=document.createElement("a");ie.href=ke.getSource3mfDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}_source.3mf`,ie.click()}else Z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:l.jsx(vs,{className:"w-4 h-4"}),onClick:()=>Z.current?.click()},{label:"Remove Source 3MF",icon:l.jsx(Rn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:l.jsx(Es,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=ke.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()}},{label:"Copy Download Link",icon:l.jsx(Hh,{className:"w-4 h-4"}),onClick:()=>{const ie=`${window.location.origin}${ke.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ie).then(()=>{o("Link copied to clipboard")}).catch(()=>{o("Failed to copy link","error")})}},{label:"QR Code",icon:l.jsx(Ice,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:l.jsx(b0,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:l.jsx(to,{className:"w-4 h-4"}),onClick:()=>O(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:l.jsx(gm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>fe.mutate()},{label:"Edit",icon:l.jsx(id,{className:"w-4 h-4"}),onClick:()=>v(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:l.jsx(Ku,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:l.jsx(Ku,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const ie=[];if(t.project_id&&ie.push({label:"Remove from Project",icon:l.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>pe.mutate(null)}),!a)ie.push({label:"Loading...",icon:l.jsx(Et,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const xe=a.filter(Re=>Re.status==="active");xe.length===0?ie.push({label:"No projects available",icon:l.jsx(Ku,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):xe.forEach(Re=>{ie.push({label:Re.name,icon:l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Re.color||"#888"}}),onClick:()=>pe.mutate(Re.id),disabled:t.project_id===Re.id})})}return ie})()},{label:n?"Deselect":"Select",icon:n?l.jsx(Vh,{className:"w-4 h-4"}):l.jsx(mm,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:l.jsx(Rn,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return l.jsxs(Nt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:be,onClick:i?()=>r(t.id):void 0,children:[i&&l.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),r(t.id)},children:n?l.jsx(Vh,{className:"w-5 h-5 text-bambu-green"}):l.jsx(mm,{className:"w-5 h-5 text-white"})}),l.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(gb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),c&&l.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation();const xe=ie.currentTarget.getBoundingClientRect();ee({x:xe.left,y:xe.bottom+4})},title:"Menu",children:l.jsx(cG,{className:"w-5 h-5 text-white"})}),l.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),fe.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:l.jsx(gm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&l.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&&l.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:[l.jsx(Hh,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&l.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation();const xe=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Re=`${window.location.origin}${ke.getSource3mfForSlicer(t.id,xe)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Re)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:l.jsx(YF,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&l.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation(),M(!0)},title:"View timelapse",children:l.jsx(Yp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&l.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:ie=>{ie.stopPropagation(),D(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[l.jsx(b0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&l.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})]})]}),l.jsxs(Rt,{className:"p-4 flex-1 flex flex-col",children:[l.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:e}),t.project_name&&l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),l.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)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Px(t.print_time_seconds||0)}
  8219. Actual: ${Px(t.actual_time_seconds||0)}
  8220. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Px(t.actual_time_seconds)}`:`Estimated: ${Px(t.print_time_seconds||0)}`,children:[l.jsx(_r,{className:"w-3 h-3"}),Px(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&l.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&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx(w0,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx($h,{className:"w-3 h-3"}),t.total_layers&&l.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&l.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&l.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[l.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ie,xe)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ie},title:ie},xe))})]})]}),(t.tags||t.notes)&&l.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&l.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:l.jsx(mG,{className:"w-3 h-3"})}),t.tags?.split(",").map((ie,xe)=>l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ie.trim()},xe))]}),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[l.jsx("span",{children:r9(t.created_at)}),l.jsx("span",{children:vR(t.file_size)})]}),l.jsxs("div",{className:"flex gap-1 mt-3",children:[l.jsxs(Le,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[l.jsx(Ts,{className:"w-3 h-3 flex-shrink-0"}),l.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.print_name||t.filename||"model",xe=`${window.location.origin}${ke.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(xe)}`},title:"Open in Bambu Studio",children:l.jsx(As,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{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:l.jsx(y0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:l.jsx(hm,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=document.createElement("a");ie.href=ke.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()},title:"Download",children:l.jsx(Es,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>v(!0),title:"Edit",children:l.jsx(id,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:l.jsx(Rn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&l.jsx(vUe,{archive:t,onClose:()=>v(!1)}),u&&l.jsx(mUe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&l.jsx(gUe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),m&&l.jsx(Qr,{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:()=>{te.mutate(),b(!1)},onCancel:()=>b(!1)}),W&&l.jsx(Qr,{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:()=>{U.mutate(),K(!1)},onCancel:()=>K(!1)}),G&&l.jsx(_Ue,{x:G.x,y:G.y,items:Ne,onClose:()=>ee(null)}),x&&t.timelapse_path&&l.jsx(WVe,{src:ke.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>M(!1)}),S&&T.length>0&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),l.jsx("button",{onClick:()=>{A(!1),k([])},className:"text-gray-400 hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(ie=>l.jsxs("button",{onClick:()=>X.mutate(ie.name),disabled:X.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:[l.jsx(Yp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-white font-medium truncate",children:ie.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:[vR(ie.size),ie.mtime&&` • ${r9(ie.mtime)}`]})]})]},ie.name))}),l.jsx("div",{className:"p-4 border-t border-gray-700",children:l.jsx(Le,{variant:"secondary",onClick:()=>{A(!1),k([])},className:"w-full",children:"Cancel"})})]})}),N&&l.jsx(CUe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),C&&t.photos&&t.photos.length>0&&l.jsx(NUe,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>D(!1),onDelete:async ie=>{try{await ke.deleteArchivePhoto(t.id,ie),s.invalidateQueries({queryKey:["archives"]}),o("Photo deleted")}catch{o("Failed to delete photo","error")}}}),F&&l.jsx(VVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),q&&l.jsx(qVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),l.jsx("input",{ref:Z,type:"file",accept:".3mf",className:"hidden",onChange:ie=>{const xe=ie.target.files?.[0];xe&&Q.mutate(xe),ie.target.value=""}})]})}const ZVe=[{id:"all",label:"All Archives",icon:l.jsx(xle,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:l.jsx(_r,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:l.jsx(Zr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:l.jsx(Zr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:l.jsx(gm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:l.jsx(lo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:l.jsx(Hh,{className:"w-4 h-4"})}];function QVe(){const t=En(),{showToast:e}=ai(),n=E.useRef(null),[r,i]=E.useState(""),[a,s]=E.useState(null),[o,c]=E.useState(null),[u,d]=E.useState(new Set),[f,g]=E.useState("or"),[m,b]=E.useState(!1),[y,v]=E.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[x,M]=E.useState(null),[S,A]=E.useState(!1),[T,k]=E.useState([]),[N,I]=E.useState(!1),[C,D]=E.useState(new Set),[F,O]=E.useState(!1),[q,R]=E.useState(!1),[W,K]=E.useState(!1),[G,ee]=E.useState("grid"),[Z,Q]=E.useState("date-desc"),[U,$]=E.useState("all"),[X,te]=E.useState(!1),[fe,pe]=E.useState(!1),[be,Ne]=E.useState(!1),{data:ie,isLoading:xe}=vt({queryKey:["archives",a],queryFn:()=>ke.getArchives(a||void 0)}),{data:Re}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:he}=vt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),ht=wt({mutationFn:async ue=>(await Promise.all(ue.map(Ve=>ke.deleteArchive(Ve))),ue.length),onSuccess:ue=>{t.invalidateQueries({queryKey:["archives"]}),D(new Set),e(`${ue} archive${ue!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});E.useEffect(()=>{localStorage.setItem("archiveHideFailed",y.toString())},[y]);const H=new Map(Re?.map(ue=>[ue.id,ue.name])||[]),B=[...new Set(ie?.flatMap(ue=>ue.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),re=[...new Set(ie?.flatMap(ue=>ue.filament_color?.split(",")||[]).filter(Boolean)||[])],V=[...new Set(ie?.flatMap(ue=>ue.tags?.split(",").map(Ve=>Ve.trim())||[]).filter(Boolean)||[])].sort(),J=ie?.filter(ue=>{const Ve=new Date,Fe=new Date(ue.created_at);let oe=!0;switch(U){case"recent":oe=Ve.getTime()-Fe.getTime()<1440*60*1e3;break;case"this-week":oe=Ve.getTime()-Fe.getTime()<10080*60*1e3;break;case"this-month":oe=Fe.getMonth()===Ve.getMonth()&&Fe.getFullYear()===Ve.getFullYear();break;case"favorites":oe=ue.is_favorite===!0;break;case"failed":oe=ue.status==="failed"||ue.status==="aborted";break;case"duplicates":oe=ue.duplicate_count>0;break}const et=(ue.print_name||ue.filename).toLowerCase().includes(r.toLowerCase()),He=!o||ue.filament_type?.split(", ").includes(o),Ke=ue.filament_color?.split(",")||[],ct=u.size===0||(f==="or"?Ke.some(Ce=>u.has(Ce)):[...u].every(Ce=>Ke.includes(Ce))),de=U==="favorites"||!m||ue.is_favorite,Ye=U==="failed"||!y||ue.status!=="failed"&&ue.status!=="aborted",ge=ue.tags?.split(",").map(Ce=>Ce.trim())||[],Ue=!x||ge.includes(x);return oe&&et&&He&&ct&&de&&Ye&&Ue}).sort((ue,Ve)=>{switch(Z){case"date-desc":return new Date(Ve.created_at).getTime()-new Date(ue.created_at).getTime();case"date-asc":return new Date(ue.created_at).getTime()-new Date(Ve.created_at).getTime();case"name-asc":return(ue.print_name||ue.filename).localeCompare(Ve.print_name||Ve.filename);case"name-desc":return(Ve.print_name||Ve.filename).localeCompare(ue.print_name||ue.filename);case"size-desc":return Ve.file_size-ue.file_size;case"size-asc":return ue.file_size-Ve.file_size;default:return 0}}),se=F||C.size>0,Ae=ue=>{D(Ve=>{const Fe=new Set(Ve);return Fe.has(ue)?Fe.delete(ue):Fe.add(ue),Fe})},Pe=()=>{J&&D(new Set(J.map(ue=>ue.id)))},Se=()=>{D(new Set),O(!1)},z=ue=>{d(Ve=>{const Fe=new Set(Ve);return Fe.has(ue)?Fe.delete(ue):Fe.add(ue),Fe})},L=()=>{d(new Set)},ne=()=>{i(""),s(null),c(null),b(!1),v(!1),M(null)},ve=r||a||o||m||y||x,we=E.useCallback(ue=>{ue.preventDefault(),ue.dataTransfer.types.includes("Files")&&I(!0)},[]),ye=E.useCallback(ue=>{ue.preventDefault(),ue.currentTarget===ue.target&&I(!1)},[]),nt=E.useCallback(ue=>{ue.preventDefault(),I(!1);const Ve=Array.from(ue.dataTransfer.files).filter(Fe=>Fe.name.endsWith(".3mf"));Ve.length>0?(k(Ve),A(!0)):ue.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Be=E.useCallback(ue=>{const Ve=ue.target;if(Ve.tagName==="INPUT"||Ve.tagName==="TEXTAREA"||Ve.isContentEditable){ue.key==="Escape"&&Ve.blur();return}switch(ue.key){case"/":ue.preventDefault(),n.current?.focus();break;case"u":case"U":!ue.metaKey&&!ue.ctrlKey&&(ue.preventDefault(),A(!0));break;case"Escape":se&&Se();break}},[se]);return E.useEffect(()=>(document.addEventListener("keydown",Be),()=>document.removeEventListener("keydown",Be)),[Be]),l.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:we,onDragLeave:ye,onDrop:nt,children:[N&&l.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[l.jsx(vs,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),l.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),se&&l.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:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:Se,children:[l.jsx(Wt,{className:"w-4 h-4"}),"Close"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("span",{className:"text-white font-medium",children:[C.size," selected"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:Pe,children:"Select All"}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>K(!0),children:[l.jsx(E0,{className:"w-4 h-4"}),"Tags"]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>{const ue=Array.from(C);Promise.all(ue.map(Ve=>ke.toggleFavorite(Ve))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ue.length} archive${ue.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[l.jsx(gm,{className:"w-4 h-4"}),"Favorite"]}),l.jsxs(Le,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>R(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]}),l.jsxs("div",{className:"flex items-center justify-between mb-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),l.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:U,onChange:ue=>$(ue.target.value),children:ZVe.map(ue=>l.jsx("option",{value:ue.id,children:ue.label},ue.id))})]}),l.jsxs("p",{className:"text-bambu-gray",children:[J?.length||0," of ",ie?.length||0," prints"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>te(!X),disabled:fe,children:[fe?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(T1,{className:"w-4 h-4"}),"Export"]}),X&&l.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:[l.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()=>{te(!1),pe(!0);try{const{blob:ue,filename:Ve}=await ke.exportArchives({format:"csv",printerId:a||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Fe=URL.createObjectURL(ue),oe=document.createElement("a");oe.href=Fe,oe.download=Ve,oe.click(),URL.revokeObjectURL(Fe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[l.jsx(to,{className:"w-4 h-4"}),"Export as CSV"]}),l.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()=>{te(!1),pe(!0);try{const{blob:ue,filename:Ve}=await ke.exportArchives({format:"xlsx",printerId:a||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Fe=URL.createObjectURL(ue),oe=document.createElement("a");oe.href=Fe,oe.download=Ve,oe.click(),URL.revokeObjectURL(Fe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[l.jsx(T1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),C.size>=2&&C.size<=5&&l.jsxs(Le,{variant:"secondary",onClick:()=>Ne(!0),children:[l.jsx(Zp,{className:"w-4 h-4"}),"Compare (",C.size,")"]}),!se&&l.jsxs(Le,{variant:"secondary",onClick:()=>O(!0),children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select"]}),l.jsxs(Le,{onClick:()=>A(!0),children:[l.jsx(vs,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),l.jsx(Nt,{className:"mb-6",children:l.jsxs(Rt,{className:"py-4",children:[l.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[l.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[l.jsx(Cc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.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:ue=>i(ue.target.value)})]}),l.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:[l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(BR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.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:ue=>s(ue.target.value?Number(ue.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),Re?.map(ue=>l.jsx("option",{value:ue.id,children:ue.name},ue.id))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(w0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.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:o||"",onChange:ue=>c(ue.target.value||null),children:[l.jsx("option",{value:"",children:"All Materials"}),B.map(ue=>l.jsx("option",{value:ue,children:ue},ue))]})]}),l.jsxs("button",{onClick:()=>b(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${m?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:m?"Show all":"Show favorites only",children:[l.jsx(gm,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),l.jsxs("button",{onClick:()=>v(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[l.jsx(lo,{className:"w-4 h-4 "}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),V.length>0&&l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(E0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.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:x||"",onChange:ue=>M(ue.target.value||null),children:[l.jsx("option",{value:"",children:"All Tags"}),V.map(ue=>l.jsx("option",{value:ue,children:ue},ue))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(eoe,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.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:Z,onChange:ue=>Q(ue.target.value),children:[l.jsx("option",{value:"date-desc",children:"Newest first"}),l.jsx("option",{value:"date-asc",children:"Oldest first"}),l.jsx("option",{value:"name-asc",children:"Name A-Z"}),l.jsx("option",{value:"name-desc",children:"Name Z-A"}),l.jsx("option",{value:"size-desc",children:"Largest first"}),l.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),l.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[l.jsx("button",{className:`p-2 ${G==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("grid"),title:"Grid view",children:l.jsx(hG,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${G==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("list"),title:"List view",children:l.jsx(VR,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${G==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("calendar"),title:"Calendar view",children:l.jsx(foe,{className:"w-4 h-4"})})]})]}),ve&&l.jsxs(Le,{variant:"ghost",size:"sm",onClick:ne,className:"text-bambu-gray hover:text-white",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Reset"]})]}),re.length>0&&l.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&l.jsx("button",{onClick:()=>g(ue=>ue==="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()}),l.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:re.map(ue=>l.jsx("button",{onClick:()=>z(ue),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ue)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ue},title:ue},ue))}),u.size>0&&l.jsxs("button",{onClick:L,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[l.jsx(Wt,{className:"w-3 h-3"}),"Clear"]})]})]})}),xe?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):J?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):G==="calendar"?l.jsx(Nt,{className:"p-6",children:l.jsx(TUe,{archives:J||[],onArchiveClick:ue=>{i(ue.print_name||ue.filename),ee("grid")}})}):G==="grid"?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:J?.map(ue=>l.jsx(YVe,{archive:ue,printerName:ue.printer_id?H.get(ue.printer_id)||"Unknown":"No Printer",isSelected:C.has(ue.id),onSelect:Ae,selectionMode:se,projects:he},ue.id))}):G==="list"?l.jsx(Nt,{children:l.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[l.jsx("div",{className:"col-span-1"}),l.jsx("div",{className:"col-span-4",children:"Name"}),l.jsx("div",{className:"col-span-2",children:"Printer"}),l.jsx("div",{className:"col-span-2",children:"Date"}),l.jsx("div",{className:"col-span-1",children:"Size"}),l.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),J?.map(ue=>l.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${C.has(ue.id)?"bg-bambu-green/10":""}`,children:[l.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[se&&l.jsx("button",{onClick:()=>Ae(ue.id),children:C.has(ue.id)?l.jsx(Vh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(mm,{className:"w-4 h-4 text-bambu-gray"})}),ue.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(ue.id),alt:"",className:"w-10 h-10 object-cover rounded"}):l.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:l.jsx(gb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),l.jsxs("div",{className:"col-span-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white text-sm truncate",children:ue.print_name||ue.filename}),ue.timelapse_path&&l.jsx("span",{title:"Has timelapse",children:l.jsx(Yp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),ue.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:ue.filament_type}),ue.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:ue.filament_color.split(",").map((Ve,Fe)=>l.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Ve},title:Ve},Fe))})]})]}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:ue.printer_id?H.get(ue.printer_id)||"Unknown":"No Printer"}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(ue.created_at).toLocaleDateString()}),l.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:vR(ue.file_size)}),l.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{const Ve=ue.print_name||ue.filename||"model",Fe=`${window.location.origin}${ke.getArchiveForSlicer(ue.id,Ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Fe)}`},title:"Open in Slicer",children:l.jsx(As,{className:"w-4 h-4"})}),ue.makerworld_url&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>window.open(ue.makerworld_url,"_blank"),title:"MakerWorld",children:l.jsx(y0,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{const Ve=document.createElement("a");Ve.href=ke.getArchiveDownload(ue.id),Ve.download=`${ue.print_name||ue.filename}.3mf`,Ve.click()},title:"Download",children:l.jsx(Es,{className:"w-4 h-4"})})]})]},ue.id))]})}):null,S&&l.jsx(xUe,{onClose:()=>{A(!1),k([])},initialFiles:T}),q&&l.jsx(Qr,{title:"Delete Archives",message:`Are you sure you want to delete ${C.size} archive${C.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${C.size}`,variant:"danger",onConfirm:()=>{ht.mutate(Array.from(C)),R(!1)},onCancel:()=>R(!1)}),W&&l.jsx(wUe,{selectedIds:Array.from(C),existingTags:V,onClose:()=>K(!1)}),be&&C.size>=2&&C.size<=5&&l.jsx(KVe,{archiveIds:Array.from(C),onClose:()=>{Ne(!1),D(new Set),O(!1)}})]})}function JVe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const cE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function hg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function hL(t){return"nodeType"in t}function es(t){var e,n;return t?hg(t)?t:hL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function fL(t){const{Document:e}=es(t);return t instanceof e}function ey(t){return hg(t)?!1:t instanceof es(t).HTMLElement}function Hee(t){return t instanceof es(t).SVGElement}function fg(t){return t?hg(t)?t.document:hL(t)?fL(t)?t:ey(t)||Hee(t)?t.ownerDocument:document:document:document}const vl=cE?E.useLayoutEffect:E.useEffect;function pL(t){const e=E.useRef(t);return vl(()=>{e.current=t}),E.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 e7e(){const t=E.useRef(null),e=E.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=E.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function cb(t,e){e===void 0&&(e=[t]);const n=E.useRef(t);return vl(()=>{n.current!==t&&(n.current=t)},e),n}function ty(t,e){const n=E.useRef();return E.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function NS(t){const e=pL(t),n=E.useRef(null),r=E.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function _R(t){const e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}let lk={};function ny(t,e){return E.useMemo(()=>{if(e)return e;const n=lk[t]==null?0:lk[t]+1;return lk[t]=n,t+"-"+n},[t,e])}function $ee(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,s)=>{const o=Object.entries(s);for(const[c,u]of o){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const um=$ee(1),ub=$ee(-1);function t7e(t){return"clientX"in t&&"clientY"in t}function mL(t){if(!t)return!1;const{KeyboardEvent:e}=es(t.target);return e&&t instanceof e}function n7e(t){if(!t)return!1;const{TouchEvent:e}=es(t.target);return e&&t instanceof e}function wR(t){if(n7e(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 t7e(t)?{x:t.clientX,y:t.clientY}:null}const Hm=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[Hm.Translate.toString(t),Hm.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),i9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function r7e(t){return t.matches(i9)?t:t.querySelector(i9)}const i7e={display:"none"};function a7e(t){let{id:e,value:n}=t;return mr.createElement("div",{id:e,style:i7e},n)}function s7e(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 mr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function o7e(){const[t,e]=E.useState("");return{announce:E.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Vee=E.createContext(null);function l7e(t){const e=E.useContext(Vee);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function c7e(){const[t]=E.useState(()=>new Set),e=E.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[E.useCallback(r=>{let{type:i,event:a}=r;t.forEach(s=>{var o;return(o=s[i])==null?void 0:o.call(s,a)})},[t]),e]}const u7e={draggable:`
  8221. To pick up a draggable item, press the space bar.
  8222. While dragging, use the arrow keys to move the item.
  8223. Press space again to drop the item in its new position, or press escape to cancel.
  8224. `},d7e={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 h7e(t){let{announcements:e=d7e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=u7e}=t;const{announce:a,announcement:s}=o7e(),o=ny("DndLiveRegion"),[c,u]=E.useState(!1);if(E.useEffect(()=>{u(!0)},[]),l7e(E.useMemo(()=>({onDragStart(f){let{active:g}=f;a(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:m}=f;e.onDragMove&&a(e.onDragMove({active:g,over:m}))},onDragOver(f){let{active:g,over:m}=f;a(e.onDragOver({active:g,over:m}))},onDragEnd(f){let{active:g,over:m}=f;a(e.onDragEnd({active:g,over:m}))},onDragCancel(f){let{active:g,over:m}=f;a(e.onDragCancel({active:g,over:m}))}}),[a,e])),!c)return null;const d=mr.createElement(mr.Fragment,null,mr.createElement(a7e,{id:r,value:i.draggable}),mr.createElement(s7e,{id:o,announcement:s}));return n?hc.createPortal(d,n):d}var di;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(di||(di={}));function kS(){}function PS(t,e){return E.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Gee(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const zo=Object.freeze({x:0,y:0});function Wee(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function qee(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function f7e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function a9(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 Kee(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function s9(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 Xee=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=s9(e,e.left,e.top),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=Wee(s9(c),i);a.push({id:o,data:{droppableContainer:s,value:u}})}}return a.sort(qee)},p7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=a9(e),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=a9(c),d=i.reduce((g,m,b)=>g+Wee(u[b],m),0),f=Number((d/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(qee)};function m7e(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),s=i-r,o=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=s*o,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const g7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,o=n.get(s);if(o){const c=m7e(o,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(f7e)};function x7e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Yee(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:zo}function b7e(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((s,o)=>({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const y7e=b7e(1);function v7e(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 _7e(t,e,n){const r=v7e(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:o}=r,c=t.left-s-(1-i)*parseFloat(n),u=t.top-o-(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 w7e={ignoreTransform:!1};function pg(t,e){e===void 0&&(e=w7e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=es(t).getComputedStyle(t);u&&(n=_7e(n,u,d))}const{top:r,left:i,width:a,height:s,bottom:o,right:c}=n;return{top:r,left:i,width:a,height:s,bottom:o,right:c}}function o9(t){return pg(t,{ignoreTransform:!0})}function S7e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function M7e(t,e){return e===void 0&&(e=es(t).getComputedStyle(t)),e.position==="fixed"}function E7e(t,e){e===void 0&&(e=es(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 uE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(fL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!ey(i)||Hee(i)||n.includes(i))return n;const a=es(t).getComputedStyle(i);return i!==t&&E7e(i,a)&&n.push(i),M7e(i,a)?n:r(i.parentNode)}return t?r(t):n}function Zee(t){const[e]=uE(t,1);return e??null}function ck(t){return!cE||!t?null:hg(t)?t:hL(t)?fL(t)||t===fg(t).scrollingElement?window:ey(t)?t:null:null}function Qee(t){return hg(t)?t.scrollX:t.scrollLeft}function Jee(t){return hg(t)?t.scrollY:t.scrollTop}function SR(t){return{x:Qee(t),y:Jee(t)}}var ji;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ji||(ji={}));function ete(t){return!cE||!t?!1:t===document.scrollingElement}function tte(t){const e={x:0,y:0},n=ete(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,s=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:o,maxScroll:r,minScroll:e}}const A7e={x:.2,y:.2};function T7e(t,e,n,r,i){let{top:a,left:s,right:o,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=A7e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=tte(t),m={x:0,y:0},b={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+y.height?(m.y=ji.Backward,b.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(m.y=ji.Forward,b.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!g&&o>=e.right-y.width?(m.x=ji.Forward,b.x=r*Math.abs((e.right-y.width-o)/y.width)):!f&&s<=e.left+y.width&&(m.x=ji.Backward,b.x=r*Math.abs((e.left+y.width-s)/y.width)),{direction:m,speed:b}}function C7e(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}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 nte(t){return t.reduce((e,n)=>um(e,SR(n)),zo)}function N7e(t){return t.reduce((e,n)=>e+Qee(n),0)}function k7e(t){return t.reduce((e,n)=>e+Jee(n),0)}function P7e(t,e){if(e===void 0&&(e=pg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Zee(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const R7e=[["x",["left","right"],N7e],["y",["top","bottom"],k7e]];class gL{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=uE(n),i=nte(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of R7e)for(const c of s)Object.defineProperty(this,c,{get:()=>{const u=o(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class u0{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 D7e(t){const{EventTarget:e}=es(t);return t instanceof e?t:fg(t)}function uk(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 Xs;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Xs||(Xs={}));function l9(t){t.preventDefault()}function j7e(t){t.stopPropagation()}var Sn;(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"})(Sn||(Sn={}));const rte={start:[Sn.Space,Sn.Enter],cancel:[Sn.Esc],end:[Sn.Space,Sn.Enter,Sn.Tab]},O7e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Sn.Right:return{...n,x:n.x+25};case Sn.Left:return{...n,x:n.x-25};case Sn.Down:return{...n,y:n.y+25};case Sn.Up:return{...n,y:n.y-25}}};class dE{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 u0(fg(n)),this.windowListeners=new u0(es(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Xs.Resize,this.handleCancel),this.windowListeners.add(Xs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Xs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&P7e(r),n(zo)}handleKeyDown(e){if(mL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=rte,coordinateGetter:s=O7e,scrollBehavior:o="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}:zo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=s(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=ub(f,d),m={x:0,y:0},{scrollableAncestors:b}=r.current;for(const y of b){const v=e.code,{isTop:x,isRight:M,isLeft:S,isBottom:A,maxScroll:T,minScroll:k}=tte(y),N=C7e(y),I={x:Math.min(v===Sn.Right?N.right-N.width/2:N.right,Math.max(v===Sn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(v===Sn.Down?N.bottom-N.height/2:N.bottom,Math.max(v===Sn.Down?N.top:N.top+N.height/2,f.y))},C=v===Sn.Right&&!M||v===Sn.Left&&!S,D=v===Sn.Down&&!A||v===Sn.Up&&!x;if(C&&I.x!==f.x){const F=y.scrollLeft+g.x,O=v===Sn.Right&&F<=T.x||v===Sn.Left&&F>=k.x;if(O&&!g.y){y.scrollTo({left:F,behavior:o});return}O?m.x=y.scrollLeft-F:m.x=v===Sn.Right?y.scrollLeft-T.x:y.scrollLeft-k.x,m.x&&y.scrollBy({left:-m.x,behavior:o});break}else if(D&&I.y!==f.y){const F=y.scrollTop+g.y,O=v===Sn.Down&&F<=T.y||v===Sn.Up&&F>=k.y;if(O&&!g.x){y.scrollTo({top:F,behavior:o});return}O?m.y=y.scrollTop-F:m.y=v===Sn.Down?y.scrollTop-T.y:y.scrollTop-k.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,um(ub(f,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}dE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=rte,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function c9(t){return!!(t&&"distance"in t)}function u9(t){return!!(t&&"delay"in t)}class xL{constructor(e,n,r){var i;r===void 0&&(r=D7e(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:s}=a;this.props=e,this.events=n,this.document=fg(s),this.documentListeners=new u0(this.document),this.listeners=new u0(r),this.windowListeners=new u0(es(s)),this.initialCoordinates=(i=wR(a))!=null?i:zo,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(Xs.Resize,this.handleCancel),this.windowListeners.add(Xs.DragStart,l9),this.windowListeners.add(Xs.VisibilityChange,this.handleCancel),this.windowListeners.add(Xs.ContextMenu,l9),this.documentListeners.add(Xs.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(u9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(c9(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(Xs.Click,j7e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xs.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!i)return;const c=(n=wR(e))!=null?n:zo,u=ub(i,c);if(!r&&o){if(c9(o)){if(o.tolerance!=null&&uk(u,o.tolerance))return this.handleCancel();if(uk(u,o.distance))return this.handleStart()}if(u9(o)&&uk(u,o.tolerance))return this.handleCancel();this.handlePending(o,u);return}e.cancelable&&e.preventDefault(),s(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===Sn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const L7e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class hE extends xL{constructor(e){const{event:n}=e,r=fg(n.target);super(e,L7e,r)}}hE.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 I7e={move:{name:"mousemove"},end:{name:"mouseup"}};var MR;(function(t){t[t.RightClick=2]="RightClick"})(MR||(MR={}));class F7e extends xL{constructor(e){super(e,I7e,fg(e.event.target))}}F7e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===MR.RightClick?!1:(r?.({event:n}),!0)}}];const dk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class U7e extends xL{constructor(e){super(e,dk)}static setup(){return window.addEventListener(dk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(dk.move.name,e)};function e(){}}}U7e.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 d0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(d0||(d0={}));var RS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(RS||(RS={}));function z7e(t){let{acceleration:e,activator:n=d0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:o=RS.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const m=H7e({delta:f,disabled:!a}),[b,y]=e7e(),v=E.useRef({x:0,y:0}),x=E.useRef({x:0,y:0}),M=E.useMemo(()=>{switch(n){case d0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case d0.DraggableRect:return i}},[n,i,c]),S=E.useRef(null),A=E.useCallback(()=>{const k=S.current;if(!k)return;const N=v.current.x*x.current.x,I=v.current.y*x.current.y;k.scrollBy(N,I)},[]),T=E.useMemo(()=>o===RS.TreeOrder?[...u].reverse():u,[o,u]);E.useEffect(()=>{if(!a||!u.length||!M){y();return}for(const k of T){if(r?.(k)===!1)continue;const N=u.indexOf(k),I=d[N];if(!I)continue;const{direction:C,speed:D}=T7e(k,I,M,e,g);for(const F of["x","y"])m[F][C[F]]||(D[F]=0,C[F]=0);if(D.x>0||D.y>0){y(),S.current=k,b(A,s),v.current=D,x.current=C;return}}v.current={x:0,y:0},x.current={x:0,y:0},y()},[e,A,r,y,a,s,JSON.stringify(M),JSON.stringify(m),b,u,T,d,JSON.stringify(g)])}const B7e={x:{[ji.Backward]:!1,[ji.Forward]:!1},y:{[ji.Backward]:!1,[ji.Forward]:!1}};function H7e(t){let{delta:e,disabled:n}=t;const r=_R(e);return ty(i=>{if(n||!r||!i)return B7e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ji.Backward]:i.x[ji.Backward]||a.x===-1,[ji.Forward]:i.x[ji.Forward]||a.x===1},y:{[ji.Backward]:i.y[ji.Backward]||a.y===-1,[ji.Forward]:i.y[ji.Forward]||a.y===1}}},[n,e,r])}function $7e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ty(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function V7e(t,e){return E.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...a]},[]),[t,e])}var db;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(db||(db={}));var ER;(function(t){t.Optimized="optimized"})(ER||(ER={}));const d9=new Map;function G7e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=E.useState(null),{frequency:o,measure:c,strategy:u}=i,d=E.useRef(t),f=v(),g=cb(f),m=E.useCallback(function(x){x===void 0&&(x=[]),!g.current&&s(M=>M===null?x:M.concat(x.filter(S=>!M.includes(S))))},[g]),b=E.useRef(null),y=ty(x=>{if(f&&!n)return d9;if(!x||x===d9||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,T=A?new gL(c(A),A):null;S.rect.current=T,T&&M.set(S.id,T)}return M}return x},[t,a,n,f,c]);return E.useEffect(()=>{d.current=t},[t]),E.useEffect(()=>{f||m()},[n,f]),E.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),E.useEffect(()=>{f||typeof o!="number"||b.current!==null||(b.current=setTimeout(()=>{m(),b.current=null},o))},[o,f,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:a!=null};function v(){switch(u){case db.Always:return!1;case db.BeforeDragging:return n;default:return!n}}}function ite(t,e){return ty(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function W7e(t,e){return ite(t,e)}function q7e(t){let{callback:e,disabled:n}=t;const r=pL(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function fE(t){let{callback:e,disabled:n}=t;const r=pL(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function K7e(t){return new gL(pg(t),t)}function h9(t,e,n){e===void 0&&(e=K7e);const[r,i]=E.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 s=q7e({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}}}}),o=fE({callback:a});return vl(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),r}function X7e(t){const e=ite(t);return Yee(t,e)}const f9=[];function Y7e(t){const e=E.useRef(t),n=ty(r=>t?r&&r!==f9&&t&&e.current&&t.parentNode===e.current.parentNode?r:uE(t):f9,[t]);return E.useEffect(()=>{e.current=t},[t]),n}function Z7e(t){const[e,n]=E.useState(null),r=E.useRef(t),i=E.useCallback(a=>{const s=ck(a.target);s&&n(o=>o?(o.set(s,SR(s)),new Map(o)):null)},[]);return E.useEffect(()=>{const a=r.current;if(t!==a){s(a);const o=t.map(c=>{const u=ck(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,SR(u)]):null}).filter(c=>c!=null);n(o.length?new Map(o):null),r.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(c=>{const u=ck(c);u?.removeEventListener("scroll",i)})}},[i,t]),E.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>um(a,s),zo):nte(t):zo,[t,e])}function p9(t,e){e===void 0&&(e=[]);const n=E.useRef(null);return E.useEffect(()=>{n.current=null},e),E.useEffect(()=>{const r=t!==zo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?ub(t,n.current):zo}function Q7e(t){E.useEffect(()=>{if(!cE)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 J7e(t,e){return E.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function ate(t){return E.useMemo(()=>t?S7e(t):null,[t])}const m9=[];function e9e(t,e){e===void 0&&(e=pg);const[n]=t,r=ate(n?es(n):null),[i,a]=E.useState(m9);function s(){a(()=>t.length?t.map(c=>ete(c)?r:new gL(e(c),c)):m9)}const o=fE({callback:s});return vl(()=>{o?.disconnect(),s(),t.forEach(c=>o?.observe(c))},[t]),i}function t9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return ey(e)?e:t}function n9e(t){let{measure:e}=t;const[n,r]=E.useState(null),i=E.useCallback(u=>{for(const{target:d}of u)if(ey(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=fE({callback:i}),s=E.useCallback(u=>{const d=t9e(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[o,c]=NS(s);return E.useMemo(()=>({nodeRef:o,rect:n,setRef:c}),[n,o,c])}const r9e=[{sensor:hE,options:{}},{sensor:dE,options:{}}],i9e={current:{}},v1={draggable:{measure:o9},droppable:{measure:o9,strategy:db.WhileDragging,frequency:ER.Optimized},dragOverlay:{measure:pg}};class h0 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 a9e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new h0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:kS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:v1,measureDroppableContainers:kS,windowRect:null,measuringScheduled:!1},s9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kS,draggableNodes:new Map,over:null,measureDroppableContainers:kS},pE=E.createContext(s9e),ste=E.createContext(a9e);function o9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new h0}}}function l9e(t,e){switch(e.type){case di.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case di.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case di.DragEnd:case di.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case di.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new h0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case di.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const s=new h0(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case di.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new h0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function c9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=E.useContext(pE),a=_R(r),s=_R(n?.id);return E.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!mL(a)||document.activeElement===a.target)return;const o=i.get(s);if(!o)return;const{activatorNode:c,node:u}=o;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=r7e(d);if(f){f.focus();break}}})}},[r,e,i,s,a]),null}function u9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function d9e(t){return E.useMemo(()=>({draggable:{...v1.draggable,...t?.draggable},droppable:{...v1.droppable,...t?.droppable},dragOverlay:{...v1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function h9e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=E.useRef(!1),{x:s,y:o}=typeof i=="boolean"?{x:i,y:i}:i;vl(()=>{if(!s&&!o||!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=Yee(d,r);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=Zee(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,s,o,r,n])}const ote=E.createContext({...zo,scaleX:1,scaleY:1});var Ou;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ou||(Ou={}));const lte=E.memo(function(e){var n,r,i,a;let{id:s,accessibility:o,autoScroll:c=!0,children:u,sensors:d=r9e,collisionDetection:f=g7e,measuring:g,modifiers:m,...b}=e;const y=E.useReducer(l9e,void 0,o9e),[v,x]=y,[M,S]=c7e(),[A,T]=E.useState(Ou.Uninitialized),k=A===Ou.Initialized,{draggable:{active:N,nodes:I,translate:C},droppable:{containers:D}}=v,F=N!=null?I.get(N):null,O=E.useRef({initial:null,translated:null}),q=E.useMemo(()=>{var Ue;return N!=null?{id:N,data:(Ue=F?.data)!=null?Ue:i9e,rect:O}:null},[N,F]),R=E.useRef(null),[W,K]=E.useState(null),[G,ee]=E.useState(null),Z=cb(b,Object.values(b)),Q=ny("DndDescribedBy",s),U=E.useMemo(()=>D.getEnabled(),[D]),$=d9e(g),{droppableRects:X,measureDroppableContainers:te,measuringScheduled:fe}=G7e(U,{dragging:k,dependencies:[C.x,C.y],config:$.droppable}),pe=$7e(I,N),be=E.useMemo(()=>G?wR(G):null,[G]),Ne=ge(),ie=W7e(pe,$.draggable.measure);h9e({activeNode:N!=null?I.get(N):null,config:Ne.layoutShiftCompensation,initialRect:ie,measure:$.draggable.measure});const xe=h9(pe,$.draggable.measure,ie),Re=h9(pe?pe.parentElement:null),he=E.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ht=D.getNodeFor((n=he.current.over)==null?void 0:n.id),H=n9e({measure:$.dragOverlay.measure}),B=(r=H.nodeRef.current)!=null?r:pe,re=k?(i=H.rect)!=null?i:xe:null,V=!!(H.nodeRef.current&&H.rect),J=X7e(V?null:xe),se=ate(B?es(B):null),Ae=Y7e(k?ht??pe:null),Pe=e9e(Ae),Se=u9e(m,{transform:{x:C.x-J.x,y:C.y-J.y,scaleX:1,scaleY:1},activatorEvent:G,active:q,activeNodeRect:xe,containerNodeRect:Re,draggingNodeRect:re,over:he.current.over,overlayNodeRect:H.rect,scrollableAncestors:Ae,scrollableAncestorRects:Pe,windowRect:se}),z=be?um(be,C):null,L=Z7e(Ae),ne=p9(L),ve=p9(L,[xe]),we=um(Se,ne),ye=re?y7e(re,Se):null,nt=q&&ye?f({active:q,collisionRect:ye,droppableRects:X,droppableContainers:U,pointerCoordinates:z}):null,Be=Kee(nt,"id"),[ue,Ve]=E.useState(null),Fe=V?Se:um(Se,ve),oe=x7e(Fe,(a=ue?.rect)!=null?a:null,xe),et=E.useRef(null),He=E.useCallback((Ue,Ce)=>{let{sensor:_e,options:ce}=Ce;if(R.current==null)return;const st=I.get(R.current);if(!st)return;const xt=Ue.nativeEvent,St=new _e({active:R.current,activeNode:st,event:xt,options:ce,context:he,onAbort(Ot){if(!I.get(Ot))return;const{onDragAbort:On}=Z.current,Mi={id:Ot};On?.(Mi),M({type:"onDragAbort",event:Mi})},onPending(Ot,Vt,On,Mi){if(!I.get(Ot))return;const{onDragPending:Ei}=Z.current,zi={id:Ot,constraint:Vt,initialCoordinates:On,offset:Mi};Ei?.(zi),M({type:"onDragPending",event:zi})},onStart(Ot){const Vt=R.current;if(Vt==null)return;const On=I.get(Vt);if(!On)return;const{onDragStart:Mi}=Z.current,si={activatorEvent:xt,active:{id:Vt,data:On.data,rect:O}};hc.unstable_batchedUpdates(()=>{Mi?.(si),T(Ou.Initializing),x({type:di.DragStart,initialCoordinates:Ot,active:Vt}),M({type:"onDragStart",event:si}),K(et.current),ee(xt)})},onMove(Ot){x({type:di.DragMove,coordinates:Ot})},onEnd:Qt(di.DragEnd),onCancel:Qt(di.DragCancel)});et.current=St;function Qt(Ot){return async function(){const{active:On,collisions:Mi,over:si,scrollAdjustedTranslate:Ei}=he.current;let zi=null;if(On&&Ei){const{cancelDrop:ra}=Z.current;zi={activatorEvent:xt,active:On,collisions:Mi,delta:Ei,over:si},Ot===di.DragEnd&&typeof ra=="function"&&await Promise.resolve(ra(zi))&&(Ot=di.DragCancel)}R.current=null,hc.unstable_batchedUpdates(()=>{x({type:Ot}),T(Ou.Uninitialized),Ve(null),K(null),ee(null),et.current=null;const ra=Ot===di.DragEnd?"onDragEnd":"onDragCancel";if(zi){const Hr=Z.current[ra];Hr?.(zi),M({type:ra,event:zi})}})}}},[I]),Ke=E.useCallback((Ue,Ce)=>(_e,ce)=>{const st=_e.nativeEvent,xt=I.get(ce);if(R.current!==null||!xt||st.dndKit||st.defaultPrevented)return;const St={active:xt};Ue(_e,Ce.options,St)===!0&&(st.dndKit={capturedBy:Ce.sensor},R.current=ce,He(_e,Ce))},[I,He]),ct=V7e(d,Ke);Q7e(d),vl(()=>{xe&&A===Ou.Initializing&&T(Ou.Initialized)},[xe,A]),E.useEffect(()=>{const{onDragMove:Ue}=Z.current,{active:Ce,activatorEvent:_e,collisions:ce,over:st}=he.current;if(!Ce||!_e)return;const xt={active:Ce,activatorEvent:_e,collisions:ce,delta:{x:we.x,y:we.y},over:st};hc.unstable_batchedUpdates(()=>{Ue?.(xt),M({type:"onDragMove",event:xt})})},[we.x,we.y]),E.useEffect(()=>{const{active:Ue,activatorEvent:Ce,collisions:_e,droppableContainers:ce,scrollAdjustedTranslate:st}=he.current;if(!Ue||R.current==null||!Ce||!st)return;const{onDragOver:xt}=Z.current,St=ce.get(Be),Qt=St&&St.rect.current?{id:St.id,rect:St.rect.current,data:St.data,disabled:St.disabled}:null,Ot={active:Ue,activatorEvent:Ce,collisions:_e,delta:{x:st.x,y:st.y},over:Qt};hc.unstable_batchedUpdates(()=>{Ve(Qt),xt?.(Ot),M({type:"onDragOver",event:Ot})})},[Be]),vl(()=>{he.current={activatorEvent:G,active:q,activeNode:pe,collisionRect:ye,collisions:nt,droppableRects:X,draggableNodes:I,draggingNode:B,draggingNodeRect:re,droppableContainers:D,over:ue,scrollableAncestors:Ae,scrollAdjustedTranslate:we},O.current={initial:re,translated:ye}},[q,pe,nt,ye,I,B,re,X,D,ue,Ae,we]),z7e({...Ne,delta:C,draggingRect:ye,pointerCoordinates:z,scrollableAncestors:Ae,scrollableAncestorRects:Pe});const de=E.useMemo(()=>({active:q,activeNode:pe,activeNodeRect:xe,activatorEvent:G,collisions:nt,containerNodeRect:Re,dragOverlay:H,draggableNodes:I,droppableContainers:D,droppableRects:X,over:ue,measureDroppableContainers:te,scrollableAncestors:Ae,scrollableAncestorRects:Pe,measuringConfiguration:$,measuringScheduled:fe,windowRect:se}),[q,pe,xe,G,nt,Re,H,I,D,X,ue,te,Ae,Pe,$,fe,se]),Ye=E.useMemo(()=>({activatorEvent:G,activators:ct,active:q,activeNodeRect:xe,ariaDescribedById:{draggable:Q},dispatch:x,draggableNodes:I,over:ue,measureDroppableContainers:te}),[G,ct,q,xe,x,Q,I,ue,te]);return mr.createElement(Vee.Provider,{value:S},mr.createElement(pE.Provider,{value:Ye},mr.createElement(ste.Provider,{value:de},mr.createElement(ote.Provider,{value:oe},u)),mr.createElement(c9e,{disabled:o?.restoreFocus===!1})),mr.createElement(h7e,{...o,hiddenTextDescribedById:Q}));function ge(){const Ue=W?.autoScrollEnabled===!1,Ce=typeof c=="object"?c.enabled===!1:c===!1,_e=k&&!Ue&&!Ce;return typeof c=="object"?{...c,enabled:_e}:{enabled:_e}}}),f9e=E.createContext(null),g9="button",p9e="Draggable";function m9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=ny(p9e),{activators:s,activatorEvent:o,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=E.useContext(pE),{role:m=g9,roleDescription:b="draggable",tabIndex:y=0}=i??{},v=c?.id===e,x=E.useContext(v?ote:f9e),[M,S]=NS(),[A,T]=NS(),k=J7e(s,e),N=cb(n);vl(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:A,data:N}),()=>{const C=f.get(e);C&&C.key===a&&f.delete(e)}),[f,e]);const I=E.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&m===g9?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,m,y,v,b,d.draggable]);return{active:c,activatorEvent:o,activeNodeRect:u,attributes:I,isDragging:v,listeners:r?void 0:k,node:M,over:g,setNodeRef:S,setActivatorNodeRef:T,transform:x}}function g9e(){return E.useContext(ste)}const x9e="Droppable",b9e={timeout:25};function y9e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=ny(x9e),{active:s,dispatch:o,over:c,measureDroppableContainers:u}=E.useContext(pE),d=E.useRef({disabled:n}),f=E.useRef(!1),g=E.useRef(null),m=E.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:v}={...b9e,...i},x=cb(y??r),M=E.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(x.current)?x.current:[x.current]),m.current=null},v)},[v]),S=fE({callback:M,disabled:b||!s}),A=E.useCallback((I,C)=>{S&&(C&&(S.unobserve(C),f.current=!1),I&&S.observe(I))},[S]),[T,k]=NS(A),N=cb(e);return E.useEffect(()=>{!S||!T.current||(S.disconnect(),f.current=!1,S.observe(T.current))},[T,S]),E.useEffect(()=>(o({type:di.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:g,data:N}}),()=>o({type:di.UnregisterDroppable,key:a,id:r})),[r]),E.useEffect(()=>{n!==d.current.disabled&&(o({type:di.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,o]),{active:s,rect:g,isOver:c?.id===r,node:T,over:c,setNodeRef:k}}function mE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function v9e(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function W_(t){return t!==null&&t>=0}function _9e(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 w9e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const bL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=mE(e,r,n),s=e[i],o=a[i];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},q_={scaleX:1,scaleY:1},S9e=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:s}=t;const o=(e=a[n])!=null?e:r;if(!o)return null;if(i===n){const u=a[s];return u?{x:0,y:n<s?u.top+u.height-(o.top+o.height):u.top-o.top,...q_}:null}const c=M9e(a,i,n);return i>n&&i<=s?{x:0,y:-o.height-c,...q_}:i<n&&i>=s?{x:0,y:o.height+c,...q_}:{x:0,y:0,...q_}};function M9e(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 cte="Sortable",ute=mr.createContext({activeIndex:-1,containerId:cte,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:bL,disabled:{draggable:!1,droppable:!1}});function dte(t){let{children:e,id:n,items:r,strategy:i=bL,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:c,over:u,measureDroppableContainers:d}=g9e(),f=ny(cte,n),g=o.rect!==null,m=E.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),b=s!=null,y=s?m.indexOf(s.id):-1,v=u?m.indexOf(u.id):-1,x=E.useRef(m),M=!_9e(m,x.current),S=v!==-1&&y===-1||M,A=w9e(a);vl(()=>{M&&b&&d(m)},[M,m,b,d]),E.useEffect(()=>{x.current=m},[m]);const T=E.useMemo(()=>({activeIndex:y,containerId:f,disabled:A,disableTransforms:S,items:m,overIndex:v,useDragOverlay:g,sortedRects:v9e(m,c),strategy:i}),[y,f,A.draggable,A.droppable,S,m,v,c,g,i]);return mr.createElement(ute.Provider,{value:T},e)}const E9e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return mE(n,r,i).indexOf(e)},A9e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:o,previousContainerId:c,transition:u}=t;return!u||!r||o!==a&&i===s?!1:n?!0:s!==i&&e===c},T9e={duration:200,easing:"ease"},hte="transform",C9e=Hm.Transition.toString({property:hte,duration:0,easing:"linear"}),N9e={roleDescription:"sortable"};function k9e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=E.useState(null),o=E.useRef(n);return vl(()=>{if(!e&&n!==o.current&&r.current){const c=i.current;if(c){const u=pg(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)&&s(d)}}n!==o.current&&(o.current=n)},[e,n,r,i]),E.useEffect(()=>{a&&s(null)},[a]),a}function fte(t){let{animateLayoutChanges:e=A9e,attributes:n,disabled:r,data:i,getNewIndex:a=E9e,id:s,strategy:o,resizeObserverConfig:c,transition:u=T9e}=t;const{items:d,containerId:f,activeIndex:g,disabled:m,disableTransforms:b,sortedRects:y,overIndex:v,useDragOverlay:x,strategy:M}=E.useContext(ute),S=P9e(r,m),A=d.indexOf(s),T=E.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),k=E.useMemo(()=>d.slice(d.indexOf(s)),[d,s]),{rect:N,node:I,isOver:C,setNodeRef:D}=y9e({id:s,data:T,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:O,activeNodeRect:q,attributes:R,setNodeRef:W,listeners:K,isDragging:G,over:ee,setActivatorNodeRef:Z,transform:Q}=m9e({id:s,data:T,attributes:{...N9e,...n},disabled:S.draggable}),U=JVe(D,W),$=!!F,X=$&&!b&&W_(g)&&W_(v),te=!x&&G,fe=te&&X?Q:null,be=X?fe??(o??M)({rects:y,activeNodeRect:q,activeIndex:g,overIndex:v,index:A}):null,Ne=W_(g)&&W_(v)?a({id:s,items:d,activeIndex:g,overIndex:v}):A,ie=F?.id,xe=E.useRef({activeId:ie,items:d,newIndex:Ne,containerId:f}),Re=d!==xe.current.items,he=e({active:F,containerId:f,isDragging:G,isSorting:$,id:s,index:A,items:d,newIndex:xe.current.newIndex,previousItems:xe.current.items,previousContainerId:xe.current.containerId,transition:u,wasDragging:xe.current.activeId!=null}),ht=k9e({disabled:!he,index:A,node:I,rect:N});return E.useEffect(()=>{$&&xe.current.newIndex!==Ne&&(xe.current.newIndex=Ne),f!==xe.current.containerId&&(xe.current.containerId=f),d!==xe.current.items&&(xe.current.items=d)},[$,Ne,f,d]),E.useEffect(()=>{if(ie===xe.current.activeId)return;if(ie!=null&&xe.current.activeId==null){xe.current.activeId=ie;return}const B=setTimeout(()=>{xe.current.activeId=ie},50);return()=>clearTimeout(B)},[ie]),{active:F,activeIndex:g,attributes:R,data:T,rect:N,index:A,newIndex:Ne,items:d,isOver:C,isSorting:$,isDragging:G,listeners:K,node:I,overIndex:v,over:ee,setNodeRef:U,setActivatorNodeRef:Z,setDroppableNodeRef:D,setDraggableNodeRef:W,transform:ht??be,transition:H()};function H(){if(ht||Re&&xe.current.newIndex===A)return C9e;if(!(te&&!mL(O)||!u)&&($||he))return Hm.Transition.toString({...u,property:hte})}}function P9e(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 DS(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 R9e=[Sn.Down,Sn.Right,Sn.Up,Sn.Left],pte=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(R9e.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case Sn.Down:r.top<g.top&&c.push(f);break;case Sn.Up:r.top>g.top&&c.push(f);break;case Sn.Left:r.left>g.left&&c.push(f);break;case Sn.Right:r.left<g.left&&c.push(f);break}});const u=p7e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Kee(u,"id");if(d===s?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),g=a.get(d),m=g?i.get(g.id):null,b=g?.node.current;if(b&&m&&f&&g){const v=uE(b).some((k,N)=>o[N]!==k),x=mte(f,g),M=D9e(f,g),S=v||!x?{x:0,y:0}:{x:M?r.width-m.width:0,y:M?r.height-m.height:0},A={x:m.left,y:m.top};return S.x&&S.y?A:ub(A,S)}}}};function mte(t,e){return!DS(t)||!DS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function D9e(t,e){return!DS(t)||!DS(e)||!mte(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function j9e({item:t,onClose:e}){const n=En(),{showToast:r}=ai(),[i,a]=E.useState(t.printer_id),s=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,c]=E.useState(t.scheduled_time&&!s?"scheduled":"asap"),[u,d]=E.useState(()=>t.scheduled_time&&!s?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=E.useState(t.require_previous_success),[m,b]=E.useState(t.auto_off_after),{data:y}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()});E.useEffect(()=>{const S=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const v=wt({mutationFn:S=>ke.updateQueueItem(t.id,S),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:S=>{r(S.message||"Failed to update queue item","error")}}),x=S=>{S.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,v.mutate(A)},M=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(id,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),"No printers configured"]}):l.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:S=>a(Number(S.target.value)),required:!0,children:y?.map(S=>l.jsx("option",{value:S.id,children:S.name},S.id))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_r,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[l.jsx(Zr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:M(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>b(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(yd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:v.isPending||y?.length===0,children:v.isPending?"Saving...":"Save Changes"})]})]})]})})})}function gte(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 O9e(t){if(!t)return"ASAP";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime();return r<-6e4?"Overdue":r<0?"Now":r<6e4?"In less than a minute":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)} hours`:e.toLocaleString()}function L9e({status:t}){const e={pending:{icon:_r,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:BS,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:fi,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:gs,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:N1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Wt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return l.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[l.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function hk({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:s}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=fte({id:t.id,disabled:t.status!=="pending"}),m={transform:Hm.Transform.toString(d),transition:f},b=t.status==="printing",y=t.status==="pending",v=["completed","failed","skipped","cancelled"].includes(t.status);return l.jsx("div",{ref:u,style:m,className:`
  8225. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8226. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8227. ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8228. ${b?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8229. `,children:l.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?l.jsx("div",{...o,...c,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:l.jsx(v0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?l.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]}):l.jsx("div",{className:"w-8"}),l.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?l.jsx("img",{src:ke.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:l.jsx($h,{className:"w-6 h-6"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),l.jsx(IS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:l.jsx(As,{className:"w-3.5 h-3.5"})})]}),l.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Ts,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(zu,{className:"w-3.5 h-3.5"}),gte(t.print_time_seconds)]}),y&&l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(_r,{className:"w-3.5 h-3.5"}),O9e(t.scheduled_time)]})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&l.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&&l.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:[l.jsx(yd,{className:"w-3 h-3"}),"Auto power off"]})]}),b&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&l.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[l.jsx(lo,{className:"w-3 h-3"}),t.error_message]})]}),l.jsx(L9e,{status:t.status}),l.jsxs("div",{className:"flex items-center gap-1",children:[b&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Poe,{className:"w-4 h-4"})}),y&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:l.jsx(id,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),v&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:s,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:l.jsx(Ta,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})})}function I9e(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState(null),[i,a]=E.useState(""),[s,o]=E.useState(!1),[c,u]=E.useState(null),[d,f]=E.useState(null),[g,m]=E.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[b,y]=E.useState(()=>{const Z=localStorage.getItem("queue.historySortAsc");return Z!==null?Z==="true":!1}),[v,x]=E.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[M,S]=E.useState(()=>{const Z=localStorage.getItem("queue.pendingSortAsc");return Z!==null?Z==="true":!0});E.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),E.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(b))},[b]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",v)},[v]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(M))},[M]);const A=Gee(PS(hE,{activationConstraint:{distance:8}}),PS(dE,{coordinateGetter:pte})),{data:T,isLoading:k}=vt({queryKey:["queue",n,i],queryFn:()=>ke.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:N}=vt({queryKey:["printers"],queryFn:()=>ke.getPrinters()}),I=wt({mutationFn:Z=>ke.cancelQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),C=wt({mutationFn:Z=>ke.removeFromQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=wt({mutationFn:Z=>ke.stopQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=wt({mutationFn:Z=>ke.reorderQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),O=wt({mutationFn:Z=>{const Q=new Date;return Q.setFullYear(Q.getFullYear()+1),ke.addToQueue({printer_id:Z.printer_id,archive_id:Z.archive_id,scheduled_time:Q.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Z=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),u(Z)},onError:Z=>e(Z.message||"Failed to re-queue item","error")}),q=wt({mutationFn:async()=>{const Z=T?.filter(Q=>["completed","failed","skipped","cancelled"].includes(Q.status))||[];for(const Q of Z)await ke.removeFromQueue(Q.id);return Z.length},onSuccess:Z=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Z} history item${Z!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),R=E.useMemo(()=>{const Z=T?.filter(U=>U.status==="pending")||[],Q=U=>{if(!U.scheduled_time)return 0;const $=new Date(U.scheduled_time).getTime(),X=Date.now()+4320*60*60*1e3;return $>X?0:$};return[...Z].sort((U,$)=>{let X;return v==="name"?X=(U.archive_name||"").localeCompare($.archive_name||""):v==="printer"?X=(U.printer_name||"").localeCompare($.printer_name||""):v==="time"?X=Q(U)-Q($):X=U.position-$.position,M?X:-X})},[T,v,M]),W=T?.filter(Z=>Z.status==="printing")||[],K=E.useMemo(()=>[...T?.filter(Q=>["completed","failed","skipped","cancelled"].includes(Q.status))||[]].sort((Q,U)=>{let $;return g==="name"?$=(Q.archive_name||"").localeCompare(U.archive_name||""):g==="printer"?$=(Q.printer_name||"").localeCompare(U.printer_name||""):$=new Date(U.completed_at||U.created_at).getTime()-new Date(Q.completed_at||Q.created_at).getTime(),b?-$:$}),[T,g,b]),G=E.useMemo(()=>R.reduce((Z,Q)=>Z+(Q.print_time_seconds||0),0),[R]),ee=Z=>{const{active:Q,over:U}=Z;if(!U||Q.id===U.id)return;const $=R.findIndex(te=>te.id===Q.id),X=R.findIndex(te=>te.id===U.id);if($!==-1&&X!==-1){const fe=mE(R,$,X).map((pe,be)=>({id:pe.id,position:be+1}));F.mutate(fe)}};return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsx("div",{className:"flex items-center justify-between mb-8",children:l.jsxs("div",{children:[l.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[l.jsx(fG,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),l.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[l.jsx(Nt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:l.jsx(BS,{className:"w-5 h-5 text-blue-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:l.jsx(_r,{className:"w-5 h-5 text-yellow-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:R.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:l.jsx(zu,{className:"w-5 h-5 text-bambu-green"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:gte(G)}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:l.jsx(fi,{className:"w-5 h-5 text-gray-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),l.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Z=>r(Z.target.value?Number(Z.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),N?.map(Z=>l.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),l.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:Z=>a(Z.target.value),children:[l.jsx("option",{value:"",children:"All Status"}),l.jsx("option",{value:"pending",children:"Pending"}),l.jsx("option",{value:"printing",children:"Printing"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"failed",children:"Failed"}),l.jsx("option",{value:"skipped",children:"Skipped"}),l.jsx("option",{value:"cancelled",children:"Cancelled"})]}),l.jsx("div",{className:"flex-1"}),K.length>0&&l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear History"]})]}),k?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?l.jsxs(Nt,{className:"p-12 text-center border-dashed",children:[l.jsx(Zr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),l.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),l.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.'})]}):l.jsxs("div",{className:"space-y-8",children:[W.length>0&&l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),l.jsx("div",{className:"space-y-3",children:W.map(Z=>l.jsx(hk,{item:Z,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>f({type:"stop",item:Z}),onRequeue:()=>{}},Z.id))})]}),R.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(_r,{className:"w-5 h-5 text-yellow-400"}),"Queued",l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",R.length," item",R.length!==1?"s":"",")"]}),l.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)"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.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:v,onChange:Z=>x(Z.target.value),children:[l.jsx("option",{value:"position",children:"Sort by Position"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"}),l.jsx("option",{value:"time",children:"Sort by Schedule"})]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>S(!M),title:M?"Ascending":"Descending",className:"px-2",children:M?l.jsx(dm,{className:"w-4 h-4"}):l.jsx(x0,{className:"w-4 h-4"})})]})]}),l.jsx(lte,{sensors:A,collisionDetection:Xee,onDragEnd:ee,children:l.jsx(dte,{items:R.map(Z=>Z.id),strategy:S9e,children:l.jsx("div",{className:"space-y-3",children:R.map((Z,Q)=>l.jsx(hk,{item:Z,position:Q+1,onEdit:()=>u(Z),onCancel:()=>f({type:"cancel",item:Z}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Z.id))})})})]}),K.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(fi,{className:"w-5 h-5 text-bambu-gray"}),"History",l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.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:g,onChange:Z=>m(Z.target.value),children:[l.jsx("option",{value:"date",children:"Sort by Date"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"})]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>y(!b),title:b?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:b?l.jsx(dm,{className:"w-4 h-4"}):l.jsx(x0,{className:"w-4 h-4"})})]})]}),l.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Z,Q)=>l.jsx(hk,{item:Z,position:Q+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Z}),onStop:()=>{},onRequeue:()=>O.mutate(Z)},Z.id))})]})]}),c&&l.jsx(j9e,{item:c,onClose:()=>u(null)}),d&&l.jsx(Qr,{title:d.type==="cancel"?"Cancel Scheduled Print":d.type==="stop"?"Stop Print":"Remove from History",message:d.type==="cancel"?`Are you sure you want to cancel "${d.item.archive_name||"this print"}"?`:d.type==="stop"?`Are you sure you want to stop the current print "${d.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${d.item.archive_name||"this item"}" from the queue history?`,confirmText:d.type==="cancel"?"Cancel Print":d.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{d.type==="cancel"?I.mutate(d.item.id):d.type==="stop"?D.mutate(d.item.id):C.mutate(d.item.id),f(null)},onCancel:()=>f(null)}),s&&l.jsx(Qr,{title:"Clear History",message:`Are you sure you want to remove all ${K.length} item${K.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{q.mutate(),o(!1)},onCancel:()=>o(!1)})]})}function F9e({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=E.useMemo(()=>{const c={};t.forEach(x=>{const M=x.split("T")[0];c[M]=(c[M]||0)+1});const u=new Date,d=new Date(u);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const f=[],g=[];let m=[],b=-1;const y=new Date(d);let v=0;for(;y<=u;)y.getDay()===0&&m.length>0&&(f.push(m),m=[],v++),y.getMonth()!==b&&(g.push({month:y.toLocaleDateString("en-US",{month:"short"}),weekIndex:v}),b=y.getMonth()),m.push(new Date(y)),y.setDate(y.getDate()+1);return m.length>0&&f.push(m),{weeks:f,monthLabels:g,printCounts:c}},[t,e]),a=Math.max(1,...Object.values(i)),s=c=>{if(c===0)return"bg-bambu-dark";const u=c/a;return u<=.25?"bg-bambu-green/30":u<=.5?"bg-bambu-green/50":u<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return l.jsxs("div",{className:"overflow-x-auto",children:[l.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:c,weekIndex:u},d)=>l.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(u-(r[d-1]?.weekIndex||0))*14-24}px`},children:c},d))}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((c,u)=>l.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:u%2===1?"visible":"hidden"},children:c},c))}),n.map((c,u)=>l.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=c.find(y=>y.getDay()===d);if(!f)return l.jsx("div",{className:"w-3 h-3"},d);const g=f.toISOString().split("T")[0],m=i[g]||0,b=g===new Date().toISOString().split("T")[0];return l.jsx("div",{className:`w-3 h-3 rounded-sm ${s(m)} ${b?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},d)})},u))]}),l.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[l.jsx("span",{children:"Less"}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),l.jsx("span",{children:"More"})]})]})}const K_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function U9e(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 z9e({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=U9e(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),a=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],v=g.get(y)||{date:y,filament:0,cost:0,prints:0};v.filament+=m.filament_used_grams||0,v.cost+=m.cost||0,v.prints+=1,g.set(y,v)}),Array.from(g.values()).sort((m,b)=>m.date.localeCompare(b.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),s=E.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(m=>{const b=new Date(m.completed_at||m.created_at),y=new Date(b);y.setDate(b.getDate()-b.getDay());const v=y.toISOString().split("T")[0],x=g.get(v)||{week:v,filament:0,cost:0,prints:0};x.filament+=m.filament_used_grams||0,x.cost+=m.cost||0,x.prints+=1,g.set(v,x)}),Array.from(g.values()).sort((m,b)=>m.week.localeCompare(b.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,a,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(v=>{const x=(m.filament_used_grams||0)/y.length;g.set(v,(g.get(v)||0)+x)})}),Array.from(g.entries()).map(([m,b])=>({name:m,value:Math.round(b)})).sort((m,b)=>b.value-m.value)},[i]),c=E.useMemo(()=>{const g=new Date,m=[];for(let b=5;b>=0;b--){const y=new Date(g.getFullYear(),g.getMonth()-b,1),v=new Date(g.getFullYear(),g.getMonth()-b+1,0),x=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(S=>{const A=new Date(S.completed_at||S.created_at);return A>=y&&A<=v});m.push({month:x,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 m},[t]),u=n==="7d"||n==="30d"?a:s,d=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),f=i.reduce((g,m)=>g+(m.cost||0),0);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),l.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>l.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),l.jsx(n1,{width:"100%",height:250,children:l.jsxs(rCe,{data:u,children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),l.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),l.jsx(ww,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),l.jsx(Mw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),l.jsx(Ew,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),l.jsx(MY,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):l.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(n1,{width:160,height:160,children:l.jsxs(tCe,{children:[l.jsx(KX,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>l.jsx($b,{fill:K_[m%K_.length]},`cell-${m}`))}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),l.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const b=o.reduce((v,x)=>v+x.value,0),y=b>0?(g.value/b*100).toFixed(0):0;return l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:K_[m%K_.length]}}),l.jsx("span",{className:"text-white truncate flex-1",children:g.name}),l.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):l.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),l.jsx(n1,{width:"100%",height:200,children:l.jsxs($Te,{data:c,children:[l.jsx(ww,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),l.jsx(Mw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),l.jsx(Ew,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),l.jsx(wD,{}),l.jsx(eY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function B9e({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:s}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=fte({id:t}),m={transform:Hm.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:l.jsxs("div",{ref:u,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{...o,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:l.jsx(v0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),l.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:s,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?l.jsx(pce,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):l.jsx(sce,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),l.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:l.jsx(zR,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),l.jsx("div",{className:"p-4",children:n})]})}function H9e({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const s=()=>{const A={};return t.forEach(T=>{A[T.id]=T.defaultSize||4}),A},[o,c]=E.useState(()=>{const A=localStorage.getItem(e);if(A)try{const T=JSON.parse(A);return T.sizes||(T.sizes=s()),T}catch{}return{order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()}}),[u,d]=E.useState(!1);E.useEffect(()=>{const A=()=>d(T=>!T);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(o))},[o,e]),E.useEffect(()=>{const T=t.map(k=>k.id).filter(k=>!o.order.includes(k));T.length>0&&c(k=>({...k,order:[...k.order,...T]}))},[t,o.order]);const f=Gee(PS(hE,{activationConstraint:{distance:8}}),PS(dE,{coordinateGetter:pte})),g=A=>{const{active:T,over:k}=A;k&&T.id!==k.id&&c(N=>{const I=N.order.indexOf(T.id),C=N.order.indexOf(k.id);return{...N,order:mE(N.order,I,C)}})},m=A=>{c(T=>({...T,hidden:T.hidden.includes(A)?T.hidden.filter(k=>k!==A):[...T.hidden,A]}))},b=A=>{c(T=>{const k=T.sizes[A]||4,N=k===1?2:k===2?4:1;return{...T,sizes:{...T.sizes,[A]:N}}})},y=()=>{const A={order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()};c(A),i?.()},v=o.order.map(A=>t.find(T=>T.id===A)).filter(Boolean),x=v.filter(A=>!o.hidden.includes(A.id)),M=v.filter(A=>o.hidden.includes(A.id)),S=a?.({hiddenCount:M.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return l.jsxs("div",{className:"space-y-4",children:[S,!r&&!a&&l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:y,children:[l.jsx(Km,{className:"w-4 h-4"}),"Reset Layout"]}),M.length>0&&l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[l.jsx(pm,{className:"w-4 h-4"}),M.length," Hidden"]})]}),u&&M.length>0&&l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(A=>l.jsxs("button",{onClick:()=>m(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:[l.jsx(pm,{className:"w-3 h-3"}),A.title]},A.id))})]}),l.jsx(lte,{sensors:f,collisionDetection:Xee,onDragEnd:g,children:l.jsx(dte,{items:x.map(A=>A.id),strategy:bL,children:l.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:x.map(A=>l.jsx(B9e,{id:A.id,title:A.title,isHidden:o.hidden.includes(A.id),size:o.sizes[A.id]||2,onToggleVisibility:()=>m(A.id),onToggleSize:()=>b(A.id),children:A.component},A.id))})})}),x.length===0&&l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx("p",{children:"All widgets are hidden."}),l.jsx(Le,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function $9e({stats:t,currency:e}){return l.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:l.jsx(w0,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),l.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:l.jsx(_r,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:l.jsx(w0,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:l.jsx(kk,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:l.jsx(xm,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:l.jsx(kk,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function V9e({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),l.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400"}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),l.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function G9e({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,s=(c=>c>=95&&c<=105?"#00ae42":c>105?"#3b82f6":"#f97316")(n),o=n-100;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),l.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[l.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),l.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),l.jsxs("div",{className:"space-y-2 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[l.jsx(gG,{className:"w-3 h-3"}),l.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([c,u])=>l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(c)||`Printer ${c}`}),l.jsxs("span",{className:`font-medium ${u>=95&&u<=105?"text-bambu-green":u>105?"text-blue-400":"text-orange-400"}`,children:[u.toFixed(0),"%"]})]},c))})]})]})}function W9e({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,r])=>r-n);return l.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-white",children:n}),l.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:l.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function q9e({printDates:t}){return l.jsx(F9e,{printDates:t,months:4})}function K9e({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:l.jsx(Ts,{className:"w-4 h-4 text-bambu-green"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function X9e({archives:t,currency:e}){return!t||t.length===0?l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):l.jsx(z9e,{archives:t,currency:e})}function Y9e(){const{data:t,isLoading:e}=vt({queryKey:["failureAnalysis"],queryFn:()=>ke.getFailureAnalysis({days:30})});if(e)return l.jsx("div",{className:"flex justify-center py-4",children:l.jsx(Et,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!t||t.total_prints===0)return l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const n=Object.entries(t.failures_by_reason).sort(([,r],[,i])=>i-r).slice(0,5);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ti,{className:`w-5 h-5 ${t.failure_rate>20?"text-red-400":t.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),l.jsxs("span",{className:"text-2xl font-bold text-white",children:[t.failure_rate.toFixed(1),"%"]}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"failure rate"})]}),l.jsxs("div",{className:"text-sm text-bambu-gray",children:[t.failed_prints," / ",t.total_prints," prints failed"]})]}),n.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray font-medium",children:"Top Failure Reasons"}),n.map(([r,i])=>l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("span",{className:"text-white truncate max-w-[200px]",children:r||"Unknown"}),l.jsx("span",{className:"text-bambu-gray",children:i})]},r))]}),t.trend&&t.trend.length>=2&&l.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(bG,{className:`w-4 h-4 ${t.trend[t.trend.length-1].failure_rate<t.trend[t.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),l.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",t.trend[t.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]})}function Z9e(){const{showToast:t}=ai(),[e,n]=E.useState(!1),[r,i]=E.useState(!1),[a,s]=E.useState(0),[o,c]=E.useState(0);E.useEffect(()=>{const S=()=>{try{const T=localStorage.getItem("bambusy-dashboard-layout");if(T){const k=JSON.parse(T);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}=vt({queryKey:["archiveStats"],queryFn:ke.getArchiveStats}),{data:f}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:g}=vt({queryKey:["archives"],queryFn:()=>ke.getArchives(void 0,void 0,1e3,0)}),{data:m}=vt({queryKey:["settings"],queryFn:ke.getSettings}),b=async S=>{i(!1),n(!0);try{const{blob:A,filename:T}=await ke.exportStats({format:S,days:90}),k=URL.createObjectURL(A),N=document.createElement("a");N.href=k,N.download=T,N.click(),URL.revokeObjectURL(k),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},y=m?.currency||"$",v=new Map(f?.map(S=>[String(S.id),S.name])||[]),x=g?.map(S=>S.created_at)||[];if(d)return l.jsx("div",{className:"p-4 md:p-8",children:l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const M=[{id:"quick-stats",title:"Quick Stats",component:l.jsx($9e,{stats:u,currency:y}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:l.jsx(V9e,{stats:u}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:l.jsx(G9e,{stats:u,printerMap:v}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:l.jsx(W9e,{stats:u}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:l.jsx(Y9e,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:l.jsx(q9e,{printDates:x}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:l.jsx(K9e,{stats:u,printerMap:v}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:l.jsx(X9e,{archives:g||[],currency:y}),defaultSize:4}];return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),l.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&l.jsxs(Le,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[l.jsx(pm,{className:"w-4 h-4"}),o," Hidden"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),s(S=>S+1),t("Layout reset")},children:[l.jsx(Km,{className:"w-4 h-4"}),"Reset Layout"]}),l.jsxs("div",{className:"relative",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(T1,{className:"w-4 h-4"}),"Export Stats"]}),r&&l.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:[l.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:()=>b("csv"),children:[l.jsx(to,{className:"w-4 h-4"}),"Export as CSV"]}),l.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:()=>b("xlsx"),children:[l.jsx(T1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),l.jsx(H9e,{widgets:M,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function Q9e({plug:t,onEdit:e}){const n=En(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,c]=E.useState(!1),[u,d]=E.useState(!1),{data:f,isLoading:g,refetch:m}=vt({queryKey:["smart-plug-status",t.id],queryFn:()=>ke.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),y=b?.find(k=>k.id===t.printer_id),v=wt({mutationFn:k=>ke.controlSmartPlug(t.id,k),onSuccess:()=>{m()}}),x=wt({mutationFn:k=>ke.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=wt({mutationFn:()=>ke.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=f?.state==="ON",A=f?.reachable??!1,T=v.isPending;return l.jsxs(l.Fragment,{children:[l.jsx(Nt,{className:"relative",children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${A?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:l.jsx(Qp,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),l.jsx("div",{className:"flex items-center gap-2",children:g?l.jsx(Et,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?l.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[l.jsx(wG,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:S?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):l.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[l.jsx(XR,{className:"w-4 h-4"}),l.jsx("span",{children:"Offline"})]})})]}),y&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),l.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&l.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&l.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:[l.jsx(Sh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&l.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:[l.jsx(Zr,{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}`]})]}),l.jsxs("div",{className:"flex gap-2 mb-3",children:[l.jsxs(Le,{size:"sm",variant:S?"primary":"secondary",disabled:!A||T,onClick:()=>s(!0),className:"flex-1",children:[T?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(yd,{className:"w-4 h-4"}),"On"]}),l.jsxs(Le,{size:"sm",variant:S?"secondary":"primary",disabled:!A||T,onClick:()=>c(!0),className:"flex-1",children:[T?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(WR,{className:"w-4 h-4"}),"Off"]})]}),l.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(HS,{className:"w-4 h-4"}),"Automation Settings"]}),l.jsx("span",{children:u?"-":"+"})]}),u&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.enabled,onChange:k=>x.mutate({enabled:k.target.checked}),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto On"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:k=>x.mutate({auto_on:k.target.checked}),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:k=>x.mutate({auto_off:k.target.checked}),className:"sr-only peer"}),l.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&&l.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{onClick:()=>x.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:[l.jsx(_r,{className:"w-4 h-4"}),"Time"]}),l.jsxs("button",{onClick:()=>x.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:[l.jsx($S,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),l.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:k=>x.mutate({off_delay_minutes:parseInt(k.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"})]}):l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),l.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:k=>x.mutate({off_temp_threshold:parseInt(k.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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(GR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(Qr,{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(),i(!1)},onCancel:()=>i(!1)}),a&&l.jsx(Qr,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),s(!1)},onCancel:()=>s(!1)}),o&&l.jsx(Qr,{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:()=>{v.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function J9e({plug:t,onClose:e}){const n=En(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.ip_address||""),[c,u]=E.useState(t?.username||""),[d,f]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[b,y]=E.useState(null),[v,x]=E.useState(null),[M,S]=E.useState(t?.power_alert_enabled||!1),[A,T]=E.useState(t?.power_alert_high?.toString()||""),[k,N]=E.useState(t?.power_alert_low?.toString()||""),[I,C]=E.useState(t?.schedule_enabled||!1),[D,F]=E.useState(t?.schedule_on_time||""),[O,q]=E.useState(t?.schedule_off_time||""),{data:R}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:W}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs});E.useEffect(()=>{const $=X=>{X.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const K=wt({mutationFn:()=>ke.testSmartPlugConnection(s,c||null,d||null),onSuccess:$=>{y($),x(null),!i&&$.device_name&&a($.device_name)},onError:$=>{y(null),x($.message)}}),G=wt({mutationFn:$=>ke.createSmartPlug($),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:$=>{x($.message)}}),ee=wt({mutationFn:$=>ke.updateSmartPlug(t.id,$),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:$=>{x($.message)}}),Z=R?.filter($=>!W?.some(te=>te.printer_id===$.id&&te.id!==t?.id)),Q=$=>{if($.preventDefault(),x(null),!i.trim()){x("Name is required");return}if(!s.trim()){x("IP address is required");return}const X={name:i.trim(),ip_address:s.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:M,power_alert_high:A?parseFloat(A):null,power_alert_low:k?parseFloat(k):null,schedule_enabled:I,schedule_on_time:D||null,schedule_off_time:O||null};r?ee.mutate(X):G.mutate(X)},U=G.isPending||ee.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:$=>$.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Q,className:"p-6 space-y-4",children:[v&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:s,onChange:$=>{o($.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsxs(Le,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!s.trim()||K.isPending,children:[K.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(wG,{className:"w-4 h-4"}),"Test"]})]})]}),b&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${b.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:b.success?l.jsxs(l.Fragment,{children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-medium",children:"Connected!"}),l.jsxs("p",{className:"text-sm opacity-80",children:[b.device_name&&`Device: ${b.device_name} - `,"State: ",b.state]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx(XR,{className:"w-5 h-5"}),l.jsx("span",{children:"Connection failed"})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:i,onChange:$=>a($.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"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),l.jsx("input",{type:"text",value:c,onChange:$=>u($.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),l.jsx("input",{type:"password",value:d,onChange:$=>f($.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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),l.jsxs("select",{value:g??"",onChange:$=>m($.target.value?Number($.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"No printer (manual control only)"}),Z?.map($=>l.jsx("option",{value:$.id,children:$.name},$.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Sh,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:M,onChange:$=>S($.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),M&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),l.jsx("input",{type:"number",value:A,onChange:$=>T($.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),l.jsx("input",{type:"number",value:k,onChange:$=>N($.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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:I,onChange:$=>C($.target.checked),className:"sr-only peer"}),l.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&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),l.jsx("input",{type:"time",value:D,onChange:$=>F($.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),l.jsx("input",{type:"time",value:O,onChange:$=>q($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),l.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."})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:U,className:"flex-1",children:[U?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Pn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return l.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:l.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 eGe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function tGe({provider:t,onEdit:e}){const n=En(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,c]=E.useState(null),{data:u}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=wt({mutationFn:y=>ke.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=wt({mutationFn:()=>ke.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=wt({mutationFn:()=>ke.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),b=y=>y||"";return l.jsxs(l.Fragment,{children:[l.jsx(Nt,{className:"relative",children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:l.jsx(Sh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:eGe[t.provider_type]||t.provider_type})]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&l.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&l.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),l.jsx(Pn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),d&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),l.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&l.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:l.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),l.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&l.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&l.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&l.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&l.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&l.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&l.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&l.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&&l.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&&l.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&&l.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&&l.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&&l.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&&l.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[l.jsx(C1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&l.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[l.jsx(Zr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),l.jsx("div",{className:"mb-3",children:l.jsxs(Le,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(qR,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&l.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?l.jsx(fi,{className:"w-4 h-4"}):l.jsx(gs,{className:"w-4 h-4"}),l.jsx("span",{children:o.message})]}),l.jsxs("button",{onClick:()=>s(!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:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(HS,{className:"w-4 h-4"}),"Event Settings"]}),a?l.jsx(FS,{className:"w-4 h-4"}):l.jsx(bd,{className:"w-4 h-4"})]}),a&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),l.jsx(Pn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Started"}),l.jsx(Pn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),l.jsx(Pn,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),l.jsx(Pn,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),l.jsx(Pn,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),l.jsx(Pn,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),l.jsx(Pn,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),l.jsx(Pn,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Pn,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),l.jsx(Pn,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>f.mutate({on_ams_ht_humidity_high:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>f.mutate({on_ams_ht_temperature_high:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(C1,{className:"w-4 h-4 text-purple-400"}),l.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),l.jsx(Pn,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(t.quiet_hours_end)||"07:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zr,{className:"w-4 h-4 text-emerald-400"}),l.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),l.jsx(Pn,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:["Send at ",b(t.daily_digest_time)||"08:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(GR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(Qr,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{g.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const x9=[{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 nGe({provider:t,onClose:e}){const n=En(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.provider_type||"email"),[c,u]=E.useState(t?.printer_id||null),[d,f]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[b,y]=E.useState(t?.quiet_hours_end||"07:00"),[v,x]=E.useState(t?.daily_digest_enabled||!1),[M,S]=E.useState(t?.daily_digest_time||"08:00"),[A,T]=E.useState(t?.on_print_start??!1),[k,N]=E.useState(t?.on_print_complete??!0),[I,C]=E.useState(t?.on_print_failed??!0),[D,F]=E.useState(t?.on_print_stopped??!0),[O,q]=E.useState(t?.on_print_progress??!1),[R,W]=E.useState(t?.on_printer_offline??!1),[K,G]=E.useState(t?.on_printer_error??!1),[ee,Z]=E.useState(t?.on_filament_low??!1),[Q,U]=E.useState(t?.on_maintenance_due??!1),[$,X]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([V,J])=>[V,String(J)])):{}),[te,fe]=E.useState(null),[pe,be]=E.useState(null),{data:Ne}=vt({queryKey:["printers"],queryFn:ke.getPrinters});E.useEffect(()=>{const V=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e]);const ie=wt({mutationFn:()=>ke.testNotificationConfig({provider_type:s,config:$}),onSuccess:V=>{fe(V),be(null)},onError:V=>{fe({success:!1,message:V.message})}}),xe=wt({mutationFn:V=>ke.createNotificationProvider(V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{be(V.message)}}),Re=wt({mutationFn:V=>ke.updateNotificationProvider(t.id,V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{be(V.message)}}),he=V=>{if(V.preventDefault(),be(null),!i.trim()){be("Name is required");return}const J=B(s);for(const Ae of J)if(!$[Ae.key]?.trim()){be(`${Ae.label} is required`);return}const se={name:i.trim(),provider_type:s,config:$,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?b:null,daily_digest_enabled:v,daily_digest_time:v?M:null,on_print_start:A,on_print_complete:k,on_print_failed:I,on_print_stopped:D,on_print_progress:O,on_printer_offline:R,on_printer_error:K,on_filament_low:ee,on_maintenance_due:Q};r?Re.mutate(se):xe.mutate(se)},ht=xe.isPending||Re.isPending,H=V=>{switch(V){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[]}},B=V=>H(V).filter(J=>J.required),re=H(s);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:l.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:V=>V.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:he,className:"p-6 space-y-4",children:[pe&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:pe}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:i,onChange:V=>a(V.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),l.jsx("select",{value:s,onChange:V=>{o(V.target.value),X({}),fe(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:x9.map(V=>l.jsx("option",{value:V.value,children:V.label},V.value))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:x9.find(V=>V.value===s)?.description})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),re.map(V=>l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[V.label," ",V.required&&"*"]}),V.type==="select"&&V.options?l.jsx("select",{value:$[V.key]||V.options[0]?.value||"",onChange:J=>{X({...$,[V.key]:J.target.value}),fe(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:V.options.map(J=>l.jsx("option",{value:J.value,children:J.label},J.value))}):l.jsx("input",{type:V.type,value:$[V.key]||"",onChange:J=>{X({...$,[V.key]:J.target.value}),fe(null)},placeholder:V.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"})]},V.key))]}),l.jsx("div",{className:"flex gap-2",children:l.jsxs(Le,{type:"button",variant:"secondary",onClick:()=>{fe(null),ie.mutate()},disabled:ie.isPending||!$[B(s)[0]?.key],className:"flex-1",children:[ie.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(qR,{className:"w-4 h-4"}),"Test Configuration"]})}),te&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${te.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:te.success?l.jsxs(l.Fragment,{children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsx("span",{children:te.message})]}):l.jsxs(l.Fragment,{children:[l.jsx(gs,{className:"w-5 h-5"}),l.jsx("span",{children:te.message})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),l.jsxs("select",{value:c??"",onChange:V=>u(V.target.value?Number(V.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:[l.jsx("option",{value:"",children:"All printers"}),Ne?.map(V=>l.jsx("option",{value:V.id,children:V.name},V.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),l.jsx(Pn,{checked:d,onChange:f})]}),d&&l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),l.jsx("input",{type:"time",value:g,onChange:V=>m(V.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),l.jsx("input",{type:"time",value:b,onChange:V=>y(V.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"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),l.jsx(Pn,{checked:v,onChange:x})]}),v&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),l.jsx("input",{type:"time",value:M,onChange:V=>S(V.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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Start"}),l.jsx(Pn,{checked:A,onChange:T})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Complete"}),l.jsx(Pn,{checked:k,onChange:N})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Failed"}),l.jsx(Pn,{checked:I,onChange:C})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Stopped"}),l.jsx(Pn,{checked:D,onChange:F})]}),l.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-white",children:"Progress"}),l.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),l.jsx(Pn,{checked:O,onChange:q})]})]})]}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Offline"}),l.jsx(Pn,{checked:R,onChange:W})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Error"}),l.jsx(Pn,{checked:K,onChange:G})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Pn,{checked:ee,onChange:Z})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),l.jsx(Pn,{checked:Q,onChange:U})]})]})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:ht,className:"flex-1",children:[ht?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function rGe({template:t,onClose:e}){const n=En(),r=E.useRef(null),[i,a]=E.useState(t.title_template),[s,o]=E.useState(t.body_template),[c,u]=E.useState(null),[d,f]=E.useState(!0),{data:g}=vt({queryKey:["template-variables"],queryFn:ke.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:b,isLoading:y}=vt({queryKey:["template-preview",t.event_type,i,s],queryFn:()=>ke.previewTemplate({event_type:t.event_type,title_template:i,body_template:s}),enabled:d&&i.length>0&&s.length>0});E.useEffect(()=>{const T=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const v=wt({mutationFn:T=>ke.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),x=wt({mutationFn:()=>ke.resetNotificationTemplate(t.id),onSuccess:T=>{a(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),M=T=>{if(T.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!s.trim()){u("Body is required");return}v.mutate({title_template:i,body_template:s})},S=T=>{const k=r.current;if(!k)return;const N=k.selectionStart,I=k.selectionEnd,C=s,D=C.substring(0,N),F=C.substring(I),O=D+`{${T}}`+F;o(O),setTimeout(()=>{k.focus();const q=N+T.length+2;k.setSelectionRange(q,q)},0)},A=i!==t.title_template||s!==t.body_template;return l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),l.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),l.jsx("input",{type:"text",value:i,onChange:T=>a(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),l.jsx("textarea",{ref:r,value:s,onChange:T=>o(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>l.jsxs("button",{type:"button",onClick:()=>S(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[l.jsx(pr,{className:"w-3 h-3"}),T]},T))}),l.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(pm,{className:"w-4 h-4"}),"Live Preview"]}),l.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&l.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[l.jsx(Et,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):b?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),l.jsx("div",{className:"text-white font-medium",children:b.title})]}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),l.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:b.body})]})]}):l.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[l.jsxs(Le,{type:"button",variant:"ghost",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-orange-400 hover:text-orange-300",children:[x.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(Km,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsxs(Le,{onClick:M,disabled:v.isPending||!A,children:[v.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(Ro,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const iGe={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"},aGe={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 sGe({onClose:t}){const e=En(),{showToast:n}=ai(),[r,i]=E.useState(7),[a,s]=E.useState(null),[o,c]=E.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=vt({queryKey:["notification-logs",r,o],queryFn:()=>ke.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=vt({queryKey:["notification-log-stats",r],queryFn:()=>ke.getNotificationLogStats(r)}),b=wt({mutationFn:()=>ke.clearNotificationLogs(30),onSuccess:v=>{n(v.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:v=>{n(`Failed to clear logs: ${v.message}`,"error")}}),y=v=>{const x=new Date(v),S=new Date().getTime()-x.getTime();return S<6e4?"Just now":S<36e5?`${Math.floor(S/6e4)}m ago`:S<864e5?`${Math.floor(S/36e5)}h ago`:x.toLocaleDateString()+" "+x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.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:[l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Pk,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&l.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:l.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[l.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",l.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(fi,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(gs,{className:"w-4 h-4"}),m.failure_count," failed"]})]})}),l.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[l.jsxs("select",{value:r,onChange:v=>i(Number(v.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:[l.jsx("option",{value:1,children:"Last 24 hours"}),l.jsx("option",{value:7,children:"Last 7 days"}),l.jsx("option",{value:30,children:"Last 30 days"}),l.jsx("option",{value:90,children:"Last 90 days"})]}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:o,onChange:v=>c(v.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),l.jsx("div",{className:"flex-1"}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Ta,{className:"w-4 h-4"}),"Refresh"]}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Clear Old"]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(Et,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(v=>l.jsx(oGe,{log:v,isExpanded:a===v.id,onToggle:()=>s(a===v.id?null:v.id),formatDate:y},v.id))}):l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(Pk,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function oGe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return l.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:[l.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?l.jsx(fi,{className:"w-4 h-4 text-bambu-green shrink-0"}):l.jsx(gs,{className:"w-4 h-4 text-red-400 shrink-0"}),l.jsx("span",{className:`text-xs font-medium ${aGe[t.event_type]||"text-bambu-gray"}`,children:iGe[t.event_type]||t.event_type}),l.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&l.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),l.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?l.jsx(FS,{className:"w-4 h-4 text-bambu-gray shrink-0"}):l.jsx(bd,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&l.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),l.jsx("p",{className:"text-sm text-white",children:t.title})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),l.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),l.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),l.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[l.jsxs("span",{children:["Provider: ",t.provider_type]}),l.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const X_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:l.jsx(KR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:l.jsx(Sh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:l.jsx(to,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:l.jsx(Qp,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:l.jsx(Ts,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:l.jsx(pG,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:l.jsx(ad,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:l.jsx(wh,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function lGe({onClose:t,onExport:e}){const{t:n}=Vm(),[r,i]=E.useState(()=>{const b={};return X_.forEach(y=>{b[y.id]=y.default}),b}),[a,s]=E.useState(!1),[o,c]=E.useState(!1);E.useEffect(()=>{const b=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]);const u=b=>{i(y=>({...y,[b]:!y[b]}))},d=()=>{const b={};X_.forEach(y=>{b[y.id]=!0}),i(b)},f=()=>{const b={};X_.forEach(y=>{b[y.id]=!1}),i(b)},g=Object.values(r).filter(Boolean).length,m=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:l.jsx(Nt,{className:"w-full max-w-lg",onClick:b=>b.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:l.jsx(Es,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[l.jsx("button",{onClick:d,disabled:o,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"})}),l.jsx("span",{className:"text-bambu-gray",children:"|"}),l.jsx("button",{onClick:f,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),l.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:X_.map(b=>l.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[b.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[l.jsx("input",{type:"checkbox",checked:r[b.id],onChange:()=>u(b.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),l.jsx("div",{className:`${r[b.id]?"text-bambu-green":"text-bambu-gray"}`,children:b.icon}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"text-white text-sm font-medium",children:n(b.labelKey,{defaultValue:b.defaultLabel})}),l.jsx("div",{className:"text-xs text-bambu-gray",children:b.description})]})]},b.id))}),r.archives&&l.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(wh,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[l.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),l.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&&l.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx($p,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),l.jsx(Pn,{checked:a,onChange:s})]}),a&&l.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx(ti,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),l.jsx(Le,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?l.jsxs(l.Fragment,{children:[l.jsx(Et,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):l.jsxs(l.Fragment,{children:[l.jsx(Es,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const b9={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives"};function cGe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=E.useState("options"),[a,s]=E.useState(!1),[o,c]=E.useState(null),[u,d]=E.useState(null),[f,g]=E.useState(new Set),m=E.useRef(null);E.useEffect(()=>{const S=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[t,r]);const b=S=>{const A=S.target.files?.[0];A&&c(A)},y=async()=>{if(o){i("restoring");try{const S=await e(o,a);d(S),i("result"),S.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},v=S=>{g(A=>{const T=new Set(A);return T.has(S)?T.delete(S):T.add(S),T})},x=u?.restored?Object.values(u.restored).reduce((S,A)=>S+A,0)+(u.files_restored||0):0,M=u?.total_skipped||0;return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:S=>{S.target===S.currentTarget&&r!=="restoring"&&t()},children:l.jsx(Nt,{className:"w-full max-w-lg",children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.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?l.jsx(fi,{className:"w-5 h-5"}):r==="result"&&!u?.success?l.jsx(ti,{className:"w-5 h-5"}):l.jsx(vs,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.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")]}),l.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"&&l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),r==="options"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:b}),l.jsx("button",{type:"button",onClick:()=>m.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o?l.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:o.name})]}):l.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[l.jsx(vs,{className:"w-8 h-8"}),l.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),l.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(ti,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[l.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),l.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"Printers"})," - matched by serial number"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),l.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?l.jsx(Ta,{className:"w-4 h-4 text-orange-400"}):l.jsx(N1,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),l.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"})]}),l.jsx(Pn,{checked:a,onChange:s})]})}),a&&l.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(ti,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[l.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."]})]})})]}),l.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),l.jsxs(Le,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[l.jsx(vs,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&l.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[l.jsx(Et,{className:"w-12 h-12 text-bambu-green animate-spin"}),l.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[l.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:x}),l.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),l.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[l.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:M}),l.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,S])=>S>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),l.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,S])=>S>0).map(([S,A])=>l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:b9[S]||S}),l.jsx("span",{className:"text-bambu-green font-medium",children:A})]},S)),(u.files_restored||0)>0&&l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),l.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,S])=>S>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(N1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),l.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,S])=>S>0).map(([S,A])=>{const T=u.skipped_details?.[S]||[],k=f.has(S);return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>T.length>0&&v(S),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[l.jsxs("span",{className:"text-white flex items-center gap-2",children:[b9[S]||S,T.length>0&&(k?l.jsx(FS,{className:"w-3 h-3"}):l.jsx(bd,{className:"w-3 h-3"}))]}),l.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),k&&T.length>0&&l.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((N,I)=>l.jsx("div",{children:N},I)),T.length>10&&l.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},S)})})]}),x===0&&M===0&&l.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),l.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Le,{onClick:t,children:"Close"})})]})]})})})}async function uGe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function dGe(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 hGe(){const t=En(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[a,s]=E.useState("auto"),[o,c]=E.useState(!1),[u,d]=E.useState("all"),[f,g]=E.useState(!1),{data:m,isLoading:b}=vt({queryKey:["spoolman-settings"],queryFn:uGe}),{data:y,isLoading:v,refetch:x}=vt({queryKey:["spoolman-status"],queryFn:ke.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=vt({queryKey:["printers"],queryFn:ke.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),s(m.spoolman_sync_mode||"auto"),g(!0))},[m]),E.useEffect(()=>{if(!f||!m)return;if(m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==a){const q=setTimeout(()=>{S.mutate()},500);return()=>clearTimeout(q)}},[e,r,a,f]);const S=wt({mutationFn:()=>dGe({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)}}),A=wt({mutationFn:ke.connectSpoolman,onSuccess:()=>{x()}}),T=wt({mutationFn:ke.disconnectSpoolman,onSuccess:()=>{x()}}),k=wt({mutationFn:ke.syncAllPrintersAms,onSuccess:O=>{O.success}}),N=wt({mutationFn:O=>ke.syncPrinterAms(O),onSuccess:O=>{O.success}}),I=()=>{u==="all"?k.mutate():N.mutate(u)},C=k.isPending||N.isPending,D=u==="all"?k.data:N.data,F=u==="all"?k.isSuccess:N.isSuccess;return b?l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(fm,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),l.jsx(Rt,{children:l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(Et,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(fm,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),S.isPending&&l.jsx(Et,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&l.jsx(zh,{className:"w-4 h-4 text-bambu-green"})]})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Enable Spoolman"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:e,onChange:O=>n(O.target.checked),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),l.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:O=>i(O.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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),l.jsxs("select",{value:a,onChange:O=>s(O.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:[l.jsx("option",{value:"auto",children:"Automatic"}),l.jsx("option",{value:"manual",children:"Manual Only"})]}),l.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&&l.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?l.jsx(Et,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?l.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[l.jsx(zh,{className:"w-4 h-4"}),"Connected"]}):l.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Disconnected"]})]}),l.jsx("div",{className:"flex gap-2",children:y?.connected?l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Vle,{className:"w-4 h-4"}),"Disconnect"]}):l.jsxs(Le,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Dk,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&l.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),y?.connected&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsxs("select",{value:u,onChange:O=>d(O.target.value==="all"?"all":Number(O.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:[l.jsx("option",{value:"all",children:"All Printers"}),M?.map(O=>l.jsx("option",{value:O.id,children:O.name},O.id))]}),l.jsx(bd,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:I,disabled:C,children:[C?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Ta,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&D&&l.jsx("div",{className:`mt-2 p-2 rounded text-sm ${D.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:D.success?`Synced ${D.synced_count} trays successfully`:`Synced ${D.synced_count} trays with ${D.errors.length} errors`})]})]})]})}function fGe({link:t,onClose:e}){const n=En(),{theme:r}=xb(),i=!!t,a=E.useRef(null),[s,o]=E.useState(t?.name||""),[c,u]=E.useState(t?.url||""),[d,f]=E.useState(t?.icon||"link"),[g,m]=E.useState(!!t?.custom_icon),[b,y]=E.useState(t?.custom_icon?ke.getExternalLinkIconUrl(t.id):null),[v,x]=E.useState(null),[M,S]=E.useState(null);E.useEffect(()=>{const F=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const A=wt({mutationFn:async F=>{const O=await ke.createExternalLink(F);return v?await ke.uploadExternalLinkIcon(O.id,v):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),T=wt({mutationFn:async F=>{let O=await ke.updateExternalLink(t.id,F);return v?O=await ke.uploadExternalLinkIcon(t.id,v):!g&&t?.custom_icon&&(O=await ke.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),k=F=>{const O=F.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){S("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){S("Image file must be less than 1MB");return}x(O),m(!0);const R=new FileReader;R.onload=W=>{y(W.target?.result)},R.readAsDataURL(O)}},N=()=>{x(null),y(null),m(!1),a.current&&(a.current.value="")},I=F=>{if(F.preventDefault(),S(null),!s.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 O={name:s.trim(),url:c.trim(),icon:d};i?T.mutate(O):A.mutate(O)},C=A.isPending||T.isPending,D=VS(d);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&b?l.jsx("img",{src:b,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):l.jsx(D,{className:"w-5 h-5"})}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:I,className:"p-6 space-y-4",children:[M&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:M}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:s,onChange:F=>o(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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),l.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"})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),l.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),l.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}),g&&b?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:b,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),l.jsx("button",{type:"button",onClick:N,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:l.jsx(Rn,{className:"w-4 h-4"})})]}):l.jsxs(Le,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[l.jsx(vs,{className:"w-4 h-4"}),"Upload"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),l.jsx(Xue,{value:d,onChange:f})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:C,className:"flex-1",children:[C?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function pGe(){const t=En(),[e,n]=E.useState(!1),[r,i]=E.useState(null),[a,s]=E.useState(null),[o,c]=E.useState(null),{data:u,isLoading:d}=vt({queryKey:["external-links"],queryFn:ke.getExternalLinks}),f=wt({mutationFn:M=>ke.deleteExternalLink(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=wt({mutationFn:M=>ke.reorderExternalLinks(M),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(M,S)=>{c(S),M.dataTransfer.effectAllowed="move"},b=M=>{M.preventDefault(),M.dataTransfer.dropEffect="move"},y=(M,S)=>{if(M.preventDefault(),o===null||o===S||!u)return;const A=u.map(I=>I.id),T=A.indexOf(o),k=A.indexOf(S);if(T===-1||k===-1)return;const N=[...A];N.splice(T,1),N.splice(k,0,o),g.mutate(N),c(null)},v=M=>{s(M)},x=()=>{a&&(f.mutate(a.id),s(null))};return l.jsxs(l.Fragment,{children:[l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Dk,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),l.jsxs(Le,{size:"sm",onClick:()=>n(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Link"]})]})}),l.jsxs(Rt,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(Et,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(M=>{const S=VS(M.icon);return l.jsxs("div",{draggable:!0,onDragStart:A=>m(A,M.id),onDragOver:b,onDrop:A=>y(A,M.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${o===M.id?"opacity-50":""}`,children:[l.jsx(v0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:l.jsx(S,{className:"w-4 h-4"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-white font-medium truncate",children:M.name}),l.jsx(As,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),l.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:M.url})]}),l.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l.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:l.jsx(id,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>v(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:l.jsx(Rn,{className:"w-4 h-4"})})]})]},M.id)})}):l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(Dk,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{children:"No external links configured"}),l.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&l.jsx(fGe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&l.jsx(Qr,{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:x,onCancel:()=>s(null)})]})}function mGe(){const t=En(),{t:e,i18n:n}=Vm(),{showToast:r,showPersistentToast:i,dismissToast:a}=ai(),[s,o]=E.useState(null),[c,u]=E.useState(!1),[d,f]=E.useState(null),[g,m]=E.useState(!1),[b,y]=E.useState(null),[v,x]=E.useState(null),[M,S]=E.useState(!1),[A,T]=E.useState(AG()),[k,N]=E.useState("general"),[I,C]=E.useState(!1),[D,F]=E.useState(""),[O,q]=E.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[R,W]=E.useState(null),[K,G]=E.useState(null),[ee,Z]=E.useState(!1),[Q,U]=E.useState(!1),[$,X]=E.useState(null),[te,fe]=E.useState(!1),[pe,be]=E.useState(!1),[Ne,ie]=E.useState(!1),[xe,Re]=E.useState(!1),he=ce=>{T(ce),Que(ce)},ht=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:H,isLoading:B}=vt({queryKey:["settings"],queryFn:ke.getSettings}),{data:re,isLoading:V}=vt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:J,isLoading:se}=vt({queryKey:["smart-plugs-energy",re?.map(ce=>ce.id)],queryFn:async()=>{if(!re||re.length===0)return null;const ce=await Promise.all(re.filter(Vt=>Vt.enabled).map(async Vt=>{try{const On=await ke.getSmartPlugStatus(Vt.id);return{plug:Vt,status:On}}catch{return{plug:Vt,status:null}}}));let st=0,xt=0,St=0,Qt=0,Ot=0;for(const{status:Vt}of ce)Vt?.reachable&&Vt.energy&&(Ot++,Vt.energy.power!=null&&(st+=Vt.energy.power),Vt.energy.today!=null&&(xt+=Vt.energy.today),Vt.energy.yesterday!=null&&(St+=Vt.energy.yesterday),Vt.energy.total!=null&&(Qt+=Vt.energy.total));return{totalPower:st,totalToday:xt,totalYesterday:St,totalLifetime:Qt,reachableCount:Ot,totalPlugs:re.filter(Vt=>Vt.enabled).length}},enabled:k==="plugs"&&!!re&&re.length>0,refetchInterval:k==="plugs"?1e4:!1}),{data:Ae,isLoading:Pe}=vt({queryKey:["notification-providers"],queryFn:ke.getNotificationProviders}),{data:Se,isLoading:z}=vt({queryKey:["api-keys"],queryFn:ke.getAPIKeys}),L=wt({mutationFn:ce=>ke.createAPIKey(ce),onSuccess:ce=>{W(ce.key||null),C(!1),F(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:ce=>{r(`Failed to create API key: ${ce.message}`,"error")}}),ne=wt({mutationFn:ce=>ke.deleteAPIKey(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:ce=>{r(`Failed to delete API key: ${ce.message}`,"error")}}),{data:ve}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:we,isLoading:ye}=vt({queryKey:["notification-templates"],queryFn:ke.getNotificationTemplates}),{data:nt}=vt({queryKey:["ffmpeg-status"],queryFn:ke.checkFfmpeg}),{data:Be}=vt({queryKey:["version"],queryFn:ke.getVersion}),{data:ue,refetch:Ve,isRefetching:Fe}=vt({queryKey:["updateCheck"],queryFn:ke.checkForUpdates,staleTime:300*1e3}),{data:oe,refetch:et}=vt({queryKey:["updateStatus"],queryFn:ke.getUpdateStatus,refetchInterval:ce=>{const st=ce.state.data;return st?.status==="downloading"||st?.status==="installing"?1e3:!1}}),He=wt({mutationFn:ke.applyUpdate,onSuccess:()=>{et()}}),[Ke,ct]=E.useState(null),de=wt({mutationFn:ke.testAllNotificationProviders,onSuccess:ce=>{ct(ce),t.invalidateQueries({queryKey:["notification-providers"]}),ce.failed===0?r(`All ${ce.tested} providers tested successfully!`,"success"):r(`${ce.success}/${ce.tested} providers succeeded`,ce.failed>0?"error":"success")},onError:ce=>{r(`Failed to test providers: ${ce.message}`,"error")}}),Ye=wt({mutationFn:async ce=>{if(!re)return{success:0,failed:0};const st=re.filter(St=>St.enabled),xt=await Promise.all(st.map(async St=>{try{return await ke.controlSmartPlug(St.id,ce),{success:!0}}catch{return{success:!1}}}));return{success:xt.filter(St=>St.success).length,failed:xt.filter(St=>!St.success).length}},onSuccess:(ce,st)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),ce.failed===0?r(`All ${ce.success} plugs turned ${st}`,"success"):r(`${ce.success} plugs turned ${st}, ${ce.failed} failed`,"error")},onError:ce=>{r(`Failed: ${ce.message}`,"error")}}),ge=E.useRef(null),Ue=E.useRef(!0);E.useEffect(()=>{H&&!s&&(o(H),setTimeout(()=>{Ue.current=!1},100))},[H,s]);const Ce=wt({mutationFn:ke.updateSettings,onSuccess:ce=>{t.setQueryData(["settings"],ce),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:ce=>{r(`Failed to save: ${ce.message}`,"error")}});E.useEffect(()=>{if(!(Ue.current||!s||!H||!(H.auto_archive!==s.auto_archive||H.save_thumbnails!==s.save_thumbnails||H.capture_finish_photo!==s.capture_finish_photo||H.default_filament_cost!==s.default_filament_cost||H.currency!==s.currency||H.energy_cost_per_kwh!==s.energy_cost_per_kwh||H.energy_tracking_mode!==s.energy_tracking_mode||H.check_updates!==s.check_updates||H.notification_language!==s.notification_language||H.telemetry_enabled!==s.telemetry_enabled||H.ams_humidity_good!==s.ams_humidity_good||H.ams_humidity_fair!==s.ams_humidity_fair||H.ams_temp_good!==s.ams_temp_good||H.ams_temp_fair!==s.ams_temp_fair||H.ams_history_retention_days!==s.ams_history_retention_days||H.date_format!==s.date_format||H.time_format!==s.time_format||H.default_printer_id!==s.default_printer_id)))return ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{Ce.mutate(s)},500),()=>{ge.current&&clearTimeout(ge.current)}},[s,H,Ce]);const _e=E.useCallback((ce,st)=>{o(xt=>xt?{...xt,[ce]:st}:null)},[]);return B||!s?l.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-8",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),l.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),l.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>N("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),l.jsxs("button",{onClick:()=>N("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Qp,{className:"w-4 h-4"}),"Smart Plugs",re&&re.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:re.length})]}),l.jsxs("button",{onClick:()=>N("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Sh,{className:"w-4 h-4"}),"Notifications",Ae&&Ae.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ae.length})]}),l.jsxs("button",{onClick:()=>N("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx($p,{className:"w-4 h-4"}),"API Keys",Se&&Se.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Se.length})]})]}),k==="general"&&l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(y0,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),l.jsx("select",{value:n.language,onChange:ce=>n.changeLanguage(ce.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:PF.map(ce=>l.jsxs("option",{value:ce.code,children:[ce.nativeName," (",ce.name,")"]},ce.code))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),l.jsx("select",{value:A,onChange:ce=>he(ce.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:A0.map(ce=>l.jsx("option",{value:ce.to,children:e(ce.labelKey)},ce.id))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),l.jsxs("select",{value:s.date_format||"system",onChange:ce=>_e("date_format",ce.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:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),l.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),l.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),l.jsxs("select",{value:s.time_format||"system",onChange:ce=>_e("time_format",ce.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:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),l.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),l.jsxs("select",{value:s.default_printer_id??"",onChange:ce=>_e("default_printer_id",ce.target.value?Number(ce.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:[l.jsx("option",{value:"",children:"No default (ask each time)"}),ve?.map(ce=>l.jsx("option",{value:ce.id,children:ce.name},ce.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Sidebar order"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:ht,children:[l.jsx(Km,{className:"w-4 h-4"}),"Reset"]})]})]})]}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Auto-archive prints"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.auto_archive,onChange:ce=>_e("auto_archive",ce.target.checked),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Save thumbnails"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.save_thumbnails,onChange:ce=>_e("save_thumbnails",ce.target.checked),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Capture finish photo"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.capture_finish_photo,onChange:ce=>_e("capture_finish_photo",ce.target.checked),className:"sr-only peer"}),l.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.capture_finish_photo&&nt&&!nt.installed&&l.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[l.jsx(ti,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"text-sm",children:[l.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),l.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:s.default_filament_cost,onChange:ce=>_e("default_filament_cost",parseFloat(ce.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),l.jsxs("select",{value:s.currency,onChange:ce=>_e("currency",ce.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:[l.jsx("option",{value:"USD",children:"USD ($)"}),l.jsx("option",{value:"EUR",children:"EUR (€)"}),l.jsx("option",{value:"GBP",children:"GBP (£)"}),l.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),l.jsx("option",{value:"JPY",children:"JPY (¥)"}),l.jsx("option",{value:"CNY",children:"CNY (¥)"}),l.jsx("option",{value:"CAD",children:"CAD ($)"}),l.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:s.energy_cost_per_kwh,onChange:ce=>_e("energy_cost_per_kwh",parseFloat(ce.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),l.jsxs("select",{value:s.energy_tracking_mode||"total",onChange:ce=>_e("energy_tracking_mode",ce.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:[l.jsx("option",{value:"print",children:"Prints Only"}),l.jsx("option",{value:"total",children:"Total Consumption"})]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(lG,{className:"w-4 h-4 text-blue-400"}),l.jsx("span",{className:"font-medium",children:"Humidity"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:s.ams_humidity_good??40,onChange:ce=>_e("ams_humidity_good",parseInt(ce.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"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:s.ams_humidity_fair??60,onChange:ce=>_e("ams_humidity_fair",parseInt(ce.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"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),l.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx($S,{className:"w-4 h-4 text-orange-400"}),l.jsx("span",{className:"font-medium",children:"Temperature"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:s.ams_temp_good??28,onChange:ce=>_e("ams_temp_good",parseFloat(ce.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"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:s.ams_temp_fair??35,onChange:ce=>_e("ams_temp_fair",parseFloat(ce.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"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),l.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(fm,{className:"w-4 h-4 text-purple-400"}),l.jsx("span",{className:"font-medium",children:"History Retention"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"1",max:"365",value:s.ams_history_retention_days??30,onChange:ce=>_e("ams_history_retention_days",parseInt(ce.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"}),l.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]}),l.jsx(hGe,{})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[l.jsx(pGe,{}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Check for updates"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.check_updates,onChange:ce=>_e("check_updates",ce.target.checked),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white",children:e("settings.telemetry")}),l.jsxs("button",{onClick:()=>ie(!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:[l.jsx(_0,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.telemetry_enabled,onChange:ce=>_e("telemetry_enabled",ce.target.checked),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Current version"}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Be?.version||"..."]})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>Ve(),disabled:Fe,children:[Fe?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Ta,{className:"w-4 h-4"}),"Check now"]})]}),ue?.update_available?l.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ue.release_name})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[ue.release_notes&&l.jsx("button",{onClick:()=>Re(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),ue.release_url&&l.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:l.jsx(As,{className:"w-4 h-4"})})]})]}),oe?.status==="downloading"||oe?.status==="installing"?l.jsxs("div",{className:"mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[l.jsx(Et,{className:"w-4 h-4 animate-spin"}),l.jsx("span",{children:oe.message})]}),l.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:l.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${oe.progress}%`}})})]}):oe?.status==="complete"?l.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:oe.message}):oe?.status==="error"?l.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:oe.error||oe.message}):l.jsxs(Le,{className:"mt-3",onClick:()=>He.mutate(),disabled:He.isPending,children:[He.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Es,{className:"w-4 h-4"}),"Install Update"]})]}):ue?.error?l.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?l.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),l.jsxs(Nt,{children:[l.jsx(Ha,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Backup Data"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>fe(!0),children:[l.jsx(Es,{className:"w-4 h-4"}),"Export"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Restore Backup"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>be(!0),children:[l.jsx(vs,{className:"w-4 h-4"}),"Restore"]})]}),l.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear"]})]})}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),l.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."})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>U(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),k==="plugs"&&l.jsxs("div",{className:"max-w-4xl",children:[l.jsxs("div",{className:"flex items-start justify-between mb-6",children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Qp,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[re&&re.filter(ce=>ce.enabled).length>1&&l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>X("on"),disabled:Ye.isPending,title:"Turn all plugs on",children:[Ye.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(yd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),l.jsxs(Le,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>X("off"),disabled:Ye.isPending,title:"Turn all plugs off",children:[Ye.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(WR,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),l.jsxs(Le,{className:"whitespace-nowrap",onClick:()=>{f(null),u(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),re&&re.length>0&&l.jsxs(Nt,{className:"mb-6",children:[l.jsx(Ha,{children:l.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[l.jsx(xm,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",se&&l.jsx(Et,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),l.jsx(Rt,{children:J?l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(xm,{className:"w-3 h-3"}),"Current Power"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[J.totalPower.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[J.reachableCount,"/",J.totalPlugs," plugs online"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(Zr,{className:"w-3 h-3"}),"Today"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[J.totalToday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(J.totalToday*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(yG,{className:"w-3 h-3"}),"Yesterday"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[J.totalYesterday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(J.totalYesterday*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(kk,{className:"w-3 h-3"}),"Total"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[J.totalLifetime.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(J.totalLifetime*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]})]}):se?null:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),V?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):re&&re.length>0?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:re.map(ce=>l.jsx(Q9e,{plug:ce,onEdit:st=>{f(st),u(!0)}},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Qp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),l.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),l.jsxs(Le,{onClick:()=>{f(null),u(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),k==="notifications"&&l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Sh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>S(!0),children:[l.jsx(Pk,{className:"w-4 h-4"}),"Log"]}),Ae&&Ae.length>0&&l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>{ct(null),de.mutate()},disabled:de.isPending,children:[de.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(qR,{className:"w-4 h-4"}),"Test All"]}),l.jsxs(Le,{size:"sm",onClick:()=>{y(null),m(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add"]})]})]}),l.jsx(Nt,{className:"mb-4",children:l.jsx(Rt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),l.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),l.jsx("select",{value:s.notification_language||"en",onChange:ce=>_e("notification_language",ce.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:PF.map(ce=>l.jsx("option",{value:ce.code,children:ce.nativeName},ce.code))})]})})}),Ke&&l.jsx(Nt,{className:"mb-4",children:l.jsxs(Rt,{className:"py-3",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),l.jsx("button",{onClick:()=>ct(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(fi,{className:"w-4 h-4"}),Ke.success," passed"]}),Ke.failed>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(gs,{className:"w-4 h-4"}),Ke.failed," failed"]})]}),Ke.results.filter(ce=>!ce.success).length>0&&l.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ke.results.filter(ce=>!ce.success).map(ce=>l.jsxs("div",{className:"text-xs text-red-400",children:[l.jsxs("span",{className:"font-medium",children:[ce.provider_name,":"]})," ",ce.message]},ce.provider_id))})]})}),Pe?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(Et,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ae&&Ae.length>0?l.jsx("div",{className:"space-y-3",children:Ae.map(ce=>l.jsx(tGe,{provider:ce,onEdit:st=>{y(st),m(!0)}},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Sh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),l.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),l.jsxs(Le,{size:"sm",onClick:()=>{y(null),m(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[l.jsx(to,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),ye?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(Et,{className:"w-6 h-6 text-bambu-green animate-spin"})}):we&&we.length>0?l.jsx("div",{className:"space-y-2",children:we.map(ce=>l.jsx(Nt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>x(ce),children:l.jsx(Rt,{className:"py-2.5 px-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-white font-medium text-sm truncate",children:ce.name}),l.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:ce.title_template})]}),l.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:st=>{st.stopPropagation(),x(ce)},children:l.jsx(GR,{className:"w-4 h-4 text-bambu-gray"})})]})})},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(to,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),k==="apikeys"&&l.jsxs("div",{className:"max-w-3xl",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx($p,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks. Use these keys to control your printers from automation tools like Home Assistant."})]}),l.jsxs(Le,{size:"sm",onClick:()=>C(!0),className:"flex-shrink-0",children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]})]}),R&&l.jsx(Nt,{className:"mb-6 border-bambu-green",children:l.jsx(Rt,{className:"py-4",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(fi,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),l.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[l.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:R}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(R);else{const ce=document.createElement("textarea");ce.value=R,ce.style.position="fixed",ce.style.left="-999999px",document.body.appendChild(ce),ce.select(),document.execCommand("copy"),document.body.removeChild(ce)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:l.jsx(Hh,{className:"w-4 h-4"})})]}),l.jsx(Le,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>W(null),children:"Dismiss"})]})]})})}),I&&l.jsxs(Nt,{className:"mb-6",children:[l.jsx(Ha,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),l.jsx("input",{type:"text",value:D,onChange:ce=>F(ce.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_read_status,onChange:ce=>q(st=>({...st,can_read_status:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Read Status"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_queue,onChange:ce=>q(st=>({...st,can_queue:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Manage Queue"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_control_printer,onChange:ce=>q(st=>({...st,can_control_printer:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Control Printer"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.jsxs(Le,{onClick:()=>L.mutate({name:D||"Unnamed Key",...O}),disabled:L.isPending,children:[L.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]}),l.jsx(Le,{variant:"secondary",onClick:()=>C(!1),children:"Cancel"})]})]})]}),z?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Se&&Se.length>0?l.jsx("div",{className:"space-y-3",children:Se.map(ce=>l.jsx(Nt,{children:l.jsx(Rt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx($p,{className:`w-5 h-5 ${ce.enabled?"text-bambu-green":"text-bambu-gray"}`}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium",children:ce.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[ce.key_prefix,"••••••••",ce.last_used&&` · Last used: ${new Date(ce.last_used).toLocaleDateString()}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex gap-1 text-xs",children:[ce.can_read_status&&l.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),ce.can_queue&&l.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),ce.can_control_printer&&l.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>G(ce.id),children:l.jsx(Rn,{className:"w-4 h-4 text-red-400"})})]})]})})},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx($p,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),l.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),l.jsxs(Le,{onClick:()=>C(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),l.jsxs(Nt,{className:"mt-6",children:[l.jsx(Ha,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),l.jsxs(Rt,{className:"space-y-3 text-sm",children:[l.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",l.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),l.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-green-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),l.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),l.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),l.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-red-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),l.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),K!==null&&l.jsx(Qr,{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:()=>{ne.mutate(K),G(null)},onCancel:()=>G(null)}),c&&l.jsx(J9e,{plug:d,onClose:()=>{u(!1),f(null)}}),g&&l.jsx(nGe,{provider:b,onClose:()=>{m(!1),y(null)}}),v&&l.jsx(rGe,{template:v,onClose:()=>x(null)}),M&&l.jsx(sGe,{onClose:()=>S(!1)}),ee&&l.jsx(Qr,{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()=>{Z(!1);try{const ce=await ke.clearNotificationLogs(30);r(ce.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>Z(!1)}),Q&&l.jsx(Qr,{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:()=>{U(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>U(!1)}),$&&l.jsx(Qr,{title:`Turn All Plugs ${$==="on"?"On":"Off"}`,message:`This will turn ${$==="on"?"ON":"OFF"} all ${re?.filter(ce=>ce.enabled).length||0} enabled smart plugs. ${$==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${$==="on"?"On":"Off"}`,variant:$==="off"?"danger":"warning",onConfirm:()=>{const ce=$;X(null),Ye.mutate(ce)},onCancel:()=>X(null)}),te&&l.jsx(lGe,{onClose:()=>fe(!1),onExport:async ce=>{fe(!1);const st="backup-progress",xt=ce.archives;xt&&i(st,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:St,filename:Qt}=await ke.exportBackup(ce);xt&&a(st);const Ot=URL.createObjectURL(St),Vt=document.createElement("a");Vt.href=Ot,Vt.download=Qt,Vt.click(),URL.revokeObjectURL(Ot),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{xt&&a(st),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),pe&&l.jsx(cGe,{onClose:()=>be(!1),onRestore:async(ce,st)=>await ke.importBackup(ce,st),onSuccess:()=>{t.invalidateQueries()}}),Ne&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>ie(!1),children:l.jsxs(Nt,{className:"w-full max-w-lg",onClick:ce=>ce.stopPropagation(),children:[l.jsxs(Ha,{className:"flex flex-row items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zce,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),l.jsx("button",{onClick:()=>ie(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem3")})]})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(gs,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),l.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),l.jsx(Le,{onClick:()=>ie(!1),className:"w-full",children:e("common.close")})]})]})}),xe&&ue?.release_notes&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Re(!1),children:l.jsxs(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:ce=>ce.stopPropagation(),children:[l.jsxs(Ha,{className:"flex flex-row items-center justify-between shrink-0",children:[l.jsxs("div",{children:[l.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&&l.jsx("p",{className:"text-sm text-bambu-gray",children:ue.release_name})]}),l.jsx("button",{onClick:()=>Re(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx(Rt,{className:"overflow-y-auto flex-1",children:l.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:ue.release_notes})}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[ue.release_url&&l.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:l.jsxs(Le,{variant:"secondary",className:"w-full",children:[l.jsx(As,{className:"w-4 h-4"}),"View on GitHub"]})}),l.jsx(Le,{onClick:()=>Re(!1),className:"flex-1",children:"Close"})]})]})})]})}const xte=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},gGe=t=>t.startsWith("HH")?"HF":"S",xGe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},AR=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 fk({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:s}){const o=gGe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return l.jsxs("div",{className:"flex items-center gap-2",children:[r&&l.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?l.jsx(Vh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(mm,{className:"w-4 h-4"})}),l.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:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:xte(t.k_value)}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),s&&l.jsx("span",{title:"Has note",children:l.jsx(mG,{className:"w-3 h-3 text-yellow-500"})}),l.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",c]})]}),s&&l.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:s,children:["Note: ",s.length>50?s.substring(0,50)+"...":s]})]}),!r&&n&&l.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:l.jsx(Hh,{className:"w-4 h-4"})})]})}function pk({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:s=null,onClose:o,onSave:c,onSaveNote:u}){const{showToast:d}=ai(),[f,g]=E.useState(t?.name||""),[m,b]=E.useState(t?.k_value?xte(t.k_value):"0.020"),[y,v]=E.useState(t?.filament_id||""),[x,M]=E.useState(t?.nozzle_id?xGe(t.nozzle_id):"HH00"),[S,A]=E.useState(t?.nozzle_diameter||n),[T,k]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[N,I]=E.useState(!1),[C,D]=E.useState({current:0,total:0}),[F,O]=E.useState(a),q=mr.useMemo(()=>{const Q=new Map;for(const U of r)if(U.filament_id&&!Q.has(U.filament_id)){const $=AR(U.name||"");Q.set(U.filament_id,{id:U.filament_id,name:$||U.filament_id})}return Array.from(Q.values()).sort((U,$)=>U.name.localeCompare($.name))},[r]),R=wt({mutationFn:Q=>(console.log("[KProfile] Calling API..."),ke.setKProfile(e,Q)),onSuccess:Q=>{if(console.log("[KProfile] Save success:",Q),d("K-profile saved"),u&&F!==a){let U;F===""&&s?U=s:t&&t.slot_id>0?U=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:U=`name_${f}_${y}`,u(U,F)}I(!0),setTimeout(()=>{I(!1),c()},2500)},onError:Q=>{console.error("[KProfile] Save error:",Q),d(Q.message,"error"),I(!1)}}),W=wt({mutationFn:Q=>(console.log("[KProfile] Deleting profile..."),ke.deleteKProfile(e,Q)),onSuccess:Q=>{console.log("[KProfile] Delete success:",Q),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:Q=>{console.error("[KProfile] Delete error:",Q),d(Q.message,"error"),I(!1)}}),[K,G]=E.useState(!1),ee=()=>{t&&W.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Z=async Q=>{if(Q.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const U=parseFloat(m).toFixed(6),$=`${x}-${S}`;if(t||T.length===1){const te={name:f,k_value:U,filament_id:y,nozzle_id:$,nozzle_diameter:S,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",te),R.mutate(te);return}I(!0),D({current:1,total:T.length});const X=T.map(te=>({name:f,k_value:U,filament_id:y,nozzle_id:$,nozzle_diameter:S,extruder_id:te,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${X.length} profiles in batch:`,X);try{if(await ke.setKProfilesBatch(e,X),d(`K-profile saved to ${T.length} extruders`),u&&F){const te=`name_${f}_${y}`;u(te,F)}}catch(te){console.error("[KProfile] Failed to save batch:",te),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),c()},3e3)};return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[l.jsxs(Nt,{className:"w-full max-w-md relative",children:[N&&l.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),l.jsx("p",{className:"text-white font-medium",children:C.total>1?`Saving to extruder ${C.current}/${C.total}...`:"Syncing with printer..."}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),l.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:N,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Z,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),l.jsx("input",{type:"text",value:f,onChange:Q=>g(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),l.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:Q=>{const U=Q.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&b(U)},onBlur:Q=>{const U=parseFloat(Q.target.value);isNaN(U)||b((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}),l.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),l.jsxs("select",{value:y,onChange:Q=>{const U=Q.target.value;if(v(U),!t&&U&&!f){const $=q.find(X=>X.id===U);$&&g(`${x==="HH00"?"HF":"S"} ${$.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:[l.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&l.jsx("option",{value:t.filament_id,children:q.find(Q=>Q.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Q=>l.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),!t&&q.length===0&&l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),l.jsxs("select",{value:x,onChange:Q=>{const U=Q.target.value;if(M(U),!t&&y&&!f){const $=q.find(X=>X.id===y);$&&g(`${U==="HS00"?"HF":"S"} ${$.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:[l.jsx("option",{value:"HH00",children:"High Flow"}),l.jsx("option",{value:"HS00",children:"Standard"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),l.jsxs("select",{value:S,onChange:Q=>A(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?l.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"}):l.jsxs("div",{className:"flex gap-4",children:[l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:Q=>{Q.target.checked?k([...T,1]):k(T.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"}),l.jsx("span",{className:"text-white",children:"Left"})]}),l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:Q=>{Q.target.checked?k([...T,0]):k(T.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"}),l.jsx("span",{className:"text-white",children:"Right"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),l.jsx("textarea",{value:F,onChange:Q=>O(Q.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),l.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:W.isPending||N,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"})}),l.jsx(Le,{type:"button",variant:"secondary",onClick:o,disabled:N,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:R.isPending||N,className:"flex-1",children:[R.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(HR,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:l.jsx(Nt,{className:"w-full max-w-sm",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(Rn,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>{G(!1),ee()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const Y_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function bGe(){const{showToast:t}=ai(),[e,n]=E.useState(null),[r,i]=E.useState(()=>localStorage.getItem(Y_.NOZZLE_DIAMETER)||"0.4"),[a,s]=E.useState(null),[o,c]=E.useState(!1),[u,d]=E.useState(null),[f,g]=E.useState(""),[m,b]=E.useState("all"),[y,v]=E.useState("all"),[x,M]=E.useState(()=>localStorage.getItem(Y_.SORT_OPTION)||"name"),[S,A]=E.useState(!1),[T,k]=E.useState(new Set),[N,I]=E.useState(!1),[C,D]=E.useState(!1),F=V=>`${V.slot_id}_${V.extruder_id}`;E.useEffect(()=>{localStorage.setItem(Y_.NOZZLE_DIAMETER,r)},[r]),E.useEffect(()=>{localStorage.setItem(Y_.SORT_OPTION,x)},[x]);const{data:O,isLoading:q}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:R,isLoading:W,isFetching:K,error:G,refetch:ee}=vt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const V=await ke.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",V?.profiles?.length||0,"profiles"),V},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Z}=vt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>ke.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Q,refetch:U}=vt({queryKey:["kprofile-notes",e],queryFn:()=>ke.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),$=G?.message?.includes("not connected");E.useEffect(()=>{if(!e&&O&&O.length>0){const V=O.find(J=>J.is_active);V&&n(V.id)}},[e,O]),E.useEffect(()=>{if(e){const V=setTimeout(()=>{ee()},150);return()=>clearTimeout(V)}},[e,r]);const X=O?.filter(V=>V.is_active)||[],te=mr.useMemo(()=>R?.profiles?R.profiles.filter(J=>{const se=f.toLowerCase(),Ae=!se||J.name.toLowerCase().includes(se)||J.filament_id.toLowerCase().includes(se),Pe=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,Se=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return Ae&&Pe&&Se}).sort((J,se)=>{switch(x){case"k_value":return parseFloat(J.k_value)-parseFloat(se.k_value);case"filament":return AR(J.name).localeCompare(AR(se.name));case"name":default:return J.name.localeCompare(se.name)}}):[],[R?.profiles,f,m,y,x]),fe=O?.find(V=>V.id===e),pe=fe?.nozzle_count===2;E.useEffect(()=>{const V=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||a||o||u||(J.key==="r"||J.key==="R"?(J.preventDefault(),ee()):J.key==="n"||J.key==="N"?(J.preventDefault(),c(!0)):J.key==="Escape"&&S&&(J.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[a,o,u,S,ee]);const be=E.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const V={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Pe=>({name:Pe.name,k_value:Pe.k_value,filament_id:Pe.filament_id,nozzle_id:Pe.nozzle_id,nozzle_diameter:Pe.nozzle_diameter,extruder_id:Pe.extruder_id}))},J=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),se=URL.createObjectURL(J),Ae=document.createElement("a");Ae.href=se,Ae.download=`kprofiles_${fe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(se),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,fe,r,t]),Ne=E.useCallback(()=>{const V=document.createElement("input");V.type="file",V.accept=".json",V.onchange=async J=>{const se=J.target.files?.[0];if(se)try{const Ae=await se.text(),Pe=JSON.parse(Ae);if(!Pe.profiles||!Array.isArray(Pe.profiles)){t("Invalid file format","error");return}let Se=0;for(const z of Pe.profiles)if(!(!z.name||!z.k_value||!z.filament_id))try{await ke.setKProfile(e,{name:z.name,k_value:parseFloat(z.k_value).toFixed(6),filament_id:z.filament_id,nozzle_id:z.nozzle_id||`HH00-${r}`,nozzle_diameter:z.nozzle_diameter||r,extruder_id:z.extruder_id??0,slot_id:0}),Se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",z.name,L)}t(`Imported ${Se} of ${Pe.profiles.length} profiles`),ee()}catch(Ae){console.error("Import error:",Ae),t("Failed to parse import file","error")}},V.click()},[e,r,t,ee]),ie=E.useCallback(V=>{k(J=>{const se=new Set(J);return se.has(V)?se.delete(V):se.add(V),se})},[]),xe=E.useCallback(()=>{k(new Set(te.map(V=>F(V))))},[te,F]),Re=E.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),he=E.useCallback(async()=>{const V=te.filter(se=>T.has(F(se)));D(!0);let J=0;for(const se of V)try{await ke.deleteKProfile(e,{slot_id:se.slot_id,extruder_id:se.extruder_id,nozzle_id:se.nozzle_id,nozzle_diameter:se.nozzle_diameter,filament_id:se.filament_id,setting_id:se.setting_id}),J++,await new Promise(Ae=>setTimeout(Ae,300))}catch(Ae){console.error("Failed to delete profile:",se.name,Ae)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),k(new Set),ee()},[e,T,te,t,ee,F]),ht=E.useCallback(V=>{const J=[];return V.setting_id&&J.push(V.setting_id),J.push(`slot_${V.slot_id}_${V.filament_id}_${V.extruder_id}`),J.push(`name_${V.name}_${V.filament_id}`),J},[]),H=E.useCallback(async(V,J)=>{if(e)try{await ke.setKProfileNote(e,V,J),U()}catch(se){console.error("Failed to save note:",se),t("Failed to save note","error")}},[e,U,t]),B=E.useCallback(V=>{if(!Q?.notes)return{note:"",key:null};const J=ht(V);for(const se of J)if(Q.notes[se])return{note:Q.notes[se],key:se};return{note:"",key:null}},[Q,ht]),re=E.useCallback(V=>B(V).note,[B]);return q?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!O||O.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(lo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):X.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(Ts,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),l.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):l.jsxs(l.Fragment,{children:[K&&!W&&l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[l.jsx(Et,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),l.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[l.jsxs("div",{className:"flex-1 min-w-48",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),l.jsx("select",{value:e||"",onChange:V=>n(parseInt(V.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:X.map(V=>l.jsx("option",{value:V.id,children:V.name},V.id))})]}),l.jsxs("div",{className:"w-32",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),l.jsxs("select",{value:r,onChange:V=>i(V.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:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>ee(),disabled:K,children:[l.jsx(Ta,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Le,{onClick:()=>c(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[l.jsxs("div",{className:"flex-1 min-w-48 relative",children:[l.jsx(Cc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:f,onChange:V=>g(V.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),pe&&l.jsx("div",{className:"w-36",children:l.jsxs("select",{value:m,onChange:V=>b(V.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:[l.jsx("option",{value:"all",children:"All Extruders"}),l.jsx("option",{value:"left",children:"Left Only"}),l.jsx("option",{value:"right",children:"Right Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{value:y,onChange:V=>v(V.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:[l.jsx("option",{value:"all",children:"All Flow"}),l.jsx("option",{value:"hf",children:"HF Only"}),l.jsx("option",{value:"s",children:"S Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{value:x,onChange:V=>M(V.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:[l.jsx("option",{value:"name",children:"Sort: Name"}),l.jsx("option",{value:"k_value",children:"Sort: K-Value"}),l.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[l.jsxs(Le,{variant:"secondary",onClick:be,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[l.jsx(Es,{className:"w-4 h-4"}),"Export"]}),l.jsxs(Le,{variant:"secondary",onClick:Ne,title:"Import profiles from JSON",children:[l.jsx(vs,{className:"w-4 h-4"}),"Import"]}),l.jsx("div",{className:"flex-1"}),S?l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",onClick:xe,title:"Select all visible profiles",children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select All"]}),l.jsxs(Le,{variant:"secondary",onClick:Re,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[l.jsx(Wt,{className:"w-4 h-4"}),"Cancel"]})]}):l.jsxs(Le,{variant:"secondary",onClick:()=>A(!0),disabled:!te.length,title:"Enter selection mode for bulk delete",children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select"]})]}),W?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):$?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(XR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),l.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),l.jsxs(Le,{variant:"secondary",onClick:()=>ee(),children:[l.jsx(Ta,{className:"w-4 h-4"}),"Retry"]})]})}):te.length>0?pe?l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),l.jsx("div",{className:"space-y-1",children:te.filter(V=>V.extruder_id===1).map(V=>l.jsx(fk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:S,isSelected:T.has(F(V)),onToggleSelect:()=>ie(F(V)),note:re(V)},F(V)))})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),l.jsx("div",{className:"space-y-1",children:te.filter(V=>V.extruder_id===0).map(V=>l.jsx(fk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:S,isSelected:T.has(F(V)),onToggleSelect:()=>ie(F(V)),note:re(V)},F(V)))})]})]}):l.jsx("div",{className:"space-y-1",children:te.map(V=>l.jsx(fk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:S,isSelected:T.has(F(V)),onToggleSelect:()=>ie(F(V)),note:re(V)},F(V)))}):f||m!=="all"||y!=="all"?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(Cc,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(HR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),l.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),l.jsxs(Le,{onClick:()=>c(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:V,key:J}=B(a);return l.jsx(pk,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:Z?.profiles||R?.profiles,isDualNozzle:pe,initialNote:V,initialNoteKey:J,onSaveNote:H,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),ee()},onSave:()=>{s(null),ee()}})})(),o&&e&&l.jsx(pk,{printerId:e,nozzleDiameter:r,existingProfiles:Z?.profiles||R?.profiles,isDualNozzle:pe,onSaveNote:H,onClose:()=>{c(!1),ee()},onSave:()=>{c(!1),ee()}}),u&&e&&l.jsx(pk,{printerId:e,nozzleDiameter:r,existingProfiles:Z?.profiles||R?.profiles,isDualNozzle:pe,onSaveNote:H,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),ee()},onSave:()=>{d(null),ee()}}),N&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-sm",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(Rn,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:()=>I(!1),disabled:C,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:he,disabled:C,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[C?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function yL(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),s=a?(a[1]||a[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=o?o[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:s,layerHeight:c,filamentType:d}}function hb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function yGe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),s=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:s<7?`${s}d ago`:e.toLocaleDateString()}function vGe({onSuccess:t}){const{showToast:e}=ai(),[n,r]=E.useState("email"),[i,a]=E.useState(""),[s,o]=E.useState(""),[c,u]=E.useState(""),[d,f]=E.useState(""),[g,m]=E.useState("global"),b=wt({mutationFn:()=>ke.cloudLogin(i,s,g),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")}),y=wt({mutationFn:()=>ke.cloudVerify(i,c),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),v=wt({mutationFn:()=>ke.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:S=>e(S.message,"error")}),x=S=>{S.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},M=b.isPending||y.isPending||v.isPending;return l.jsx(Nt,{className:"max-w-md mx-auto",children:l.jsxs(Rt,{children:[l.jsxs("div",{className:"text-center mb-6",children:[l.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:l.jsx(US,{className:"w-6 h-6 text-bambu-green"})}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),l.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),l.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),l.jsx("input",{type:"password",value:s,onChange:S=>o(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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),l.jsxs("select",{value:g,onChange:S=>m(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:[l.jsx("option",{value:"global",children:"Global"}),l.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),l.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"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),l.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})]}),l.jsxs("div",{className:"flex gap-2",children:[n==="code"&&l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),l.jsxs(Le,{type:"submit",disabled:M,className:"flex-1",children:[M?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(QF,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[l.jsx($p,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[l.jsx(QF,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Op({label:t,value:e,options:n,onChange:r}){const[i,a]=E.useState(!1),s=n.find(o=>o.value===e);return l.jsxs("div",{className:"relative",children:[l.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:[l.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),l.jsx("span",{children:s?.label||"All"}),l.jsx(bd,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),l.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(o=>l.jsxs("button",{onClick:()=>{r(o.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===o.value?"text-bambu-green":"text-white"}`,children:[l.jsx("span",{children:o.label}),o.count!==void 0&&l.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function _Ge(){const[t,e]=E.useState(!1);E.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?l.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:l.jsx(dm,{className:"w-5 h-5"})}):null}function mk({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:s}){const o=yL(t.name),c=hb(t.setting_id);return l.jsxs("div",{className:"flex items-center gap-2 group",children:[l.jsx("button",{onClick:e,disabled:s,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":s?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!s?"cursor-pointer":""}`,children:l.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&l.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&&l.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),l.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:l.jsx(Hh,{className:"w-4 h-4"})})]})}function TR(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(`
  8230. `)){const i=t.replace(/\\n/g,`
  8231. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8232. `);if(i.length>1)return`"""
  8233. `+i.map(a=>n+" "+a).join(`
  8234. `)+`
  8235. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8236. `+t.map(i=>n+" "+TR(i,e+1)).join(`,
  8237. `)+`
  8238. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8239. `+r.map(([a,s])=>n+" "+JSON.stringify(a)+": "+TR(s,e+1)).join(`,
  8240. `)+`
  8241. `+n+"}"}return String(t)}function wGe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=ai(),s=En(),[o,c]=E.useState(!1),{data:u,isLoading:d}=vt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ke.getCloudSettingDetail(t.setting_id)}),f=wt({mutationFn:()=>ke.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),s.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),g=hb(t.setting_id),m=yL(t.name,u?.setting?.inherits);return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:l.jsxs(Rt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&l.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[l.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"•"}),l.jsx("span",{children:m.printer})]})]})]}),l.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex items-center justify-center py-16",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?l.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:TR(u)}):l.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?l.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[l.jsx(ti,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]}):l.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),l.jsxs(Le,{variant:"secondary",onClick:r,children:[l.jsx(Hh,{className:"w-4 h-4"}),"Duplicate"]}),g&&l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",onClick:i,disabled:d||!u,children:[l.jsx(id,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{variant:"danger",onClick:()=>c(!0),children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})})]})})})}function bte(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function yte(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function SGe({onClose:t,onApply:e}){const{showToast:n}=ai(),[r,i]=E.useState(bte),[a,s]=E.useState("all"),[o,c]=E.useState(null),[u,d]=E.useState(""),[f,g]=E.useState(""),[m,b]=E.useState("{}"),[y,v]=E.useState(null),[x,M]=E.useState(null),S=a==="all"?r:r.filter(O=>O.type===a),A=O=>{i(O),yte(O)},T=O=>{const q=r.filter(R=>R.id!==O);A(q),M(null),n("Template deleted")},k=O=>{c(O.id),d(O.name),g(O.description),b(JSON.stringify(O.settings,null,2)),v(null)},N=()=>{if(!(!o||!u.trim()))try{const O=JSON.parse(m),q=r.map(R=>R.id===o?{...R,name:u.trim(),description:f.trim(),settings:O}:R);A(q),c(null),n("Template updated")}catch(O){v(O.message)}},I=()=>{c(null),d(""),g(""),b("{}"),v(null)},C=O=>{const q=r.map(R=>R.id===O?{...R,showInModal:!R.showInModal}:R);A(q)},D={filament:{label:"Filament",icon:UR,color:"text-amber-400"},print:{label:"Process",icon:HS,color:"text-blue-400"},printer:{label:"Printer",icon:Ts,color:"text-purple-400"}},F=x?r.find(O=>O.id===x):null;return E.useEffect(()=>{const O=q=>{q.key==="Escape"&&(x?M(null):o?I():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[x,o,t]),l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:l.jsx(ti,{className:"w-6 h-6 text-red-400"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),l.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',l.jsx("span",{className:"font-medium",children:F.name}),'"?']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>T(x),className:"flex-1 bg-red-500 hover:bg-red-600",children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),l.jsx(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(M0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>l.jsx("button",{onClick:()=>s(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":D[O].label},O))]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(M0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:"No templates yet"}),l.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):l.jsx("div",{className:"space-y-2",children:S.map(O=>{const q=D[O.type],R=q.icon;return o===O.id?l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[l.jsx("input",{type:"text",value:u,onChange:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:f,onChange:W=>g(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"mb-3",children:[l.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),l.jsx("textarea",{value:m,onChange:W=>{b(W.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&l.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{size:"sm",onClick:N,disabled:!u.trim(),children:[l.jsx(Ro,{className:"w-4 h-4"}),"Save"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:I,children:"Cancel"})]})]},O.id):l.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:[l.jsx(R,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:O.name}),l.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),l.jsx("button",{onClick:()=>C(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?l.jsx(pm,{className:"w-4 h-4"}):l.jsx(zR,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),l.jsx("button",{onClick:()=>k(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:l.jsx(id,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>M(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:l.jsx(Rn,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function vte({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,s]=E.useState("changes"),[o,c]=E.useState(""),u=E.useMemo(()=>{const m=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const y of m){if(y==="inherits"||y==="version")continue;const v=e[y],x=n[y],M=y in e,S=y in n;let A;!M&&S?A="added":M&&!S?A="removed":JSON.stringify(v)!==JSON.stringify(x)?A="changed":A="same",b.push({key:y,left:v,right:x,status:A})}return b.sort((y,v)=>{const x={changed:0,added:1,removed:2,same:3};return x[y.status]!==x[v.status]?x[y.status]-x[v.status]:y.key.localeCompare(v.key)})},[e,n]),d=E.useMemo(()=>{let m=[...u];if(a==="changes"&&(m=m.filter(b=>b.status!=="same")),o){const b=o.toLowerCase();m=m.filter(y=>y.key.toLowerCase().includes(b)||String(y.left).toLowerCase().includes(b)||String(y.right).toLowerCase().includes(b))}return m},[u,a,o]),f=E.useMemo(()=>({added:u.filter(m=>m.status==="added").length,removed:u.filter(m=>m.status==="removed").length,changed:u.filter(m=>m.status==="changed").length,same:u.filter(m=>m.status==="same").length}),[u]),g=m=>{if(m===void 0)return"—";if(m===null)return"null";if(Array.isArray(m))return m.length===0?"[]":m.length===1?String(m[0]):m.join(", ");if(typeof m=="object")return JSON.stringify(m);const b=String(m);if(b.includes("\\n")||b.length>100){const y=b.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return E.useEffect(()=>{const m=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:l.jsxs(Rt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Zp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),l.jsx("p",{className:"text-white font-medium truncate",children:r})]}),l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),l.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[l.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[l.jsx(pr,{className:"w-3.5 h-3.5"}),f.added," added"]}),l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(jk,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),l.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[l.jsx(Nk,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),l.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[l.jsx(DA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsx(Cc,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:o,onChange:m=>c(m.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&&l.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>s("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"}),l.jsx("button",{onClick:()=>s("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"})]})]})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(DA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:l.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[l.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),l.jsx("th",{className:"text-left p-3 w-1/3",children:r}),l.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),l.jsx("tbody",{children:d.map(m=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],y={added:l.jsx(pr,{className:"w-3.5 h-3.5 text-green-400"}),removed:l.jsx(jk,{className:"w-3.5 h-3.5 text-red-400"}),changed:l.jsx(Nk,{className:"w-3.5 h-3.5 text-amber-400"}),same:l.jsx(DA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[m.status];return l.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[l.jsx("td",{className:"p-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[y,l.jsx("span",{className:"text-sm text-white font-mono",children:m.key})]})}),l.jsx("td",{className:"p-3",children:l.jsx("span",{className:`text-sm font-mono break-all ${m.status==="removed"?"text-red-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.left)})}),l.jsx("td",{className:"p-3",children:l.jsx("span",{className:`text-sm font-mono break-all ${m.status==="added"?"text-green-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.right)})})]},m.key)})})]})})]})})})}function MGe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=ai(),i=En(),a=!!e?.setting_id,[s,o]=E.useState("common"),[c,u]=E.useState(e?.type||"filament"),[d,f]=E.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,m]=E.useState(e?.base_id||""),[b,y]=E.useState(""),[v,x]=E.useState(e?.setting||{inherits:""}),[M,S]=E.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,T]=E.useState(null),[k,N]=E.useState(""),[I,C]=E.useState(!1),[D,F]=E.useState(""),[O,q]=E.useState(!1),[R,W]=E.useState(bte),[K,G]=E.useState(!1),[ee,Z]=E.useState(""),[Q,U]=E.useState(""),[$,X]=E.useState(!0),[te,fe]=E.useState(null),[pe,be]=E.useState(!1),Ne=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),ie=E.useMemo(()=>Ne.filter(oe=>hb(oe.setting_id)),[Ne]),{data:xe}=vt({queryKey:["cloudFields",c],queryFn:()=>ke.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Re}=vt({queryKey:["allPresetDetails",c,ie.map(oe=>oe.setting_id).join(",")],queryFn:async()=>{const oe={};for(let He=0;He<ie.length;He+=5){const Ke=ie.slice(He,He+5);(await Promise.all(Ke.map(async de=>{try{const Ye=await ke.getCloudSettingDetail(de.setting_id);return{id:de.setting_id,detail:Ye}}catch{return null}}))).forEach(de=>{de&&(oe[de.id]=de.detail)})}return oe},enabled:ie.length>0,staleTime:1e3*60*10}),{data:he,isLoading:ht}=vt({queryKey:["cloudSettingDetail",g],queryFn:()=>ke.getCloudSettingDetail(g),enabled:!!g});E.useEffect(()=>{s!=="json"&&S(JSON.stringify(v,null,2))},[v,s]);const H=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(et=>!hb(et.setting_id)).sort((et,He)=>et.name.localeCompare(He.name)),[n,c]);E.useEffect(()=>{if(!g)return;const oe=H.find(et=>et.setting_id===g);oe&&(y(oe.name),a||(x({inherits:oe.name}),S(JSON.stringify({inherits:oe.name},null,2))))},[g,H,a]);const B=E.useMemo(()=>{const oe=xe?.fields||[],et=new Set(oe.map(de=>de.key)),He=new Set,Ke=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Re&&Object.values(Re).forEach(de=>{de?.setting&&Object.keys(de.setting).forEach(Ye=>{!et.has(Ye)&&!Ke.has(Ye)&&He.add(Ye)})}),Object.keys(v).forEach(de=>{!et.has(de)&&!Ke.has(de)&&He.add(de)});const ct=Array.from(He).sort().map(de=>({key:de,label:de.replace(/_/g," ").replace(/\b\w/g,Ye=>Ye.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...oe,...ct]},[xe,Re,v]),re=B.filter(oe=>oe.label.toLowerCase().includes(k.toLowerCase())||oe.key.toLowerCase().includes(k.toLowerCase())),V=()=>{if(D.trim()){const oe=D.trim().toLowerCase().replace(/\s+/g,"_");J(oe,""),F(""),q(!1),r(`Field "${oe}" added`)}},J=(oe,et)=>{x(He=>{const Ke={...He};return et===""||et===void 0?delete Ke[oe]:Ke[oe]=et,Ke})},se=oe=>{x(et=>({...et,...oe.settings})),fe(oe.name),r("Template applied")},Ae=()=>{if(!ee.trim())return;const oe={...v};if(delete oe.inherits,Object.keys(oe).length===0){r("No overrides to save","error");return}const et={id:Date.now().toString(),name:ee.trim(),description:Q.trim()||"Custom template",type:c,settings:oe,showInModal:$},He=[...R,et];W(He),yte(He),G(!1),Z(""),U(""),X(!0),r("Template saved")},Pe=E.useMemo(()=>R.filter(oe=>oe.type===c&&oe.showInModal),[c,R]),Se=oe=>{S(oe);try{const et=JSON.parse(oe);x(et),T(null)}catch(et){T(et.message)}},z=oe=>{oe.preventDefault(),C(!1);const et=oe.dataTransfer.files[0];if(et&&et.name.endsWith(".json")){const He=new FileReader;He.onload=Ke=>{try{const ct=Ke.target?.result,de=JSON.parse(ct),Ye=de.setting||de;x(ge=>({...ge,...Ye})),S(JSON.stringify({...v,...Ye},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},He.readAsText(et)}},L=wt({mutationFn:()=>{const oe={...v},et=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";oe[et]=`"${d}"`;const He={type:c,name:d,base_id:g,setting:oe};return ke.createCloudSetting(He)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),ne=wt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return ke.updateCloudSetting(e.setting_id,{name:d,setting:v})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),ve=a?ne:L,we=he?.setting?.inherits,ye=we?H.find(oe=>oe.name===we):void 0,{data:nt}=vt({queryKey:["cloudSettingDetail",ye?.setting_id],queryFn:()=>ke.getCloudSettingDetail(ye.setting_id),enabled:!!ye?.setting_id}),Be=E.useMemo(()=>{const oe=nt?.setting||{},et=he?.setting||{},He=g&&Re?.[g]?.setting?Re[g].setting:{};return{...oe,...et,...He}},[g,he,nt,Re]),ue=oe=>{if(oe==null)return"";if(Array.isArray(oe)){const et=[...new Set(oe.map(He=>String(He)))];return et.length===1?et[0]:oe.join(", ")}return String(oe)},Ve=oe=>{const et=v[oe.key],He=Be[oe.key],Ke=ue(He),ct=ht?"Loading...":Ke||"",de="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(oe.type==="boolean"){const Ye=et==="1"||et===void 0&&He==="1";return l.jsx("button",{type:"button",onClick:()=>J(oe.key,et==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ye?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:l.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ye?"translate-x-3.5":"translate-x-0.5"}`})})}return oe.type==="select"?l.jsxs("select",{value:et||"",onChange:Ye=>J(oe.key,Ye.target.value),className:de,children:[l.jsx("option",{value:"",children:ct}),oe.options?.map(Ye=>l.jsx("option",{value:Ye.value,children:Ye.label},Ye.value))]}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:oe.type==="number"?"number":"text",value:et!==void 0?String(et):"",onChange:Ye=>J(oe.key,Ye.target.value),step:oe.step,min:oe.min,max:oe.max,placeholder:ct,className:de}),oe.unit&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:oe.unit})]})},Fe=E.useMemo(()=>he?.setting?he.setting:{},[he]);return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:oe=>{oe.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:z,children:[pe&&g&&l.jsx(vte,{onClose:()=>be(!1),leftPreset:Fe,rightPreset:v,leftLabel:`Base: ${b||g}`,rightLabel:`Current: ${d||"New Preset"}`}),l.jsx(Nt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[g&&l.jsxs("button",{onClick:()=>be(!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:[l.jsx(Zp,{className:"w-4 h-4"}),"Compare"]}),l.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),I&&l.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:l.jsxs("div",{className:"text-center",children:[l.jsx(vs,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),l.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),l.jsxs("select",{value:c,onChange:oe=>{u(oe.target.value),m("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"filament",children:"Filament"}),l.jsx("option",{value:"print",children:"Process"}),l.jsx("option",{value:"printer",children:"Printer"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),l.jsxs("select",{value:g,onChange:oe=>m(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"Select base preset..."}),H.map(oe=>l.jsx("option",{value:oe.setting_id,children:oe.name},oe.setting_id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),l.jsx("input",{type:"text",value:d,onChange:oe=>f(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),b&&l.jsx("div",{className:"text-xs text-bambu-gray",children:l.jsxs("p",{className:"flex items-center gap-1",children:[l.jsx(zh,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",l.jsx("span",{className:"text-white",children:b}),ht&&l.jsx(Et,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.jsxs("button",{onClick:()=>o("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(JF,{className:"w-4 h-4"}),"Common"]}),l.jsxs("button",{onClick:()=>o("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(VR,{className:"w-4 h-4"}),"All Fields"]}),l.jsxs("button",{onClick:()=>o("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(oG,{className:"w-4 h-4"}),"JSON",A&&l.jsx(lo,{className:"w-3 h-3 text-red-400"})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{const oe={name:d,type:c,base_id:g,setting:v},et=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),He=URL.createObjectURL(et),Ke=document.createElement("a");Ke.href=He,Ke.download=`${d||"preset"}.json`,document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),URL.revokeObjectURL(He),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:[l.jsx(Es,{className:"w-4 h-4"}),"Export"]}),l.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:[l.jsx(vs,{className:"w-4 h-4"}),"Import"]}),l.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:oe=>{const et=oe.target.files?.[0];if(et){const He=new FileReader;He.onload=Ke=>{try{const ct=JSON.parse(Ke.target?.result),de=ct.setting||ct;x(Ye=>({...Ye,...de})),r("File imported")}catch{r("Invalid JSON","error")}},He.readAsText(et)}}})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[s==="common"&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(M0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(v).filter(oe=>oe!=="inherits").length>0&&l.jsxs("button",{onClick:()=>G(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[l.jsx(Ro,{className:"w-3 h-3"}),"Save as template"]})]}),K&&l.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[l.jsx("input",{type:"text",value:ee,onChange:oe=>Z(oe.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:Q,onChange:oe=>U(oe.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{size:"sm",onClick:Ae,disabled:!ee.trim(),children:[l.jsx(Ro,{className:"w-3 h-3"}),"Save"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),l.jsxs("button",{onClick:()=>X(!$),className:`flex items-center gap-1.5 text-xs transition-colors ${$?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[$?l.jsx(pm,{className:"w-3.5 h-3.5"}):l.jsx(zR,{className:"w-3.5 h-3.5"}),$?"Show in modals":"Hidden in modals"]})]})]}),te&&l.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:[l.jsx(zh,{className:"w-4 h-4 text-bambu-green"}),l.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",l.jsx("span",{className:"font-medium",children:te})]}),l.jsx("button",{onClick:()=>fe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Pe.map(oe=>l.jsxs("button",{onClick:()=>se(oe),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:oe.name}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:oe.description})]},oe.id)),Pe.length===0&&l.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."})]}),l.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),l.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:B.slice(0,10).map(oe=>l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:oe.label}),l.jsx("div",{className:"w-48",children:Ve(oe)})]},oe.key))})]}),Object.keys(v).length>1&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([oe])=>oe!=="inherits").map(([oe,et])=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[oe,": ",String(et).slice(0,20),l.jsx("button",{onClick:()=>J(oe,void 0),className:"hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},oe))})]})]}),s==="fields"&&l.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),l.jsx("span",{className:"text-xs text-bambu-gray",children:Re?`${B.length} fields`:"Loading..."})]}),l.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[l.jsx(Cc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:k,onChange:oe=>N(oe.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[re.filter(oe=>!(oe.key in v)).map(oe=>{const et=Be[oe.key],He=ue(et);return l.jsxs("div",{onClick:()=>{x(Ke=>({...Ke,[oe.key]:He||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-sm text-white truncate",children:oe.label}),l.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:oe.key})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[He&&l.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:He,children:[He.slice(0,20),He.length>20?"...":""]}),l.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:l.jsx(pr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},oe.key)}),re.filter(oe=>!(oe.key in v)).length===0&&l.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),l.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:O?l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:D,onChange:oe=>F(oe.target.value),onKeyDown:oe=>oe.key==="Enter"&&V(),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}),l.jsx(Le,{size:"sm",onClick:V,disabled:!D.trim(),children:l.jsx(pr,{className:"w-4 h-4"})}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>{q(!1),F("")},children:l.jsx(Wt,{className:"w-4 h-4"})})]}):l.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[l.jsx(pr,{className:"w-4 h-4"}),"Add custom field"]})})]}),l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(v).filter(oe=>oe!=="inherits").length," fields"]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([oe])=>oe!=="inherits").map(([oe,et])=>{const He=B.find(Ke=>Ke.key===oe);return l.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:He?.label||oe}),l.jsx("p",{className:"text-xs text-bambu-gray-dark",children:oe})]}),l.jsx("button",{onClick:()=>J(oe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),He?Ve(He):l.jsx("input",{type:"text",value:String(et),onChange:Ke=>J(oe,Ke.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},oe)}),Object.keys(v).filter(oe=>oe!=="inherits").length===0&&l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(JF,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{className:"text-sm",children:"No overrides yet"}),l.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(v).filter(oe=>oe!=="inherits").length>0&&l.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:l.jsxs("button",{onClick:()=>{G(!0),o("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:[l.jsx(Ro,{className:"w-4 h-4"}),"Save as template"]})})]})]}),s==="json"&&l.jsxs("div",{className:"space-y-2",children:[A&&l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),A]}),l.jsx("textarea",{value:M,onChange:oe=>Se(oe.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>ve.mutate(),disabled:ve.isPending||!d.trim()||!a&&!g||!!A,className:"flex-1",children:[ve.isPending?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):a?l.jsx(Ro,{className:"w-4 h-4"}):l.jsx(pr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function EGe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,s]=E.useState(""),[o,c]=E.useState("all"),[u,d]=E.useState("all"),[f,g]=E.useState("all"),[m,b]=E.useState("all"),[y,v]=E.useState("all"),[x,M]=E.useState("all"),[S,A]=E.useState(null),[T,k]=E.useState(!1),[N,I]=E.useState(!1),[C,D]=E.useState(null),[F,O]=E.useState(null),[q,R]=E.useState(null),[W,K]=E.useState(!1),[G,ee]=E.useState([null,null]),[Z,Q]=E.useState(!1),[U,$]=E.useState(null),X=En(),te=E.useMemo(()=>[...t.filament.map(re=>({...re,type:"filament"})),...t.printer.map(re=>({...re,type:"printer"})),...t.process.map(re=>({...re,type:"process"}))].map(re=>({...re,meta:yL(re.name)})),[t]),fe=E.useMemo(()=>{const B=new Set,re=new Set,V=new Set;return te.forEach(J=>{J.meta.nozzle&&B.add(J.meta.nozzle),J.meta.filamentType&&re.add(J.meta.filamentType),J.meta.layerHeight&&V.add(J.meta.layerHeight)}),{printers:i.map(J=>({id:J.id.toString(),name:J.name})),nozzles:Array.from(B).sort((J,se)=>parseFloat(J)-parseFloat(se)),filaments:Array.from(re).sort(),layerHeights:Array.from(V).sort((J,se)=>parseFloat(J)-parseFloat(se))}},[te,i]),pe=E.useMemo(()=>f==="all"?null:i.find(re=>re.id.toString()===f)?.model||null,[f,i]),be=E.useMemo(()=>te.filter(B=>o==="all"||B.type===o).filter(B=>{if(u==="all")return!0;const re=hb(B.setting_id);return u==="custom"?re:!re}).filter(B=>{if(f==="all"||!pe)return!0;const re=B.meta.printer?.toLowerCase()||"",V=pe.toLowerCase();return re.includes(V)||V.includes(re)}).filter(B=>m==="all"||B.meta.nozzle===m).filter(B=>y==="all"||B.meta.filamentType===y).filter(B=>x==="all"||B.meta.layerHeight===x).filter(B=>a===""||B.name.toLowerCase().includes(a.toLowerCase())).sort((B,re)=>B.name.localeCompare(re.name)),[te,o,u,f,pe,m,y,x,a]),Ne=B=>{if(W){const re=G[0]?.setting_id===B.setting_id,V=G[1]?.setting_id===B.setting_id;if(re)ee([G[1],null]);else if(V)ee([G[0],null]);else if(!G[0])ee([B,null]);else if(G[1]){if(G[0].type!==B.type)return;ee([G[0],B])}else{if(G[0].type!==B.type)return;ee([G[0],B])}}else A(B)},ie=B=>{if(G[0]?.setting_id===B.setting_id)return 0;if(G[1]?.setting_id===B.setting_id)return 1},xe=async B=>{try{const re=await ke.getCloudSettingDetail(B.setting_id),V=B.type==="process"?"print":B.type;D({type:V,name:B.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),A(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},Re=async B=>{try{X.removeQueries({queryKey:["cloudSettingDetail",B.setting_id]});const re=await ke.getCloudSettingDetail(B.setting_id),V=B.type==="process"?"print":B.type;O({type:V,name:B.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:B.setting_id}),A(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},he=()=>{c("all"),d("all"),g("all"),b("all"),v("all"),M("all"),s("")},ht=o!=="all"||u!=="all"||f!=="all"||m!=="all"||y!=="all"||x!=="all"||a!=="",H=t.filament.length+t.printer.length+t.process.length;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-4 mb-6",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(Cc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:a,onChange:B=>s(B.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"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),ee([null,null])):K(!0)},children:[l.jsx(Zp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>I(!0),children:[l.jsx(M0,{className:"w-4 h-4"}),"Templates"]}),l.jsxs(Le,{variant:"secondary",onClick:n,disabled:r,children:[l.jsx(Ta,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Le,{onClick:()=>k(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"New Preset"]})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx(BR,{className:"w-4 h-4 text-bambu-gray"}),l.jsx(Op,{label:"Type",value:o,options:[{value:"all",label:"All",count:H},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:B=>c(B)}),l.jsx(Op,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:B=>d(B)}),fe.printers.length>0&&l.jsx(Op,{label:"Printer",value:f,options:[{value:"all",label:"All"},...fe.printers.map(B=>({value:B.id,label:B.name}))],onChange:g}),fe.nozzles.length>0&&l.jsx(Op,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...fe.nozzles.map(B=>({value:B,label:B}))],onChange:b}),fe.filaments.length>0&&(o==="all"||o==="filament")&&l.jsx(Op,{label:"Filament",value:y,options:[{value:"all",label:"All"},...fe.filaments.map(B=>({value:B,label:B}))],onChange:v}),fe.layerHeights.length>0&&(o==="all"||o==="process")&&l.jsx(Op,{label:"Layer",value:x,options:[{value:"all",label:"All"},...fe.layerHeights.map(B=>({value:B,label:B}))],onChange:M}),ht&&l.jsx("button",{onClick:he,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&l.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(Zp,{className:"w-5 h-5 text-blue-400"}),l.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),l.jsx("span",{className:"text-bambu-gray",children:G[0]?`Select another ${G[0].type} preset`:"Click two presets of the same type to compare"})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[0]?G[0].name:"1. Select first"}),l.jsx(Nk,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[1]?G[1].name:"2. Select second"})]}),G[0]&&G[1]&&l.jsxs(Le,{size:"sm",onClick:async()=>{try{const[B,re]=await Promise.all([ke.getCloudSettingDetail(G[0].setting_id),ke.getCloudSettingDetail(G[1].setting_id)]);$([B.setting||{},re.setting||{}]),Q(!0)}catch{}},children:[l.jsx(Zp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),l.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(_r,{className:"w-3 h-3"}),"Last synced: ",yGe(e.toISOString())]}),l.jsxs("span",{children:["Showing ",be.length," of ",H," presets"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),l.jsx("span",{children:"= My preset (editable)"})]})]}),be.length===0?l.jsxs("div",{className:"text-center py-16",children:[l.jsx($h,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),l.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),ht&&l.jsx("button",{onClick:he,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(UR,{className:"w-4 h-4 text-amber-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",be.filter(B=>B.type==="filament").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[be.filter(B=>B.type==="filament").map(B=>l.jsx(mk,{setting:B,onClick:()=>Ne(B),onDuplicate:()=>xe(B),compareMode:W,isCompareSelected:ie(B)!==void 0,compareIndex:ie(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),be.filter(B=>B.type==="filament").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(HS,{className:"w-4 h-4 text-blue-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",be.filter(B=>B.type==="process").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[be.filter(B=>B.type==="process").map(B=>l.jsx(mk,{setting:B,onClick:()=>Ne(B),onDuplicate:()=>xe(B),compareMode:W,isCompareSelected:ie(B)!==void 0,compareIndex:ie(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),be.filter(B=>B.type==="process").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(Ts,{className:"w-4 h-4 text-purple-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",be.filter(B=>B.type==="printer").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[be.filter(B=>B.type==="printer").map(B=>l.jsx(mk,{setting:B,onClick:()=>Ne(B),onDuplicate:()=>xe(B),compareMode:W,isCompareSelected:ie(B)!==void 0,compareIndex:ie(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),be.filter(B=>B.type==="printer").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&l.jsx(wGe,{setting:S,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>xe(S),onEdit:()=>Re(S)}),(T||C||F||q)&&l.jsx(MGe,{onClose:()=>{k(!1),D(null),O(null),R(null)},initialData:F||C||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),N&&l.jsx(SGe,{onClose:()=>I(!1),onApply:B=>{R({type:B.type,setting:B.settings}),I(!1)}}),Z&&U&&G[0]&&G[1]&&l.jsx(vte,{onClose:()=>{Q(!1),$(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function AGe(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState("cloud"),[i,a]=E.useState(),{data:s,isLoading:o}=vt({queryKey:["cloudStatus"],queryFn:ke.getCloudStatus}),{data:c=[]}=vt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=vt({queryKey:["cloudSettings"],queryFn:()=>ke.getCloudSettings(),enabled:!!s?.is_authenticated,retry:!1,staleTime:1e3*60*5});E.useEffect(()=>{g&&a(new Date(g))},[g]);const m=wt({mutationFn:ke.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?l.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-6 lg:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[l.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:[l.jsx(US,{className:"w-4 h-4"}),"Cloud Profiles"]}),l.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:[l.jsx(HR,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&l.jsxs(l.Fragment,{children:[s?.is_authenticated&&l.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",l.jsx("span",{className:"text-white",children:s.email})]})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[l.jsx(ece,{className:"w-4 h-4"}),"Logout"]})]}),s?.is_authenticated?d?l.jsx("div",{className:"flex items-center justify-center py-16",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?l.jsx(EGe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):l.jsxs("div",{className:"text-center py-16",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),l.jsx(Le,{onClick:()=>f(),children:"Retry"})]}):l.jsx(vGe,{onSuccess:b})]}),n==="kprofiles"&&l.jsx(bGe,{}),l.jsx(_Ge,{})]})}const Vx={Droplet:UR,Flame:ple,Ruler:Bce,Sparkles:M0,Square:mm,Cable:doe,Wrench:ad,Calendar:Zr,Timer:zu,Cog:Boe,Fan:rle,Zap:xm,Wind:Fue,Thermometer:$S,Layers:$h,Box:hm,Target:gG,RefreshCw:Ta,Settings:KR,Filter:BR,CircleDot:Noe};function f0(t){return t&&Vx[t]||ad}function Lp(t,e){return e==="days"?t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<30?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`:t<1?`${Math.round(t*60)}m`:t<10?`${t.toFixed(1)}h`:`${Math.round(t)}h`}function gk(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 TGe({item:t,onPerform:e,onToggle:n}){const r=f0(t.maintenance_type_icon),i=t.interval_type||"hours",s=(()=>{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))})(),o=()=>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 ${Lp(Math.abs(f),"days")}`:t.is_warning?`Due in ${Lp(f,"days")}`:`${Lp(f,"days")} left`}else return t.is_due?`Overdue by ${Lp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Lp(t.hours_until_due,"hours")}`:`${Lp(t.hours_until_due,"hours")} left`};return l.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.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:[l.jsx(r,{className:`w-5 h-5 ${o()}`}),t.enabled&&(t.is_due||t.is_warning)&&l.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`})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&l.jsx("span",{title:"Time-based interval",children:l.jsx(Zr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),l.jsx("div",{className:"mt-2 mb-1.5",children:l.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${s}%`}})})}),l.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&l.jsx(ti,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&l.jsx(_r,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&l.jsx(zh,{className:"w-3 h-3"}),d()]})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(Pn,{checked:t.enabled,onChange:f=>n(t.id,f)}),l.jsxs(Le,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[l.jsx(Km,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function CGe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=E.useState(!0),[s,o]=E.useState(!1),[c,u]=E.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((m,b)=>m.is_due&&!b.is_due?-1:!m.is_due&&b.is_due?1:m.is_warning&&!b.is_warning?-1:!m.is_warning&&b.is_warning?1:m.maintenance_type_id-b.maintenance_type_id),f=d.find(m=>m.enabled&&(m.is_due||m.is_warning)),g=()=>{const m=parseFloat(c);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return l.jsxs(Nt,{className:"overflow-hidden",children:[l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),l.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&l.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:[l.jsx(ti,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&l.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:[l.jsx(_r,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&l.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:[l.jsx(zh,{className:"w-3 h-3"}),"All good"]})]})]}),l.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?l.jsx(FS,{className:"w-4 h-4"}):l.jsx(bd,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),l.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:l.jsx(zu,{className:"w-4 h-4 text-bambu-gray"})}),s?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",value:c,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g(),m.key==="Escape"&&o(!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}),l.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),l.jsx(Le,{size:"sm",onClick:g,children:"Save"}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):l.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[l.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.floor(t.total_print_hours)," hours",l.jsx(S0,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),l.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const m=f0(f.maintenance_type_icon);return l.jsx(m,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),l.jsxs("div",{children:[l.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),l.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&l.jsx(Rt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:l.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(m=>l.jsx(TGe,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function NGe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a}){const[s,o]=E.useState(null),[c,u]=E.useState(""),[d,f]=E.useState("hours"),[g,m]=E.useState(!1),[b,y]=E.useState(""),[v,x]=E.useState("100"),[M,S]=E.useState("hours"),[A,T]=E.useState("Wrench"),[k,N]=E.useState(null),[I,C]=E.useState(""),[D,F]=E.useState(""),[O,q]=E.useState("hours"),[R,W]=E.useState("Wrench"),K=X=>{N(X),C(X.name),F(X.default_interval_hours.toString()),q(X.interval_type||"hours"),W(X.icon||"Wrench")},G=()=>{k&&I.trim()&&parseFloat(D)>0&&(i(k.id,{name:I.trim(),default_interval_hours:parseFloat(D),interval_type:O,icon:R}),N(null))},ee=(X,te,fe)=>{const pe=parseFloat(c);if(!isNaN(pe)&&pe>0){const be=Math.abs(pe-te)<.01?null:pe;n(X,{custom_interval_hours:be,custom_interval_type:d!==fe?d:null})}o(null)},Z=X=>{X.preventDefault(),b.trim()&&parseFloat(v)>0&&(r({name:b.trim(),default_interval_hours:parseFloat(v),interval_type:M,icon:A}),y(""),x("100"),S("hours"),m(!1))},Q=t?.map(X=>({printerId:X.printer_id,printerName:X.printer_name,items:X.maintenance_items.sort((te,fe)=>te.maintenance_type_id-fe.maintenance_type_id)})).sort((X,te)=>X.printerName.localeCompare(te.printerName))||[],U=e.filter(X=>X.is_system),$=e.filter(X=>!X.is_system);return l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),l.jsxs(Le,{onClick:()=>m(!g),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&l.jsx(Nt,{className:"mb-6",children:l.jsx(Rt,{className:"py-4",children:l.jsxs("form",{onSubmit:Z,children:[l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[l.jsxs("div",{className:"lg:col-span-2",children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),l.jsx("input",{type:"text",value:b,onChange:X=>y(X.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),l.jsxs("select",{value:M,onChange:X=>{S(X.target.value),X.target.value==="days"?x("30"):x("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:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",M==="days"?"days":"hours",")"]}),l.jsx("input",{type:"number",value:v,onChange:X=>x(X.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"})]})]}),l.jsxs("div",{className:"mt-4 flex items-end justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),l.jsx("div",{className:"flex gap-1",children:Object.keys(Vx).map(X=>{const te=Vx[X];return l.jsx("button",{type:"button",onClick:()=>T(X),className:`p-2 rounded-lg transition-colors ${A===X?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:l.jsx(te,{className:"w-4 h-4"})},X)})})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),l.jsx(Le,{type:"submit",disabled:!b.trim(),children:"Add Type"})]})]})]})})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U.map(X=>{const te=f0(X.icon),fe=X.interval_type||"hours";return l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:l.jsx(te,{className:"w-5 h-5 text-bambu-gray"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-white truncate",children:X.name}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(zu,{className:"w-3 h-3"}),gk(X.default_interval_hours,fe)]})]})]})},X.id)}),$.map(X=>{const te=f0(X.icon),fe=X.interval_type||"hours";return k?.id===X.id?l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:l.jsxs("div",{className:"space-y-3",children:[l.jsx("input",{type:"text",value:I,onChange:be=>C(be.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}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("select",{value:O,onChange:be=>q(be.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:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.jsx("input",{type:"number",value:D,onChange:be=>F(be.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"})]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Vx).map(be=>{const Ne=Vx[be];return l.jsx("button",{type:"button",onClick:()=>W(be),className:`p-1.5 rounded transition-colors ${R===be?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:l.jsx(Ne,{className:"w-3.5 h-3.5"})},be)})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{size:"sm",onClick:G,disabled:!I.trim(),children:"Save"}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>N(null),children:"Cancel"})]})]})},X.id):l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:l.jsx(te,{className:"w-5 h-5 text-bambu-green"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-white truncate",children:X.name}),l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(zu,{className:"w-3 h-3"}),gk(X.default_interval_hours,fe)]})]}),l.jsx("button",{onClick:()=>K(X),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:l.jsx(S0,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>{confirm(`Delete "${X.name}"?`)&&a(X.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Rn,{className:"w-4 h-4"})})]})},X.id)})]})]}),Q.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),l.jsx("div",{className:"space-y-4",children:Q.map(X=>l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-4",children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:X.printerName}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:X.items.map(te=>{const fe=f0(te.maintenance_type_icon),pe=e.find(Re=>Re.id===te.maintenance_type_id),be=pe?.default_interval_hours||te.interval_hours,Ne=pe?.interval_type||"hours",ie=te.interval_type||"hours",xe=s===te.id;return l.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[l.jsx(fe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),l.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:te.maintenance_type_name}),xe?l.jsxs("div",{className:"flex items-center gap-1",children:[d==="days"?l.jsx(Zr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):l.jsx(zu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),l.jsxs("select",{value:d,onChange:Re=>f(Re.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.jsx("input",{type:"number",value:c,onChange:Re=>u(Re.target.value),onKeyDown:Re=>{Re.key==="Enter"&&ee(te.id,be,Ne),Re.key==="Escape"&&o(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),l.jsx(Le,{size:"sm",onClick:()=>ee(te.id,be,Ne),children:"OK"})]}):l.jsxs("button",{onClick:()=>{o(te.id),u(te.interval_hours.toString()),f(ie)},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:[ie==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(zu,{className:"w-3 h-3"}),gk(te.interval_hours,ie),l.jsx(S0,{className:"w-3 h-3 text-bambu-gray"})]})]},te.id)})})]})},X.printerId))})]}),Q.length===0&&l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx(_r,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),l.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function kGe(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState("status"),{data:i,isLoading:a}=vt({queryKey:["maintenanceOverview"],queryFn:ke.getMaintenanceOverview}),{data:s}=vt({queryKey:["maintenanceTypes"],queryFn:ke.getMaintenanceTypes}),o=wt({mutationFn:({id:M,notes:S})=>ke.performMaintenance(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:M=>{e(M.message,"error")}}),c=wt({mutationFn:({id:M,data:S})=>ke.updateMaintenanceItem(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),u=wt({mutationFn:ke.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:M=>{e(M.message,"error")}}),d=wt({mutationFn:({id:M,data:S})=>ke.updateMaintenanceType(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),f=wt({mutationFn:ke.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:M=>{e(M.message,"error")}}),g=wt({mutationFn:({printerId:M,hours:S})=>ke.setPrinterHours(M,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:M=>{e(M.message,"error")}}),m=M=>{o.mutate({id:M})},b=(M,S)=>{c.mutate({id:M,data:{enabled:S}})},y=(M,S)=>{g.mutate({printerId:M,hours:S})};if(a)return l.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((M,S)=>M+S.due_count,0)||0,x=i?.reduce((M,S)=>M+S.warning_count,0)||0;return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?l.jsxs(l.Fragment,{children:[v>0&&l.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&x>0&&" · ",x>0&&l.jsxs("span",{className:"text-amber-400",children:[x," due soon"]}),v===0&&x===0&&l.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),l.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[l.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"}),l.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"?l.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((M,S)=>{const A=M.due_count*10+M.warning_count,T=S.due_count*10+S.warning_count;return A!==T?T-A:M.printer_name.localeCompare(S.printer_name)}).map(M=>l.jsx(CGe,{overview:M,onPerform:m,onToggle:b,onSetHours:y},M.printer_id)):l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-16",children:[l.jsx(ad,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):l.jsx(NGe,{overview:i,types:s||[],onUpdateInterval:(M,S)=>c.mutate({id:M,data:S}),onAddType:M=>u.mutate(M),onUpdateType:(M,S)=>d.mutate({id:M,data:S}),onDeleteType:M=>f.mutate(M)})]})}const y9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function PGe({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.description||""),[c,u]=E.useState(t?.color||y9[0]),[d,f]=E.useState(t?.target_count?.toString()||""),[g,m]=E.useState(t?.status||"active"),b=y=>{y.preventDefault(),n({name:i.trim(),description:s.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,...t&&{status:g}})};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[l.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),l.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),l.jsx("input",{type:"text",value:i,onChange:y=>a(y.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),l.jsx("textarea",{value:s,onChange:y=>o(y.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:y9.map(y=>l.jsx("button",{type:"button",onClick:()=>u(y),className:`w-8 h-8 rounded-full transition-transform ${c===y?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:y}},y))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),l.jsx("input",{type:"number",value:d,onChange:y=>f(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 50 parts to print",min:"1"})]}),t&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),l.jsxs("select",{value:g,onChange:y=>m(y.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:[l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"archived",children:"Archived"})]})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsx(Le,{type:"submit",disabled:!i.trim()||r,children:r?l.jsx(Et,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function RGe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,a=t.status==="completed",s=t.status==="archived";return l.jsx(Nt,{className:"hover:border-bambu-gray/30 transition-colors cursor-pointer",onClick:e,children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:t.color||"#6b7280"}}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),t.description&&l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-0.5 line-clamp-1",children:t.description})]})]}),l.jsxs("div",{className:"flex items-center gap-1",onClick:o=>o.stopPropagation(),children:[a&&l.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded",children:"Completed"}),s&&l.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded",children:"Archived"}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,className:"p-1",children:l.jsx(S0,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"p-1 text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]}),t.target_count&&l.jsxs("div",{className:"mb-3",children:[l.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[l.jsxs("span",{children:[t.archive_count," / ",t.target_count," prints"]}),l.jsxs("span",{children:[i.toFixed(0),"%"]})]}),l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full transition-all duration-300",style:{width:`${Math.min(i,100)}%`,backgroundColor:i>=100?"#22c55e":t.color||"#6b7280"}})})]}),t.archives&&t.archives.length>0&&l.jsx("div",{className:"mb-3",children:l.jsxs("div",{className:"flex gap-2",children:[t.archives.slice(0,5).map(o=>l.jsxs("a",{href:`/archives?search=${encodeURIComponent(o.print_name||"")}`,onClick:c=>c.stopPropagation(),className:"relative w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:o.print_name||"Unknown",children:[o.thumbnail_path?l.jsx("img",{src:`/api/v1/archives/${o.id}/thumbnail`,alt:o.print_name||"",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:l.jsx(w0,{className:"w-6 h-6"})}),o.status==="failed"&&l.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:l.jsx("span",{className:"text-white text-xs font-bold",children:"✗"})})]},o.id)),t.archive_count>5&&l.jsxs("div",{className:"w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 flex items-center justify-center text-sm text-bambu-gray border border-bambu-dark-tertiary",children:["+",t.archive_count-5]})]})}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[l.jsxs("div",{className:"flex items-center gap-1",title:"Archives",children:[l.jsx(wh,{className:"w-4 h-4"}),l.jsx("span",{children:t.archive_count})]}),l.jsxs("div",{className:"flex items-center gap-1",title:"Queued",children:[l.jsx(Xle,{className:"w-4 h-4"}),l.jsx("span",{children:t.queue_count})]})]})]})})}function DGe(){const t=En(),{showToast:e}=ai(),[n,r]=E.useState(!1),[i,a]=E.useState(),[s,o]=E.useState("active"),[c,u]=E.useState(null),{data:d,isLoading:f}=vt({queryKey:["projects",s==="all"?void 0:s],queryFn:()=>ke.getProjects(s==="all"?void 0:s)}),g=wt({mutationFn:A=>ke.createProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),e("Project created","success")},onError:A=>{e(A.message,"error")}}),m=wt({mutationFn:({id:A,data:T})=>ke.updateProject(A,T),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),a(void 0),e("Project updated","success")},onError:A=>{e(A.message,"error")}}),b=wt({mutationFn:A=>ke.deleteProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),u(null),e("Project deleted","success")},onError:A=>{e(A.message,"error")}}),y=A=>{i?m.mutate({id:i.id,data:A}):g.mutate(A)},v=A=>{a(A),r(!0)},x=A=>{v(A)},M=A=>{u(A)},S=()=>{c!==null&&b.mutate(c)};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Ku,{className:"w-6 h-6 text-bambu-green"}),l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Projects"})]}),l.jsxs(Le,{onClick:()=>r(!0),children:[l.jsx(pr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),l.jsx("div",{className:"flex gap-2",children:["active","completed","archived","all"].map(A=>l.jsx("button",{onClick:()=>o(A),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${s===A?"bg-bambu-green text-white":"bg-bambu-card text-bambu-gray hover:bg-bambu-gray/20"}`,children:A.charAt(0).toUpperCase()+A.slice(1)},A))}),f?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Et,{className:"w-8 h-8 animate-spin text-bambu-green"})}):d?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(Ku,{className:"w-12 h-12 text-bambu-gray/50 mx-auto mb-4"}),l.jsx("p",{className:"text-bambu-gray",children:"No projects found"}),l.jsx("p",{className:"text-bambu-gray/70 text-sm mt-1",children:"Create a project to group related prints together"})]})}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d?.map(A=>l.jsx(RGe,{project:A,onClick:()=>x(A),onEdit:()=>v(A),onDelete:()=>M(A.id)},A.id))}),c!==null&&l.jsx(Qr,{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:S,onCancel:()=>u(null)}),n&&l.jsx(PGe,{project:i,onClose:()=>{r(!1),a(void 0)},onSave:y,isLoading:g.isPending||m.isPending})]})}function jGe(){const{printerId:t}=B9(),e=parseInt(t||"0",10),[n,r]=E.useState("stream"),[i,a]=E.useState(!1),[s,o]=E.useState(!0),[c,u]=E.useState(Date.now()),[d,f]=E.useState(!1),[g,m]=E.useState(!1),b=E.useRef(null),y=E.useRef(null),{data:v}=vt({queryKey:["printer",e],queryFn:()=>ke.getPrinter(e),enabled:e>0});E.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambuddy"}),[v]),E.useEffect(()=>{const C=`/api/v1/printers/${e}/camera/stop`,D=()=>{e>0&&navigator.sendBeacon(C)},F=()=>{document.visibilityState==="hidden"&&e>0&&navigator.sendBeacon(C)};return window.addEventListener("beforeunload",D),document.addEventListener("visibilitychange",F),()=>{window.removeEventListener("beforeunload",D),document.removeEventListener("visibilitychange",F),b.current&&(b.current.src=""),e>0&&navigator.sendBeacon(C)}},[e]),E.useEffect(()=>{if(s&&!d){const D=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(D)}},[n,s,c,d]),E.useEffect(()=>{const C=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",C),()=>document.removeEventListener("fullscreenchange",C)},[]);const x=()=>{a(!0),o(!1)},M=()=>{o(!1),a(!1)},S=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},A=C=>{n===C||d||(f(!0),o(!0),a(!1),b.current&&(b.current.src=""),n==="stream"&&S(),setTimeout(()=>{r(C),u(Date.now()),f(!1)},100))},T=()=>{d||(f(!0),o(!0),a(!1),b.current&&(b.current.src=""),n==="stream"&&S(),setTimeout(()=>{u(Date.now()),f(!1)},100))},k=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},N=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,I=s||d;return e?l.jsxs("div",{ref:y,className:"min-h-screen bg-black flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[l.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(b0,{className:"w-4 h-4"}),v?.name||`Printer ${e}`]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[l.jsx("button",{onClick:()=>A("stream"),disabled:I,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"}),l.jsx("button",{onClick:()=>A("snapshot"),disabled:I,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"})]}),l.jsx("button",{onClick:T,disabled:I,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:l.jsx(Ta,{className:`w-4 h-4 text-bambu-gray ${I?"animate-spin":""}`})}),l.jsx("button",{onClick:k,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?l.jsx(gce,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(lce,{className:"w-4 h-4 text-bambu-gray"})})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:l.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(s||d)&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:l.jsxs("div",{className:"text-center",children:[l.jsx(Ta,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:l.jsxs("div",{className:"text-center p-4",children:[l.jsx(ti,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),l.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),l.jsx("button",{onClick:T,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),l.jsx("img",{ref:b,src:N,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:N?x:void 0,onLoad:N?M:void 0},c)]})})]}):l.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:l.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function OGe(){const{id:t}=B9(),{theme:e}=xb(),{data:n,isLoading:r,error:i}=vt({queryKey:["external-link",t],queryFn:()=>ke.getExternalLink(Number(t)),enabled:!!t});return r?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[l.jsx(ti,{className:"w-12 h-12"}),l.jsx("p",{children:"Link not found"})]}):l.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function Fr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return l.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[l.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:l.jsx(t,{className:"w-5 h-5"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:e}),l.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&l.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function v9({percent:t,color:e="bg-bambu-green"}){return l.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function th({title:t,icon:e,children:n}){return l.jsxs(Nt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(e,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function LGe(){const{t}=Vm(),{data:e,isLoading:n,refetch:r,isFetching:i}=vt({queryKey:["systemInfo"],queryFn:ke.getSystemInfo,refetchInterval:3e4});if(n)return l.jsx("div",{className:"flex items-center justify-center h-64",children:l.jsx(Et,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!e)return l.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const a=e.storage.disk_percent_used>90?"bg-red-500":e.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",s=e.memory.percent_used>90?"bg-red-500":e.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return l.jsxs("div",{className:"p-6 space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),l.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),l.jsxs("button",{onClick:()=>r(),disabled:i,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:[l.jsx(Ta,{className:`w-4 h-4 ${i?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),l.jsx(th,{title:t("system.application","Application"),icon:nh,children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[l.jsx(Fr,{icon:nh,label:t("system.version","Version"),value:`v${e.app.version}`}),l.jsx(Fr,{icon:_r,label:t("system.uptime","System Uptime"),value:e.system.uptime_formatted}),l.jsx(Fr,{icon:nh,label:t("system.hostname","Hostname"),value:e.system.hostname})]})}),l.jsxs(th,{title:t("system.database","Database"),icon:fm,children:[l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[l.jsx(Fr,{icon:wh,label:t("system.totalArchives","Total Archives"),value:e.database.archives}),l.jsx(Fr,{icon:Toe,label:t("system.completed","Completed"),value:e.database.archives_completed,color:"text-green-500"}),l.jsx(Fr,{icon:gs,label:t("system.failed","Failed"),value:e.database.archives_failed,color:"text-red-500"}),l.jsx(Fr,{icon:Et,label:t("system.printing","Printing"),value:e.database.archives_printing,color:"text-yellow-500"})]}),l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsx(Fr,{icon:Ts,label:t("system.printers","Printers"),value:e.database.printers}),l.jsx(Fr,{icon:pG,label:t("system.filaments","Filaments"),value:e.database.filaments}),l.jsx(Fr,{icon:Ku,label:t("system.projects","Projects"),value:e.database.projects}),l.jsx(Fr,{icon:Qp,label:t("system.smartPlugs","Smart Plugs"),value:e.database.smart_plugs})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[l.jsx(Fr,{icon:_r,label:t("system.totalPrintTime","Total Print Time"),value:e.database.total_print_time_formatted}),l.jsx(Fr,{icon:wh,label:t("system.totalFilament","Total Filament Used"),value:`${e.database.total_filament_kg} kg`,subValue:`${e.database.total_filament_grams.toLocaleString()} g`})]})]}),l.jsxs(th,{title:t("system.connectedPrinters","Connected Printers"),icon:Ts,children:[l.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[l.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:e.printers.connected}),l.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:e.printers.total})})]}),e.printers.connected_list.length>0?l.jsx("div",{className:"space-y-2",children:e.printers.connected_list.map(o=>l.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),l.jsx("span",{className:"font-medium text-white",children:o.name})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[l.jsx("span",{children:o.model}),l.jsx("span",{className:`px-2 py-0.5 rounded ${o.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":o.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:o.state})]})]},o.id))}):l.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),l.jsx(th,{title:t("system.storage","Storage"),icon:$R,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),l.jsxs("span",{className:"text-white",children:[e.storage.disk_used_formatted," / ",e.storage.disk_total_formatted]})]}),l.jsx(v9,{percent:e.storage.disk_percent_used,color:a}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.storage.disk_free_formatted," ",t("system.free","free")," (",(100-e.storage.disk_percent_used).toFixed(1),"%)"]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsx(Fr,{icon:wh,label:t("system.archiveStorage","Archive Storage"),value:e.storage.archive_size_formatted}),l.jsx(Fr,{icon:fm,label:t("system.databaseSize","Database Size"),value:e.storage.database_size_formatted})]})]})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsx(th,{title:t("system.memory","Memory"),icon:uce,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),l.jsxs("span",{className:"text-white",children:[e.memory.used_formatted," / ",e.memory.total_formatted]})]}),l.jsx(v9,{percent:e.memory.percent_used,color:s}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.memory.available_formatted," ",t("system.available","available")]})]})})}),l.jsx(th,{title:t("system.cpu","CPU"),icon:gv,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx(Fr,{icon:gv,label:t("system.cores","Cores"),value:e.cpu.count,subValue:`${e.cpu.count_logical} logical`}),l.jsx(Fr,{icon:gv,label:t("system.usage","Usage"),value:`${e.cpu.percent}%`})]})})})]}),l.jsx(th,{title:t("system.systemDetails","System Details"),icon:nh,children:l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsx(Fr,{icon:nh,label:t("system.os","Operating System"),value:e.system.platform,subValue:e.system.platform_release}),l.jsx(Fr,{icon:gv,label:t("system.architecture","Architecture"),value:e.system.architecture}),l.jsx(Fr,{icon:nh,label:t("system.python","Python"),value:e.system.python_version}),l.jsx(Fr,{icon:_r,label:t("system.bootTime","Boot Time"),value:new Date(e.system.boot_time).toLocaleString()})]})})]})}function IGe(){const t=E.useRef(null),e=E.useRef(null),n=En(),[r,i]=E.useState(!1),a=E.useRef(new Set),s=E.useRef(null),o=E.useRef(new Map),c=E.useRef(null),u=E.useRef([]),d=E.useRef(!1),f=E.useRef(()=>{}),g=E.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()},[]),m=E.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 T=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),T=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=k=>{try{const N=JSON.parse(k.data);N.type==="printer_status"&&N.printer_id!==void 0&&N.data?f.current(N):(u.current.push(N),g())}catch{}},A.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),T&&(clearInterval(T),T=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{m()},3e3)},A.onerror=k=>{console.error("[WebSocket] Error",k),A.close()},t.current=A},[]),b=E.useCallback((M,S)=>{const A=o.current.get(M)||{};o.current.set(M,{...A,...S}),c.current||(c.current=window.setTimeout(()=>{const T=new Map(o.current);o.current.clear(),c.current=null,requestAnimationFrame(()=>{T.forEach((k,N)=>{n.setQueryData(["printerStatus",N],I=>{const C={...I,...k};return C.wifi_signal==null&&I?.wifi_signal!=null&&(C.wifi_signal=I.wifi_signal),C})})})},100))},[n]),y=E.useCallback(M=>{a.current.add(M),s.current&&clearTimeout(s.current),s.current=window.setTimeout(()=>{const S=Array.from(a.current);a.current.clear(),s.current=null;let A=0;S.forEach(T=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[T]})})},A),A+=500})},3e3)},[n]),v=E.useCallback(M=>{switch(M.type){case"printer_status":M.printer_id!==void 0&&M.data&&b(M.printer_id,M.data);break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break}},[n,y,b]);E.useEffect(()=>{f.current=v},[v]),E.useEffect(()=>(m(),()=>{e.current&&clearTimeout(e.current),s.current&&clearTimeout(s.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[m]);const x=E.useCallback(M=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(M))},[]);return{isConnected:r,sendMessage:x}}const FGe=new Rse({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function UGe({children:t}){return IGe(),l.jsx(l.Fragment,{children:t})}function zGe(){return l.jsx(Wue,{children:l.jsx(nde,{children:l.jsx(Dse,{client:FGe,children:l.jsx(UGe,{children:l.jsx(ese,{children:l.jsxs(Pae,{children:[l.jsx(fs,{path:"/camera/:printerId",element:l.jsx(jGe,{})}),l.jsxs(fs,{path:"/",element:l.jsx(Jue,{}),children:[l.jsx(fs,{index:!0,element:l.jsx(ECe,{})}),l.jsx(fs,{path:"archives",element:l.jsx(QVe,{})}),l.jsx(fs,{path:"queue",element:l.jsx(I9e,{})}),l.jsx(fs,{path:"stats",element:l.jsx(Z9e,{})}),l.jsx(fs,{path:"profiles",element:l.jsx(AGe,{})}),l.jsx(fs,{path:"maintenance",element:l.jsx(kGe,{})}),l.jsx(fs,{path:"projects",element:l.jsx(DGe,{})}),l.jsx(fs,{path:"settings",element:l.jsx(mGe,{})}),l.jsx(fs,{path:"system",element:l.jsx(LGe,{})}),l.jsx(fs,{path:"external/:id",element:l.jsx(OGe,{})})]})]})})})})})})}Ore.createRoot(document.getElementById("root")).render(l.jsx(E.StrictMode,{children:l.jsx(zGe,{})}));