| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650 |
- function Zre(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 wv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jT={exports:{}},fx={};var SF;function Qre(){if(SF)return fx;SF=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 l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:s,ref:i!==void 0?i:null,props:a}}return fx.Fragment=e,fx.jsx=n,fx.jsxs=n,fx}var MF;function Jre(){return MF||(MF=1,jT.exports=Qre()),jT.exports}var o=Jre(),RT={exports:{}},tn={};var EF;function eie(){if(EF)return tn;EF=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"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function p(B){return B===null||typeof B!="object"?null:(B=g&&B[g]||B["@@iterator"],typeof B=="function"?B:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,y={};function b(B,G,Q){this.props=B,this.context=G,this.refs=y,this.updater=Q||x}b.prototype.isReactComponent={},b.prototype.setState=function(B,G){if(typeof B!="object"&&typeof B!="function"&&B!=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,B,G,"setState")},b.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function E(){}E.prototype=b.prototype;function w(B,G,Q){this.props=B,this.context=G,this.refs=y,this.updater=Q||x}var T=w.prototype=new E;T.constructor=w,v(T,b.prototype),T.isPureReactComponent=!0;var A=Array.isArray;function C(){}var N={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function k(B,G,Q){var te=Q.ref;return{$$typeof:t,type:B,key:G,ref:te!==void 0?te:null,props:Q}}function R(B,G){return k(B.type,G,B.props)}function I(B){return typeof B=="object"&&B!==null&&B.$$typeof===t}function L(B){var G={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(Q){return G[Q]})}var q=/\/+/g;function j(B,G){return typeof B=="object"&&B!==null&&B.key!=null?L(""+B.key):G.toString(36)}function V(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(C,C):(B.status="pending",B.then(function(G){B.status==="pending"&&(B.status="fulfilled",B.value=G)},function(G){B.status==="pending"&&(B.status="rejected",B.reason=G)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function K(B,G,Q,te,he){var oe=typeof B;(oe==="undefined"||oe==="boolean")&&(B=null);var xe=!1;if(B===null)xe=!0;else switch(oe){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(B.$$typeof){case t:case e:xe=!0;break;case d:return xe=B._init,K(xe(B._payload),G,Q,te,he)}}if(xe)return he=he(B),xe=te===""?"."+j(B,0):te,A(he)?(Q="",xe!=null&&(Q=xe.replace(q,"$&/")+"/"),K(he,G,Q,"",function(ce){return ce})):he!=null&&(I(he)&&(he=R(he,Q+(he.key==null||B&&B.key===he.key?"":(""+he.key).replace(q,"$&/")+"/")+xe)),G.push(he)),1;xe=0;var Te=te===""?".":te+":";if(A(B))for(var me=0;me<B.length;me++)te=B[me],oe=Te+j(te,me),xe+=K(te,G,Q,oe,he);else if(me=p(B),typeof me=="function")for(B=me.call(B),me=0;!(te=B.next()).done;)te=te.value,oe=Te+j(te,me++),xe+=K(te,G,Q,oe,he);else if(oe==="object"){if(typeof B.then=="function")return K(V(B),G,Q,te,he);throw G=String(B),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return xe}function W(B,G,Q){if(B==null)return B;var te=[],he=0;return K(B,te,"","",function(oe){return G.call(Q,oe,he++)}),te}function J(B){if(B._status===-1){var G=B._result;G=G(),G.then(function(Q){(B._status===0||B._status===-1)&&(B._status=1,B._result=Q)},function(Q){(B._status===0||B._status===-1)&&(B._status=2,B._result=Q)}),B._status===-1&&(B._status=0,B._result=G)}if(B._status===1)return B._result.default;throw B._result}var ee=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},Z={map:W,forEach:function(B,G,Q){W(B,function(){G.apply(this,arguments)},Q)},count:function(B){var G=0;return W(B,function(){G++}),G},toArray:function(B){return W(B,function(G){return G})||[]},only:function(B){if(!I(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return tn.Activity=f,tn.Children=Z,tn.Component=b,tn.Fragment=n,tn.Profiler=i,tn.PureComponent=w,tn.StrictMode=r,tn.Suspense=c,tn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,tn.__COMPILER_RUNTIME={__proto__:null,c:function(B){return N.H.useMemoCache(B)}},tn.cache=function(B){return function(){return B.apply(null,arguments)}},tn.cacheSignal=function(){return null},tn.cloneElement=function(B,G,Q){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var te=v({},B.props),he=B.key;if(G!=null)for(oe in G.key!==void 0&&(he=""+G.key),G)!F.call(G,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&G.ref===void 0||(te[oe]=G[oe]);var oe=arguments.length-2;if(oe===1)te.children=Q;else if(1<oe){for(var xe=Array(oe),Te=0;Te<oe;Te++)xe[Te]=arguments[Te+2];te.children=xe}return k(B.type,he,te)},tn.createContext=function(B){return B={$$typeof:s,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:a,_context:B},B},tn.createElement=function(B,G,Q){var te,he={},oe=null;if(G!=null)for(te in G.key!==void 0&&(oe=""+G.key),G)F.call(G,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(he[te]=G[te]);var xe=arguments.length-2;if(xe===1)he.children=Q;else if(1<xe){for(var Te=Array(xe),me=0;me<xe;me++)Te[me]=arguments[me+2];he.children=Te}if(B&&B.defaultProps)for(te in xe=B.defaultProps,xe)he[te]===void 0&&(he[te]=xe[te]);return k(B,oe,he)},tn.createRef=function(){return{current:null}},tn.forwardRef=function(B){return{$$typeof:l,render:B}},tn.isValidElement=I,tn.lazy=function(B){return{$$typeof:d,_payload:{_status:-1,_result:B},_init:J}},tn.memo=function(B,G){return{$$typeof:u,type:B,compare:G===void 0?null:G}},tn.startTransition=function(B){var G=N.T,Q={};N.T=Q;try{var te=B(),he=N.S;he!==null&&he(Q,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(C,ee)}catch(oe){ee(oe)}finally{G!==null&&Q.types!==null&&(G.types=Q.types),N.T=G}},tn.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},tn.use=function(B){return N.H.use(B)},tn.useActionState=function(B,G,Q){return N.H.useActionState(B,G,Q)},tn.useCallback=function(B,G){return N.H.useCallback(B,G)},tn.useContext=function(B){return N.H.useContext(B)},tn.useDebugValue=function(){},tn.useDeferredValue=function(B,G){return N.H.useDeferredValue(B,G)},tn.useEffect=function(B,G){return N.H.useEffect(B,G)},tn.useEffectEvent=function(B){return N.H.useEffectEvent(B)},tn.useId=function(){return N.H.useId()},tn.useImperativeHandle=function(B,G,Q){return N.H.useImperativeHandle(B,G,Q)},tn.useInsertionEffect=function(B,G){return N.H.useInsertionEffect(B,G)},tn.useLayoutEffect=function(B,G){return N.H.useLayoutEffect(B,G)},tn.useMemo=function(B,G){return N.H.useMemo(B,G)},tn.useOptimistic=function(B,G){return N.H.useOptimistic(B,G)},tn.useReducer=function(B,G,Q){return N.H.useReducer(B,G,Q)},tn.useRef=function(B){return N.H.useRef(B)},tn.useState=function(B){return N.H.useState(B)},tn.useSyncExternalStore=function(B,G,Q){return N.H.useSyncExternalStore(B,G,Q)},tn.useTransition=function(){return N.H.useTransition()},tn.version="19.2.0",tn}var TF;function Jp(){return TF||(TF=1,RT.exports=eie()),RT.exports}var M=Jp();const _r=bo(M),tie=Zre({__proto__:null,default:_r},[M]);var DT={exports:{}},mx={},OT={exports:{}},LT={};var AF;function nie(){return AF||(AF=1,(function(t){function e(K,W){var J=K.length;K.push(W);e:for(;0<J;){var ee=J-1>>>1,Z=K[ee];if(0<i(Z,W))K[ee]=W,K[J]=Z,J=ee;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var W=K[0],J=K.pop();if(J!==W){K[0]=J;e:for(var ee=0,Z=K.length,B=Z>>>1;ee<B;){var G=2*(ee+1)-1,Q=K[G],te=G+1,he=K[te];if(0>i(Q,J))te<Z&&0>i(he,Q)?(K[ee]=he,K[te]=J,ee=te):(K[ee]=Q,K[G]=J,ee=G);else if(te<Z&&0>i(he,J))K[ee]=he,K[te]=J,ee=te;else break e}}return W}function i(K,W){var J=K.sortIndex-W.sortIndex;return J!==0?J:K.id-W.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,l=s.now();t.unstable_now=function(){return s.now()-l}}var c=[],u=[],d=1,f=null,g=3,p=!1,x=!1,v=!1,y=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function T(K){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=K)r(u),W.sortIndex=W.expirationTime,e(c,W);else break;W=n(u)}}function A(K){if(v=!1,T(K),!x)if(n(c)!==null)x=!0,C||(C=!0,L());else{var W=n(u);W!==null&&V(A,W.startTime-K)}}var C=!1,N=-1,F=5,k=-1;function R(){return y?!0:!(t.unstable_now()-k<F)}function I(){if(y=!1,C){var K=t.unstable_now();k=K;var W=!0;try{e:{x=!1,v&&(v=!1,E(N),N=-1),p=!0;var J=g;try{t:{for(T(K),f=n(c);f!==null&&!(f.expirationTime>K&&R());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,g=f.priorityLevel;var Z=ee(f.expirationTime<=K);if(K=t.unstable_now(),typeof Z=="function"){f.callback=Z,T(K),W=!0;break t}f===n(c)&&r(c),T(K)}else r(c);f=n(c)}if(f!==null)W=!0;else{var B=n(u);B!==null&&V(A,B.startTime-K),W=!1}}break e}finally{f=null,g=J,p=!1}W=void 0}}finally{W?L():C=!1}}}var L;if(typeof w=="function")L=function(){w(I)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,j=q.port2;q.port1.onmessage=I,L=function(){j.postMessage(null)}}else L=function(){b(I,0)};function V(K,W){N=b(function(){K(t.unstable_now())},W)}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"):F=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 W=3;break;default:W=g}var J=g;g=W;try{return K()}finally{g=J}},t.unstable_requestPaint=function(){y=!0},t.unstable_runWithPriority=function(K,W){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var J=g;g=K;try{return W()}finally{g=J}},t.unstable_scheduleCallback=function(K,W,J){var ee=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?ee+J:ee):J=ee,K){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=J+Z,K={id:d++,callback:W,priorityLevel:K,startTime:J,expirationTime:Z,sortIndex:-1},J>ee?(K.sortIndex=J,e(u,K),n(c)===null&&K===n(u)&&(v?(E(N),N=-1):v=!0,V(A,J-ee))):(K.sortIndex=Z,e(c,K),x||p||(x=!0,C||(C=!0,L()))),K},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(K){var W=g;return function(){var J=g;g=W;try{return K.apply(this,arguments)}finally{g=J}}}})(LT)),LT}var NF;function rie(){return NF||(NF=1,OT.exports=nie()),OT.exports}var IT={exports:{}},ca={};var CF;function iie(){if(CF)return ca;CF=1;var t=Jp();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 l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ca.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ca.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)},ca.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()}},ca.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))},ca.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ca.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ca.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},ca.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},ca.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},ca.requestFormReset=function(c){r.d.r(c)},ca.unstable_batchedUpdates=function(c,u){return c(u)},ca.useFormState=function(c,u,d){return s.H.useFormState(c,u,d)},ca.useFormStatus=function(){return s.H.useHostTransitionStatus()},ca.version="19.2.0",ca}var kF;function X9(){if(kF)return IT.exports;kF=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(),IT.exports=iie(),IT.exports}var PF;function aie(){if(PF)return mx;PF=1;var t=rie(),e=Jp(),n=X9();function r(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)m+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var m=h,_=h;if(h.alternate)for(;m.return;)m=m.return;else{h=m;do m=h,(m.flags&4098)!==0&&(_=m.return),h=m.return;while(h)}return m.tag===3?_:null}function s(h){if(h.tag===13){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function l(h){if(h.tag===31){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var m=h.alternate;if(!m){if(m=a(h),m===null)throw Error(r(188));return m!==h?null:h}for(var _=h,S=m;;){var P=_.return;if(P===null)break;var D=P.alternate;if(D===null){if(S=P.return,S!==null){_=S;continue}break}if(P.child===D.child){for(D=P.child;D;){if(D===_)return c(P),h;if(D===S)return c(P),m;D=D.sibling}throw Error(r(188))}if(_.return!==S.return)_=P,S=D;else{for(var X=!1,le=P.child;le;){if(le===_){X=!0,_=P,S=D;break}if(le===S){X=!0,S=P,_=D;break}le=le.sibling}if(!X){for(le=D.child;le;){if(le===_){X=!0,_=D,S=P;break}if(le===S){X=!0,S=D,_=P;break}le=le.sibling}if(!X)throw Error(r(189))}}if(_.alternate!==S)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:m}function d(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h;for(h=h.child;h!==null;){if(m=d(h),m!==null)return m;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),w=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function L(h){return h===null||typeof h!="object"?null:(h=I&&h[I]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case v:return"Fragment";case b:return"Profiler";case y:return"StrictMode";case A:return"Suspense";case C:return"SuspenseList";case k:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case w:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case T:var m=h.render;return h=h.displayName,h||(h=m.displayName||m.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case N:return m=h.displayName||null,m!==null?m:j(h.type)||"Memo";case F:m=h._payload,h=h._init;try{return j(h(m))}catch{}}return null}var V=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},ee=[],Z=-1;function B(h){return{current:h}}function G(h){0>Z||(h.current=ee[Z],ee[Z]=null,Z--)}function Q(h,m){Z++,ee[Z]=h.current,h.current=m}var te=B(null),he=B(null),oe=B(null),xe=B(null);function Te(h,m){switch(Q(oe,m),Q(he,h),Q(te,null),m.nodeType){case 9:case 11:h=(h=m.documentElement)&&(h=h.namespaceURI)?W5(h):0;break;default:if(h=m.tagName,m=m.namespaceURI)m=W5(m),h=q5(m,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}G(te),Q(te,h)}function me(){G(te),G(he),G(oe)}function ce(h){h.memoizedState!==null&&Q(xe,h);var m=te.current,_=q5(m,h.type);m!==_&&(Q(he,h),Q(te,_))}function Ce(h){he.current===h&&(G(te),G(he)),xe.current===h&&(G(xe),cx._currentValue=J)}var fe,Ie;function z(h){if(fe===void 0)try{throw Error()}catch(_){var m=_.stack.trim().match(/\n( *(at )?)/);fe=m&&m[1]||"",Ie=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+fe+h+Ie}var H=!1;function re(h,m){if(!h||H)return"";H=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(m){var ft=function(){throw Error()};if(Object.defineProperty(ft.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ft,[])}catch(st){var tt=st}Reflect.construct(h,[],ft)}else{try{ft.call()}catch(st){tt=st}h.call(ft.prototype)}}else{try{throw Error()}catch(st){tt=st}(ft=h())&&typeof ft.catch=="function"&&ft.catch(function(){})}}catch(st){if(st&&tt&&typeof st.stack=="string")return[st.stack,tt.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var D=S.DetermineComponentFrameRoot(),X=D[0],le=D[1];if(X&&le){var Ne=X.split(`
- `),Je=le.split(`
- `);for(P=S=0;S<Ne.length&&!Ne[S].includes("DetermineComponentFrameRoot");)S++;for(;P<Je.length&&!Je[P].includes("DetermineComponentFrameRoot");)P++;if(S===Ne.length||P===Je.length)for(S=Ne.length-1,P=Je.length-1;1<=S&&0<=P&&Ne[S]!==Je[P];)P--;for(;1<=S&&0<=P;S--,P--)if(Ne[S]!==Je[P]){if(S!==1||P!==1)do if(S--,P--,0>P||Ne[S]!==Je[P]){var ut=`
- `+Ne[S].replace(" at new "," at ");return h.displayName&&ut.includes("<anonymous>")&&(ut=ut.replace("<anonymous>",h.displayName)),ut}while(1<=S&&0<=P);break}}}finally{H=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?z(_):""}function $(h,m){switch(h.tag){case 26:case 27:case 5:return z(h.type);case 16:return z("Lazy");case 13:return h.child!==m&&m!==null?z("Suspense Fallback"):z("Suspense");case 19:return z("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 z("Activity");default:return""}}function Y(h){try{var m="",_=null;do m+=$(h,_),_=h,h=h.return;while(h);return m}catch(S){return`
- Error generating stack: `+S.message+`
- `+S.stack}}var se=Object.prototype.hasOwnProperty,ue=t.unstable_scheduleCallback,Ee=t.unstable_cancelCallback,Me=t.unstable_shouldYield,U=t.unstable_requestPaint,O=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,_e=t.unstable_NormalPriority,We=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,Ye=t.log,lt=t.unstable_setDisableYieldValue,de=null,ae=null;function ze(h){if(typeof Ye=="function"&<(h),ae&&typeof ae.setStrictMode=="function")try{ae.setStrictMode(de,h)}catch{}}var Ue=Math.clz32?Math.clz32:pe,et=Math.log,dt=Math.LN2;function pe(h){return h>>>=0,h===0?32:31-(et(h)/dt|0)|0}var nt=256,ve=262144,He=4194304;function je(h){var m=h&42;if(m!==0)return m;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function we(h,m,_){var S=h.pendingLanes;if(S===0)return 0;var P=0,D=h.suspendedLanes,X=h.pingedLanes;h=h.warmLanes;var le=S&134217727;return le!==0?(S=le&~D,S!==0?P=je(S):(X&=le,X!==0?P=je(X):_||(_=le&~h,_!==0&&(P=je(_))))):(le=S&~D,le!==0?P=je(le):X!==0?P=je(X):_||(_=S&~h,_!==0&&(P=je(_)))),P===0?0:m!==0&&m!==P&&(m&D)===0&&(D=P&-P,_=m&-m,D>=_||D===32&&(_&4194048)!==0)?m:P}function Xe(h,m){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&m)===0}function ot(h,m){switch(h){case 1:case 2:case 4:case 8:case 64:return m+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return m+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function St(){var h=He;return He<<=1,(He&62914560)===0&&(He=4194304),h}function Dt(h){for(var m=[],_=0;31>_;_++)m.push(h);return m}function qt(h,m){h.pendingLanes|=m,m!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ft(h,m,_,S,P,D){var X=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,Ne=h.expirationTimes,Je=h.hiddenUpdates;for(_=X&~_;0<_;){var ut=31-Ue(_),ft=1<<ut;le[ut]=0,Ne[ut]=-1;var tt=Je[ut];if(tt!==null)for(Je[ut]=null,ut=0;ut<tt.length;ut++){var st=tt[ut];st!==null&&(st.lane&=-536870913)}_&=~ft}S!==0&&kn(h,S,0),D!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=D&~(X&~m))}function kn(h,m,_){h.pendingLanes|=m,h.suspendedLanes&=~m;var S=31-Ue(m);h.entangledLanes|=m,h.entanglements[S]=h.entanglements[S]|1073741824|_&261930}function Nn(h,m){var _=h.entangledLanes|=m;for(h=h.entanglements;_;){var S=31-Ue(_),P=1<<S;P&m|h[S]&m&&(h[S]|=m),_&=~P}}function Lr(h,m){var _=m&-m;return _=(_&42)!==0?1:Er(_),(_&(h.suspendedLanes|m))!==0?0:_}function Er(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 br(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Tr(){var h=W.p;return h!==0?h:(h=window.event,h===void 0?32:gF(h.type))}function ei(h,m){var _=W.p;try{return W.p=h,m()}finally{W.p=_}}var Ar=Math.random().toString(36).slice(2),rn="__reactFiber$"+Ar,Oe="__reactProps$"+Ar,Jt="__reactContainer$"+Ar,Gr="__reactEvents$"+Ar,ge="__reactListeners$"+Ar,Ge="__reactHandles$"+Ar,rt="__reactResources$"+Ar,Ke="__reactMarker$"+Ar;function at(h){delete h[rn],delete h[Oe],delete h[Gr],delete h[ge],delete h[Ge]}function At(h){var m=h[rn];if(m)return m;for(var _=h.parentNode;_;){if(m=_[Jt]||_[rn]){if(_=m.alternate,m.child!==null||_!==null&&_.child!==null)for(h=eF(h);h!==null;){if(_=h[rn])return _;h=eF(h)}return m}h=_,_=h.parentNode}return null}function ie(h){if(h=h[rn]||h[Jt]){var m=h.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return h}return null}function Ae(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h.stateNode;throw Error(r(33))}function Fe(h){var m=h[rt];return m||(m=h[rt]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function Le(h){h[Ke]=!0}var Pe=new Set,ct={};function mt(h,m){Mt(h,m),Mt(h+"Capture",m)}function Mt(h,m){for(ct[h]=m,h=0;h<m.length;h++)Pe.add(m[h])}var _t=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Lt={},Ct={};function bt(h){return se.call(Ct,h)?!0:se.call(Lt,h)?!1:_t.test(h)?Ct[h]=!0:(Lt[h]=!0,!1)}function Yt(h,m,_){if(bt(m))if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(m);return;case"boolean":var S=m.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){h.removeAttribute(m);return}}h.setAttribute(m,""+_)}}function zt(h,m,_){if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(m);return}h.setAttribute(m,""+_)}}function on(h,m,_,S){if(S===null)h.removeAttribute(_);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(m,_,""+S)}}function pn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function _n(h){var m=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function Ut(h,m,_){var S=Object.getOwnPropertyDescriptor(h.constructor.prototype,m);if(!h.hasOwnProperty(m)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var P=S.get,D=S.set;return Object.defineProperty(h,m,{configurable:!0,get:function(){return P.call(this)},set:function(X){_=""+X,D.call(this,X)}}),Object.defineProperty(h,m,{enumerable:S.enumerable}),{getValue:function(){return _},setValue:function(X){_=""+X},stopTracking:function(){h._valueTracker=null,delete h[m]}}}}function en(h){if(!h._valueTracker){var m=_n(h)?"checked":"value";h._valueTracker=Ut(h,m,""+h[m])}}function nn(h){if(!h)return!1;var m=h._valueTracker;if(!m)return!0;var _=m.getValue(),S="";return h&&(S=_n(h)?h.checked?"true":"false":h.value),h=S,h!==_?(m.setValue(h),!0):!1}function Ir(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 Wr=/[\n"\\]/g;function Fn(h){return h.replace(Wr,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function vo(h,m,_,S,P,D,X,le){h.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?h.type=X:h.removeAttribute("type"),m!=null?X==="number"?(m===0&&h.value===""||h.value!=m)&&(h.value=""+pn(m)):h.value!==""+pn(m)&&(h.value=""+pn(m)):X!=="submit"&&X!=="reset"||h.removeAttribute("value"),m!=null?ki(h,X,pn(m)):_!=null?ki(h,X,pn(_)):S!=null&&h.removeAttribute("value"),P==null&&D!=null&&(h.defaultChecked=!!D),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),le!=null&&typeof le!="function"&&typeof le!="symbol"&&typeof le!="boolean"?h.name=""+pn(le):h.removeAttribute("name")}function zn(h,m,_,S,P,D,X,le){if(D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"&&(h.type=D),m!=null||_!=null){if(!(D!=="submit"&&D!=="reset"||m!=null)){en(h);return}_=_!=null?""+pn(_):"",m=m!=null?""+pn(m):_,le||m===h.value||(h.value=m),h.defaultValue=m}S=S??P,S=typeof S!="function"&&typeof S!="symbol"&&!!S,h.checked=le?h.checked:!!S,h.defaultChecked=!!S,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(h.name=X),en(h)}function ki(h,m,_){m==="number"&&Ir(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function mi(h,m,_,S){if(h=h.options,m){m={};for(var P=0;P<_.length;P++)m["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=m.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&S&&(h[_].defaultSelected=!0)}else{for(_=""+pn(_),m=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,S&&(h[P].defaultSelected=!0);return}m!==null||h[P].disabled||(m=h[P])}m!==null&&(m.selected=!0)}}function Pi(h,m,_){if(m!=null&&(m=""+pn(m),m!==h.value&&(h.value=m),_==null)){h.defaultValue!==m&&(h.defaultValue=m);return}h.defaultValue=_!=null?""+pn(_):""}function Wi(h,m,_,S){if(m==null){if(S!=null){if(_!=null)throw Error(r(92));if(V(S)){if(1<S.length)throw Error(r(93));S=S[0]}_=S}_==null&&(_=""),m=_}_=pn(m),h.defaultValue=_,S=h.textContent,S===_&&S!==""&&S!==null&&(h.value=S),en(h)}function Ko(h,m){if(m){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=m;return}}h.textContent=m}var Ol=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 $L(h,m,_){var S=m.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?S?h.setProperty(m,""):m==="float"?h.cssFloat="":h[m]="":S?h.setProperty(m,_):typeof _!="number"||_===0||Ol.has(m)?m==="float"?h.cssFloat=_:h[m]=(""+_).trim():h[m]=_+"px"}function VL(h,m,_){if(m!=null&&typeof m!="object")throw Error(r(62));if(h=h.style,_!=null){for(var S in _)!_.hasOwnProperty(S)||m!=null&&m.hasOwnProperty(S)||(S.indexOf("--")===0?h.setProperty(S,""):S==="float"?h.cssFloat="":h[S]="");for(var P in m)S=m[P],m.hasOwnProperty(P)&&_[P]!==S&&$L(h,P,S)}else for(var D in m)m.hasOwnProperty(D)&&$L(h,D,m[D])}function NE(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 qte=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"]]),Kte=/^[\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 fy(h){return Kte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Ll(){}var CE=null;function kE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var Tf=null,Af=null;function GL(h){var m=ie(h);if(m&&(h=m.stateNode)){var _=h[Oe]||null;e:switch(h=m.stateNode,m.type){case"input":if(vo(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),m=_.name,_.type==="radio"&&m!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Fn(""+m)+'"][type="radio"]'),m=0;m<_.length;m++){var S=_[m];if(S!==h&&S.form===h.form){var P=S[Oe]||null;if(!P)throw Error(r(90));vo(S,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(m=0;m<_.length;m++)S=_[m],S.form===h.form&&nn(S)}break e;case"textarea":Pi(h,_.value,_.defaultValue);break e;case"select":m=_.value,m!=null&&mi(h,!!_.multiple,m,!1)}}}var PE=!1;function WL(h,m,_){if(PE)return h(m,_);PE=!0;try{var S=h(m);return S}finally{if(PE=!1,(Tf!==null||Af!==null)&&(ev(),Tf&&(m=Tf,h=Af,Af=Tf=null,GL(m),h)))for(m=0;m<h.length;m++)GL(h[m])}}function Tg(h,m){var _=h.stateNode;if(_===null)return null;var S=_[Oe]||null;if(S===null)return null;_=S[m];e:switch(m){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(h=h.type,S=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!S;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,m,typeof _));return _}var Il=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),jE=!1;if(Il)try{var Ag={};Object.defineProperty(Ag,"passive",{get:function(){jE=!0}}),window.addEventListener("test",Ag,Ag),window.removeEventListener("test",Ag,Ag)}catch{jE=!1}var tu=null,RE=null,my=null;function qL(){if(my)return my;var h,m=RE,_=m.length,S,P="value"in tu?tu.value:tu.textContent,D=P.length;for(h=0;h<_&&m[h]===P[h];h++);var X=_-h;for(S=1;S<=X&&m[_-S]===P[D-S];S++);return my=P.slice(h,1<S?1-S:void 0)}function py(h){var m=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&m===13&&(h=13)):h=m,h===10&&(h=13),32<=h||h===13?h:0}function gy(){return!0}function KL(){return!1}function Ba(h){function m(_,S,P,D,X){this._reactName=_,this._targetInst=P,this.type=S,this.nativeEvent=D,this.target=X,this.currentTarget=null;for(var le in h)h.hasOwnProperty(le)&&(_=h[le],this[le]=_?_(D):D[le]);return this.isDefaultPrevented=(D.defaultPrevented!=null?D.defaultPrevented:D.returnValue===!1)?gy:KL,this.isPropagationStopped=KL,this}return f(m.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=gy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=gy)},persist:function(){},isPersistent:gy}),m}var Ld={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xy=Ba(Ld),Ng=f({},Ld,{view:0,detail:0}),Xte=Ba(Ng),DE,OE,Cg,by=f({},Ng,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:IE,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!==Cg&&(Cg&&h.type==="mousemove"?(DE=h.screenX-Cg.screenX,OE=h.screenY-Cg.screenY):OE=DE=0,Cg=h),DE)},movementY:function(h){return"movementY"in h?h.movementY:OE}}),XL=Ba(by),Yte=f({},by,{dataTransfer:0}),Zte=Ba(Yte),Qte=f({},Ng,{relatedTarget:0}),LE=Ba(Qte),Jte=f({},Ld,{animationName:0,elapsedTime:0,pseudoElement:0}),ene=Ba(Jte),tne=f({},Ld,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),nne=Ba(tne),rne=f({},Ld,{data:0}),YL=Ba(rne),ine={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ane={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"},sne={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function one(h){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(h):(h=sne[h])?!!m[h]:!1}function IE(){return one}var lne=f({},Ng,{key:function(h){if(h.key){var m=ine[h.key]||h.key;if(m!=="Unidentified")return m}return h.type==="keypress"?(h=py(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?ane[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:IE,charCode:function(h){return h.type==="keypress"?py(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?py(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),cne=Ba(lne),une=f({},by,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ZL=Ba(une),dne=f({},Ng,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:IE}),hne=Ba(dne),fne=f({},Ld,{propertyName:0,elapsedTime:0,pseudoElement:0}),mne=Ba(fne),pne=f({},by,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),gne=Ba(pne),xne=f({},Ld,{newState:0,oldState:0}),bne=Ba(xne),yne=[9,13,27,32],FE=Il&&"CompositionEvent"in window,kg=null;Il&&"documentMode"in document&&(kg=document.documentMode);var vne=Il&&"TextEvent"in window&&!kg,QL=Il&&(!FE||kg&&8<kg&&11>=kg),JL=" ",e4=!1;function t4(h,m){switch(h){case"keyup":return yne.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function n4(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Nf=!1;function _ne(h,m){switch(h){case"compositionend":return n4(m);case"keypress":return m.which!==32?null:(e4=!0,JL);case"textInput":return h=m.data,h===JL&&e4?null:h;default:return null}}function wne(h,m){if(Nf)return h==="compositionend"||!FE&&t4(h,m)?(h=qL(),my=RE=tu=null,Nf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1<m.char.length)return m.char;if(m.which)return String.fromCharCode(m.which)}return null;case"compositionend":return QL&&m.locale!=="ko"?null:m.data;default:return null}}var Sne={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 r4(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m==="input"?!!Sne[h.type]:m==="textarea"}function i4(h,m,_,S){Tf?Af?Af.push(S):Af=[S]:Tf=S,m=ov(m,"onChange"),0<m.length&&(_=new xy("onChange","change",null,_,S),h.push({event:_,listeners:m}))}var Pg=null,jg=null;function Mne(h){z5(h,0)}function yy(h){var m=Ae(h);if(nn(m))return h}function a4(h,m){if(h==="change")return m}var s4=!1;if(Il){var UE;if(Il){var zE="oninput"in document;if(!zE){var o4=document.createElement("div");o4.setAttribute("oninput","return;"),zE=typeof o4.oninput=="function"}UE=zE}else UE=!1;s4=UE&&(!document.documentMode||9<document.documentMode)}function l4(){Pg&&(Pg.detachEvent("onpropertychange",c4),jg=Pg=null)}function c4(h){if(h.propertyName==="value"&&yy(jg)){var m=[];i4(m,jg,h,kE(h)),WL(Mne,m)}}function Ene(h,m,_){h==="focusin"?(l4(),Pg=m,jg=_,Pg.attachEvent("onpropertychange",c4)):h==="focusout"&&l4()}function Tne(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return yy(jg)}function Ane(h,m){if(h==="click")return yy(m)}function Nne(h,m){if(h==="input"||h==="change")return yy(m)}function Cne(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var us=typeof Object.is=="function"?Object.is:Cne;function Rg(h,m){if(us(h,m))return!0;if(typeof h!="object"||h===null||typeof m!="object"||m===null)return!1;var _=Object.keys(h),S=Object.keys(m);if(_.length!==S.length)return!1;for(S=0;S<_.length;S++){var P=_[S];if(!se.call(m,P)||!us(h[P],m[P]))return!1}return!0}function u4(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function d4(h,m){var _=u4(h);h=0;for(var S;_;){if(_.nodeType===3){if(S=h+_.textContent.length,h<=m&&S>=m)return{node:_,offset:m-h};h=S}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=u4(_)}}function h4(h,m){return h&&m?h===m?!0:h&&h.nodeType===3?!1:m&&m.nodeType===3?h4(h,m.parentNode):"contains"in h?h.contains(m):h.compareDocumentPosition?!!(h.compareDocumentPosition(m)&16):!1:!1}function f4(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var m=Ir(h.document);m instanceof h.HTMLIFrameElement;){try{var _=typeof m.contentWindow.location.href=="string"}catch{_=!1}if(_)h=m.contentWindow;else break;m=Ir(h.document)}return m}function BE(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m&&(m==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||m==="textarea"||h.contentEditable==="true")}var kne=Il&&"documentMode"in document&&11>=document.documentMode,Cf=null,HE=null,Dg=null,$E=!1;function m4(h,m,_){var S=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;$E||Cf==null||Cf!==Ir(S)||(S=Cf,"selectionStart"in S&&BE(S)?S={start:S.selectionStart,end:S.selectionEnd}:(S=(S.ownerDocument&&S.ownerDocument.defaultView||window).getSelection(),S={anchorNode:S.anchorNode,anchorOffset:S.anchorOffset,focusNode:S.focusNode,focusOffset:S.focusOffset}),Dg&&Rg(Dg,S)||(Dg=S,S=ov(HE,"onSelect"),0<S.length&&(m=new xy("onSelect","select",null,m,_),h.push({event:m,listeners:S}),m.target=Cf)))}function Id(h,m){var _={};return _[h.toLowerCase()]=m.toLowerCase(),_["Webkit"+h]="webkit"+m,_["Moz"+h]="moz"+m,_}var kf={animationend:Id("Animation","AnimationEnd"),animationiteration:Id("Animation","AnimationIteration"),animationstart:Id("Animation","AnimationStart"),transitionrun:Id("Transition","TransitionRun"),transitionstart:Id("Transition","TransitionStart"),transitioncancel:Id("Transition","TransitionCancel"),transitionend:Id("Transition","TransitionEnd")},VE={},p4={};Il&&(p4=document.createElement("div").style,"AnimationEvent"in window||(delete kf.animationend.animation,delete kf.animationiteration.animation,delete kf.animationstart.animation),"TransitionEvent"in window||delete kf.transitionend.transition);function Fd(h){if(VE[h])return VE[h];if(!kf[h])return h;var m=kf[h],_;for(_ in m)if(m.hasOwnProperty(_)&&_ in p4)return VE[h]=m[_];return h}var g4=Fd("animationend"),x4=Fd("animationiteration"),b4=Fd("animationstart"),Pne=Fd("transitionrun"),jne=Fd("transitionstart"),Rne=Fd("transitioncancel"),y4=Fd("transitionend"),v4=new Map,GE="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(" ");GE.push("scrollEnd");function _o(h,m){v4.set(h,m),mt(m,[h])}var vy=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var m=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(m))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Ds=[],Pf=0,WE=0;function _y(){for(var h=Pf,m=WE=Pf=0;m<h;){var _=Ds[m];Ds[m++]=null;var S=Ds[m];Ds[m++]=null;var P=Ds[m];Ds[m++]=null;var D=Ds[m];if(Ds[m++]=null,S!==null&&P!==null){var X=S.pending;X===null?P.next=P:(P.next=X.next,X.next=P),S.pending=P}D!==0&&_4(_,P,D)}}function wy(h,m,_,S){Ds[Pf++]=h,Ds[Pf++]=m,Ds[Pf++]=_,Ds[Pf++]=S,WE|=S,h.lanes|=S,h=h.alternate,h!==null&&(h.lanes|=S)}function qE(h,m,_,S){return wy(h,m,_,S),Sy(h)}function Ud(h,m){return wy(h,null,null,m),Sy(h)}function _4(h,m,_){h.lanes|=_;var S=h.alternate;S!==null&&(S.lanes|=_);for(var P=!1,D=h.return;D!==null;)D.childLanes|=_,S=D.alternate,S!==null&&(S.childLanes|=_),D.tag===22&&(h=D.stateNode,h===null||h._visibility&1||(P=!0)),h=D,D=D.return;return h.tag===3?(D=h.stateNode,P&&m!==null&&(P=31-Ue(_),h=D.hiddenUpdates,S=h[P],S===null?h[P]=[m]:S.push(m),m.lane=_|536870912),D):null}function Sy(h){if(50<nx)throw nx=0,nT=null,Error(r(185));for(var m=h.return;m!==null;)h=m,m=h.return;return h.tag===3?h.stateNode:null}var jf={};function Dne(h,m,_,S){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ds(h,m,_,S){return new Dne(h,m,_,S)}function KE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Fl(h,m){var _=h.alternate;return _===null?(_=ds(h.tag,m,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=m,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,m=h.dependencies,_.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function w4(h,m){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=m,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,m=_.dependencies,h.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext}),h}function My(h,m,_,S,P,D){var X=0;if(S=h,typeof h=="function")KE(h)&&(X=1);else if(typeof h=="string")X=Ure(h,_,te.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case k:return h=ds(31,_,m,P),h.elementType=k,h.lanes=D,h;case v:return zd(_.children,P,D,m);case y:X=8,P|=24;break;case b:return h=ds(12,_,m,P|2),h.elementType=b,h.lanes=D,h;case A:return h=ds(13,_,m,P),h.elementType=A,h.lanes=D,h;case C:return h=ds(19,_,m,P),h.elementType=C,h.lanes=D,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case w:X=10;break e;case E:X=9;break e;case T:X=11;break e;case N:X=14;break e;case F:X=16,S=null;break e}X=29,_=Error(r(130,h===null?"null":typeof h,"")),S=null}return m=ds(X,_,m,P),m.elementType=h,m.type=S,m.lanes=D,m}function zd(h,m,_,S){return h=ds(7,h,S,m),h.lanes=_,h}function XE(h,m,_){return h=ds(6,h,null,m),h.lanes=_,h}function S4(h){var m=ds(18,null,null,0);return m.stateNode=h,m}function YE(h,m,_){return m=ds(4,h.children!==null?h.children:[],h.key,m),m.lanes=_,m.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},m}var M4=new WeakMap;function Os(h,m){if(typeof h=="object"&&h!==null){var _=M4.get(h);return _!==void 0?_:(m={value:h,source:m,stack:Y(m)},M4.set(h,m),m)}return{value:h,source:m,stack:Y(m)}}var Rf=[],Df=0,Ey=null,Og=0,Ls=[],Is=0,nu=null,Xo=1,Yo="";function Ul(h,m){Rf[Df++]=Og,Rf[Df++]=Ey,Ey=h,Og=m}function E4(h,m,_){Ls[Is++]=Xo,Ls[Is++]=Yo,Ls[Is++]=nu,nu=h;var S=Xo;h=Yo;var P=32-Ue(S)-1;S&=~(1<<P),_+=1;var D=32-Ue(m)+P;if(30<D){var X=P-P%5;D=(S&(1<<X)-1).toString(32),S>>=X,P-=X,Xo=1<<32-Ue(m)+P|_<<P|S,Yo=D+h}else Xo=1<<D|_<<P|S,Yo=h}function ZE(h){h.return!==null&&(Ul(h,1),E4(h,1,0))}function QE(h){for(;h===Ey;)Ey=Rf[--Df],Rf[Df]=null,Og=Rf[--Df],Rf[Df]=null;for(;h===nu;)nu=Ls[--Is],Ls[Is]=null,Yo=Ls[--Is],Ls[Is]=null,Xo=Ls[--Is],Ls[Is]=null}function T4(h,m){Ls[Is++]=Xo,Ls[Is++]=Yo,Ls[Is++]=nu,Xo=m.id,Yo=m.overflow,nu=h}var qi=null,hr=null,Tn=!1,ru=null,Fs=!1,JE=Error(r(519));function iu(h){var m=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Lg(Os(m,h)),JE}function A4(h){var m=h.stateNode,_=h.type,S=h.memoizedProps;switch(m[rn]=h,m[Oe]=S,_){case"dialog":bn("cancel",m),bn("close",m);break;case"iframe":case"object":case"embed":bn("load",m);break;case"video":case"audio":for(_=0;_<ix.length;_++)bn(ix[_],m);break;case"source":bn("error",m);break;case"img":case"image":case"link":bn("error",m),bn("load",m);break;case"details":bn("toggle",m);break;case"input":bn("invalid",m),zn(m,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":bn("invalid",m);break;case"textarea":bn("invalid",m),Wi(m,S.value,S.defaultValue,S.children)}_=S.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||m.textContent===""+_||S.suppressHydrationWarning===!0||V5(m.textContent,_)?(S.popover!=null&&(bn("beforetoggle",m),bn("toggle",m)),S.onScroll!=null&&bn("scroll",m),S.onScrollEnd!=null&&bn("scrollend",m),S.onClick!=null&&(m.onclick=Ll),m=!0):m=!1,m||iu(h,!0)}function N4(h){for(qi=h.return;qi;)switch(qi.tag){case 5:case 31:case 13:Fs=!1;return;case 27:case 3:Fs=!0;return;default:qi=qi.return}}function Of(h){if(h!==qi)return!1;if(!Tn)return N4(h),Tn=!0,!1;var m=h.tag,_;if((_=m!==3&&m!==27)&&((_=m===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||xT(h.type,h.memoizedProps)),_=!_),_&&hr&&iu(h),N4(h),m===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));hr=J5(h)}else if(m===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));hr=J5(h)}else m===27?(m=hr,bu(h.type)?(h=wT,wT=null,hr=h):hr=m):hr=qi?zs(h.stateNode.nextSibling):null;return!0}function Bd(){hr=qi=null,Tn=!1}function e2(){var h=ru;return h!==null&&(Ga===null?Ga=h:Ga.push.apply(Ga,h),ru=null),h}function Lg(h){ru===null?ru=[h]:ru.push(h)}var t2=B(null),Hd=null,zl=null;function au(h,m,_){Q(t2,m._currentValue),m._currentValue=_}function Bl(h){h._currentValue=t2.current,G(t2)}function n2(h,m,_){for(;h!==null;){var S=h.alternate;if((h.childLanes&m)!==m?(h.childLanes|=m,S!==null&&(S.childLanes|=m)):S!==null&&(S.childLanes&m)!==m&&(S.childLanes|=m),h===_)break;h=h.return}}function r2(h,m,_,S){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var D=P.dependencies;if(D!==null){var X=P.child;D=D.firstContext;e:for(;D!==null;){var le=D;D=P;for(var Ne=0;Ne<m.length;Ne++)if(le.context===m[Ne]){D.lanes|=_,le=D.alternate,le!==null&&(le.lanes|=_),n2(D.return,_,h),S||(X=null);break e}D=le.next}}else if(P.tag===18){if(X=P.return,X===null)throw Error(r(341));X.lanes|=_,D=X.alternate,D!==null&&(D.lanes|=_),n2(X,_,h),X=null}else X=P.child;if(X!==null)X.return=P;else for(X=P;X!==null;){if(X===h){X=null;break}if(P=X.sibling,P!==null){P.return=X.return,X=P;break}X=X.return}P=X}}function Lf(h,m,_,S){h=null;for(var P=m,D=!1;P!==null;){if(!D){if((P.flags&524288)!==0)D=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var X=P.alternate;if(X===null)throw Error(r(387));if(X=X.memoizedProps,X!==null){var le=P.type;us(P.pendingProps.value,X.value)||(h!==null?h.push(le):h=[le])}}else if(P===xe.current){if(X=P.alternate,X===null)throw Error(r(387));X.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(cx):h=[cx])}P=P.return}h!==null&&r2(m,h,_,S),m.flags|=262144}function Ty(h){for(h=h.firstContext;h!==null;){if(!us(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function $d(h){Hd=h,zl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Ki(h){return C4(Hd,h)}function Ay(h,m){return Hd===null&&$d(h),C4(h,m)}function C4(h,m){var _=m._currentValue;if(m={context:m,memoizedValue:_,next:null},zl===null){if(h===null)throw Error(r(308));zl=m,h.dependencies={lanes:0,firstContext:m},h.flags|=524288}else zl=zl.next=m;return _}var One=typeof AbortController<"u"?AbortController:function(){var h=[],m=this.signal={aborted:!1,addEventListener:function(_,S){h.push(S)}};this.abort=function(){m.aborted=!0,h.forEach(function(_){return _()})}},Lne=t.unstable_scheduleCallback,Ine=t.unstable_NormalPriority,ti={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function i2(){return{controller:new One,data:new Map,refCount:0}}function Ig(h){h.refCount--,h.refCount===0&&Lne(Ine,function(){h.controller.abort()})}var Fg=null,a2=0,If=0,Ff=null;function Fne(h,m){if(Fg===null){var _=Fg=[];a2=0,If=lT(),Ff={status:"pending",value:void 0,then:function(S){_.push(S)}}}return a2++,m.then(k4,k4),m}function k4(){if(--a2===0&&Fg!==null){Ff!==null&&(Ff.status="fulfilled");var h=Fg;Fg=null,If=0,Ff=null;for(var m=0;m<h.length;m++)(0,h[m])()}}function Une(h,m){var _=[],S={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){S.status="fulfilled",S.value=m;for(var P=0;P<_.length;P++)(0,_[P])(m)},function(P){for(S.status="rejected",S.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),S}var P4=K.S;K.S=function(h,m){m5=O(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&Fne(h,m),P4!==null&&P4(h,m)};var Vd=B(null);function s2(){var h=Vd.current;return h!==null?h:ar.pooledCache}function Ny(h,m){m===null?Q(Vd,Vd.current):Q(Vd,m.pool)}function j4(){var h=s2();return h===null?null:{parent:ti._currentValue,pool:h}}var Uf=Error(r(460)),o2=Error(r(474)),Cy=Error(r(542)),ky={then:function(){}};function R4(h){return h=h.status,h==="fulfilled"||h==="rejected"}function D4(h,m,_){switch(_=h[_],_===void 0?h.push(m):_!==m&&(m.then(Ll,Ll),m=_),m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,L4(h),h;default:if(typeof m.status=="string")m.then(Ll,Ll);else{if(h=ar,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=m,h.status="pending",h.then(function(S){if(m.status==="pending"){var P=m;P.status="fulfilled",P.value=S}},function(S){if(m.status==="pending"){var P=m;P.status="rejected",P.reason=S}})}switch(m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,L4(h),h}throw Wd=m,Uf}}function Gd(h){try{var m=h._init;return m(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Wd=_,Uf):_}}var Wd=null;function O4(){if(Wd===null)throw Error(r(459));var h=Wd;return Wd=null,h}function L4(h){if(h===Uf||h===Cy)throw Error(r(483))}var zf=null,Ug=0;function Py(h){var m=Ug;return Ug+=1,zf===null&&(zf=[]),D4(zf,h,m)}function zg(h,m){m=m.props.ref,h.ref=m!==void 0?m:null}function jy(h,m){throw m.$$typeof===g?Error(r(525)):(h=Object.prototype.toString.call(m),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(m).join(", ")+"}":h)))}function I4(h){function m($e,Re){if(h){var Qe=$e.deletions;Qe===null?($e.deletions=[Re],$e.flags|=16):Qe.push(Re)}}function _($e,Re){if(!h)return null;for(;Re!==null;)m($e,Re),Re=Re.sibling;return null}function S($e){for(var Re=new Map;$e!==null;)$e.key!==null?Re.set($e.key,$e):Re.set($e.index,$e),$e=$e.sibling;return Re}function P($e,Re){return $e=Fl($e,Re),$e.index=0,$e.sibling=null,$e}function D($e,Re,Qe){return $e.index=Qe,h?(Qe=$e.alternate,Qe!==null?(Qe=Qe.index,Qe<Re?($e.flags|=67108866,Re):Qe):($e.flags|=67108866,Re)):($e.flags|=1048576,Re)}function X($e){return h&&$e.alternate===null&&($e.flags|=67108866),$e}function le($e,Re,Qe,ht){return Re===null||Re.tag!==6?(Re=XE(Qe,$e.mode,ht),Re.return=$e,Re):(Re=P(Re,Qe),Re.return=$e,Re)}function Ne($e,Re,Qe,ht){var Bt=Qe.type;return Bt===v?ut($e,Re,Qe.props.children,ht,Qe.key):Re!==null&&(Re.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===F&&Gd(Bt)===Re.type)?(Re=P(Re,Qe.props),zg(Re,Qe),Re.return=$e,Re):(Re=My(Qe.type,Qe.key,Qe.props,null,$e.mode,ht),zg(Re,Qe),Re.return=$e,Re)}function Je($e,Re,Qe,ht){return Re===null||Re.tag!==4||Re.stateNode.containerInfo!==Qe.containerInfo||Re.stateNode.implementation!==Qe.implementation?(Re=YE(Qe,$e.mode,ht),Re.return=$e,Re):(Re=P(Re,Qe.children||[]),Re.return=$e,Re)}function ut($e,Re,Qe,ht,Bt){return Re===null||Re.tag!==7?(Re=zd(Qe,$e.mode,ht,Bt),Re.return=$e,Re):(Re=P(Re,Qe),Re.return=$e,Re)}function ft($e,Re,Qe){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return Re=XE(""+Re,$e.mode,Qe),Re.return=$e,Re;if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case p:return Qe=My(Re.type,Re.key,Re.props,null,$e.mode,Qe),zg(Qe,Re),Qe.return=$e,Qe;case x:return Re=YE(Re,$e.mode,Qe),Re.return=$e,Re;case F:return Re=Gd(Re),ft($e,Re,Qe)}if(V(Re)||L(Re))return Re=zd(Re,$e.mode,Qe,null),Re.return=$e,Re;if(typeof Re.then=="function")return ft($e,Py(Re),Qe);if(Re.$$typeof===w)return ft($e,Ay($e,Re),Qe);jy($e,Re)}return null}function tt($e,Re,Qe,ht){var Bt=Re!==null?Re.key:null;if(typeof Qe=="string"&&Qe!==""||typeof Qe=="number"||typeof Qe=="bigint")return Bt!==null?null:le($e,Re,""+Qe,ht);if(typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case p:return Qe.key===Bt?Ne($e,Re,Qe,ht):null;case x:return Qe.key===Bt?Je($e,Re,Qe,ht):null;case F:return Qe=Gd(Qe),tt($e,Re,Qe,ht)}if(V(Qe)||L(Qe))return Bt!==null?null:ut($e,Re,Qe,ht,null);if(typeof Qe.then=="function")return tt($e,Re,Py(Qe),ht);if(Qe.$$typeof===w)return tt($e,Re,Ay($e,Qe),ht);jy($e,Qe)}return null}function st($e,Re,Qe,ht,Bt){if(typeof ht=="string"&&ht!==""||typeof ht=="number"||typeof ht=="bigint")return $e=$e.get(Qe)||null,le(Re,$e,""+ht,Bt);if(typeof ht=="object"&&ht!==null){switch(ht.$$typeof){case p:return $e=$e.get(ht.key===null?Qe:ht.key)||null,Ne(Re,$e,ht,Bt);case x:return $e=$e.get(ht.key===null?Qe:ht.key)||null,Je(Re,$e,ht,Bt);case F:return ht=Gd(ht),st($e,Re,Qe,ht,Bt)}if(V(ht)||L(ht))return $e=$e.get(Qe)||null,ut(Re,$e,ht,Bt,null);if(typeof ht.then=="function")return st($e,Re,Qe,Py(ht),Bt);if(ht.$$typeof===w)return st($e,Re,Qe,Ay(Re,ht),Bt);jy(Re,ht)}return null}function Ot($e,Re,Qe,ht){for(var Bt=null,Pn=null,It=Re,sn=Re=0,Sn=null;It!==null&&sn<Qe.length;sn++){It.index>sn?(Sn=It,It=null):Sn=It.sibling;var jn=tt($e,It,Qe[sn],ht);if(jn===null){It===null&&(It=Sn);break}h&&It&&jn.alternate===null&&m($e,It),Re=D(jn,Re,sn),Pn===null?Bt=jn:Pn.sibling=jn,Pn=jn,It=Sn}if(sn===Qe.length)return _($e,It),Tn&&Ul($e,sn),Bt;if(It===null){for(;sn<Qe.length;sn++)It=ft($e,Qe[sn],ht),It!==null&&(Re=D(It,Re,sn),Pn===null?Bt=It:Pn.sibling=It,Pn=It);return Tn&&Ul($e,sn),Bt}for(It=S(It);sn<Qe.length;sn++)Sn=st(It,$e,sn,Qe[sn],ht),Sn!==null&&(h&&Sn.alternate!==null&&It.delete(Sn.key===null?sn:Sn.key),Re=D(Sn,Re,sn),Pn===null?Bt=Sn:Pn.sibling=Sn,Pn=Sn);return h&&It.forEach(function(Su){return m($e,Su)}),Tn&&Ul($e,sn),Bt}function Wt($e,Re,Qe,ht){if(Qe==null)throw Error(r(151));for(var Bt=null,Pn=null,It=Re,sn=Re=0,Sn=null,jn=Qe.next();It!==null&&!jn.done;sn++,jn=Qe.next()){It.index>sn?(Sn=It,It=null):Sn=It.sibling;var Su=tt($e,It,jn.value,ht);if(Su===null){It===null&&(It=Sn);break}h&&It&&Su.alternate===null&&m($e,It),Re=D(Su,Re,sn),Pn===null?Bt=Su:Pn.sibling=Su,Pn=Su,It=Sn}if(jn.done)return _($e,It),Tn&&Ul($e,sn),Bt;if(It===null){for(;!jn.done;sn++,jn=Qe.next())jn=ft($e,jn.value,ht),jn!==null&&(Re=D(jn,Re,sn),Pn===null?Bt=jn:Pn.sibling=jn,Pn=jn);return Tn&&Ul($e,sn),Bt}for(It=S(It);!jn.done;sn++,jn=Qe.next())jn=st(It,$e,sn,jn.value,ht),jn!==null&&(h&&jn.alternate!==null&&It.delete(jn.key===null?sn:jn.key),Re=D(jn,Re,sn),Pn===null?Bt=jn:Pn.sibling=jn,Pn=jn);return h&&It.forEach(function(Yre){return m($e,Yre)}),Tn&&Ul($e,sn),Bt}function Yn($e,Re,Qe,ht){if(typeof Qe=="object"&&Qe!==null&&Qe.type===v&&Qe.key===null&&(Qe=Qe.props.children),typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case p:e:{for(var Bt=Qe.key;Re!==null;){if(Re.key===Bt){if(Bt=Qe.type,Bt===v){if(Re.tag===7){_($e,Re.sibling),ht=P(Re,Qe.props.children),ht.return=$e,$e=ht;break e}}else if(Re.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===F&&Gd(Bt)===Re.type){_($e,Re.sibling),ht=P(Re,Qe.props),zg(ht,Qe),ht.return=$e,$e=ht;break e}_($e,Re);break}else m($e,Re);Re=Re.sibling}Qe.type===v?(ht=zd(Qe.props.children,$e.mode,ht,Qe.key),ht.return=$e,$e=ht):(ht=My(Qe.type,Qe.key,Qe.props,null,$e.mode,ht),zg(ht,Qe),ht.return=$e,$e=ht)}return X($e);case x:e:{for(Bt=Qe.key;Re!==null;){if(Re.key===Bt)if(Re.tag===4&&Re.stateNode.containerInfo===Qe.containerInfo&&Re.stateNode.implementation===Qe.implementation){_($e,Re.sibling),ht=P(Re,Qe.children||[]),ht.return=$e,$e=ht;break e}else{_($e,Re);break}else m($e,Re);Re=Re.sibling}ht=YE(Qe,$e.mode,ht),ht.return=$e,$e=ht}return X($e);case F:return Qe=Gd(Qe),Yn($e,Re,Qe,ht)}if(V(Qe))return Ot($e,Re,Qe,ht);if(L(Qe)){if(Bt=L(Qe),typeof Bt!="function")throw Error(r(150));return Qe=Bt.call(Qe),Wt($e,Re,Qe,ht)}if(typeof Qe.then=="function")return Yn($e,Re,Py(Qe),ht);if(Qe.$$typeof===w)return Yn($e,Re,Ay($e,Qe),ht);jy($e,Qe)}return typeof Qe=="string"&&Qe!==""||typeof Qe=="number"||typeof Qe=="bigint"?(Qe=""+Qe,Re!==null&&Re.tag===6?(_($e,Re.sibling),ht=P(Re,Qe),ht.return=$e,$e=ht):(_($e,Re),ht=XE(Qe,$e.mode,ht),ht.return=$e,$e=ht),X($e)):_($e,Re)}return function($e,Re,Qe,ht){try{Ug=0;var Bt=Yn($e,Re,Qe,ht);return zf=null,Bt}catch(It){if(It===Uf||It===Cy)throw It;var Pn=ds(29,It,null,$e.mode);return Pn.lanes=ht,Pn.return=$e,Pn}finally{}}}var qd=I4(!0),F4=I4(!1),su=!1;function l2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function c2(h,m){h=h.updateQueue,m.updateQueue===h&&(m.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function ou(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function lu(h,m,_){var S=h.updateQueue;if(S===null)return null;if(S=S.shared,(Ln&2)!==0){var P=S.pending;return P===null?m.next=m:(m.next=P.next,P.next=m),S.pending=m,m=Sy(h),_4(h,null,_),m}return wy(h,S,m,_),Sy(h)}function Bg(h,m,_){if(m=m.updateQueue,m!==null&&(m=m.shared,(_&4194048)!==0)){var S=m.lanes;S&=h.pendingLanes,_|=S,m.lanes=_,Nn(h,_)}}function u2(h,m){var _=h.updateQueue,S=h.alternate;if(S!==null&&(S=S.updateQueue,_===S)){var P=null,D=null;if(_=_.firstBaseUpdate,_!==null){do{var X={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};D===null?P=D=X:D=D.next=X,_=_.next}while(_!==null);D===null?P=D=m:D=D.next=m}else P=D=m;_={baseState:S.baseState,firstBaseUpdate:P,lastBaseUpdate:D,shared:S.shared,callbacks:S.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=m:h.next=m,_.lastBaseUpdate=m}var d2=!1;function Hg(){if(d2){var h=Ff;if(h!==null)throw h}}function $g(h,m,_,S){d2=!1;var P=h.updateQueue;su=!1;var D=P.firstBaseUpdate,X=P.lastBaseUpdate,le=P.shared.pending;if(le!==null){P.shared.pending=null;var Ne=le,Je=Ne.next;Ne.next=null,X===null?D=Je:X.next=Je,X=Ne;var ut=h.alternate;ut!==null&&(ut=ut.updateQueue,le=ut.lastBaseUpdate,le!==X&&(le===null?ut.firstBaseUpdate=Je:le.next=Je,ut.lastBaseUpdate=Ne))}if(D!==null){var ft=P.baseState;X=0,ut=Je=Ne=null,le=D;do{var tt=le.lane&-536870913,st=tt!==le.lane;if(st?(wn&tt)===tt:(S&tt)===tt){tt!==0&&tt===If&&(d2=!0),ut!==null&&(ut=ut.next={lane:0,tag:le.tag,payload:le.payload,callback:null,next:null});e:{var Ot=h,Wt=le;tt=m;var Yn=_;switch(Wt.tag){case 1:if(Ot=Wt.payload,typeof Ot=="function"){ft=Ot.call(Yn,ft,tt);break e}ft=Ot;break e;case 3:Ot.flags=Ot.flags&-65537|128;case 0:if(Ot=Wt.payload,tt=typeof Ot=="function"?Ot.call(Yn,ft,tt):Ot,tt==null)break e;ft=f({},ft,tt);break e;case 2:su=!0}}tt=le.callback,tt!==null&&(h.flags|=64,st&&(h.flags|=8192),st=P.callbacks,st===null?P.callbacks=[tt]:st.push(tt))}else st={lane:tt,tag:le.tag,payload:le.payload,callback:le.callback,next:null},ut===null?(Je=ut=st,Ne=ft):ut=ut.next=st,X|=tt;if(le=le.next,le===null){if(le=P.shared.pending,le===null)break;st=le,le=st.next,st.next=null,P.lastBaseUpdate=st,P.shared.pending=null}}while(!0);ut===null&&(Ne=ft),P.baseState=Ne,P.firstBaseUpdate=Je,P.lastBaseUpdate=ut,D===null&&(P.shared.lanes=0),fu|=X,h.lanes=X,h.memoizedState=ft}}function U4(h,m){if(typeof h!="function")throw Error(r(191,h));h.call(m)}function z4(h,m){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)U4(_[h],m)}var Bf=B(null),Ry=B(0);function B4(h,m){h=Yl,Q(Ry,h),Q(Bf,m),Yl=h|m.baseLanes}function h2(){Q(Ry,Yl),Q(Bf,Bf.current)}function f2(){Yl=Ry.current,G(Bf),G(Ry)}var hs=B(null),Us=null;function cu(h){var m=h.alternate;Q(qr,qr.current&1),Q(hs,h),Us===null&&(m===null||Bf.current!==null||m.memoizedState!==null)&&(Us=h)}function m2(h){Q(qr,qr.current),Q(hs,h),Us===null&&(Us=h)}function H4(h){h.tag===22?(Q(qr,qr.current),Q(hs,h),Us===null&&(Us=h)):uu()}function uu(){Q(qr,qr.current),Q(hs,hs.current)}function fs(h){G(hs),Us===h&&(Us=null),G(qr)}var qr=B(0);function Dy(h){for(var m=h;m!==null;){if(m.tag===13){var _=m.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||vT(_)||_T(_)))return m}else if(m.tag===19&&(m.memoizedProps.revealOrder==="forwards"||m.memoizedProps.revealOrder==="backwards"||m.memoizedProps.revealOrder==="unstable_legacy-backwards"||m.memoizedProps.revealOrder==="together")){if((m.flags&128)!==0)return m}else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return null;m=m.return}m.sibling.return=m.return,m=m.sibling}return null}var Hl=0,an=null,Kn=null,ni=null,Oy=!1,Hf=!1,Kd=!1,Ly=0,Vg=0,$f=null,zne=0;function Fr(){throw Error(r(321))}function p2(h,m){if(m===null)return!1;for(var _=0;_<m.length&&_<h.length;_++)if(!us(h[_],m[_]))return!1;return!0}function g2(h,m,_,S,P,D){return Hl=D,an=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,K.H=h===null||h.memoizedState===null?EI:P2,Kd=!1,D=_(S,P),Kd=!1,Hf&&(D=V4(m,_,S,P)),$4(h),D}function $4(h){K.H=qg;var m=Kn!==null&&Kn.next!==null;if(Hl=0,ni=Kn=an=null,Oy=!1,Vg=0,$f=null,m)throw Error(r(300));h===null||ri||(h=h.dependencies,h!==null&&Ty(h)&&(ri=!0))}function V4(h,m,_,S){an=h;var P=0;do{if(Hf&&($f=null),Vg=0,Hf=!1,25<=P)throw Error(r(301));if(P+=1,ni=Kn=null,h.updateQueue!=null){var D=h.updateQueue;D.lastEffect=null,D.events=null,D.stores=null,D.memoCache!=null&&(D.memoCache.index=0)}K.H=TI,D=m(_,S)}while(Hf);return D}function Bne(){var h=K.H,m=h.useState()[0];return m=typeof m.then=="function"?Gg(m):m,h=h.useState()[0],(Kn!==null?Kn.memoizedState:null)!==h&&(an.flags|=1024),m}function x2(){var h=Ly!==0;return Ly=0,h}function b2(h,m,_){m.updateQueue=h.updateQueue,m.flags&=-2053,h.lanes&=~_}function y2(h){if(Oy){for(h=h.memoizedState;h!==null;){var m=h.queue;m!==null&&(m.pending=null),h=h.next}Oy=!1}Hl=0,ni=Kn=an=null,Hf=!1,Vg=Ly=0,$f=null}function Ea(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ni===null?an.memoizedState=ni=h:ni=ni.next=h,ni}function Kr(){if(Kn===null){var h=an.alternate;h=h!==null?h.memoizedState:null}else h=Kn.next;var m=ni===null?an.memoizedState:ni.next;if(m!==null)ni=m,Kn=h;else{if(h===null)throw an.alternate===null?Error(r(467)):Error(r(310));Kn=h,h={memoizedState:Kn.memoizedState,baseState:Kn.baseState,baseQueue:Kn.baseQueue,queue:Kn.queue,next:null},ni===null?an.memoizedState=ni=h:ni=ni.next=h}return ni}function Iy(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Gg(h){var m=Vg;return Vg+=1,$f===null&&($f=[]),h=D4($f,h,m),m=an,(ni===null?m.memoizedState:ni.next)===null&&(m=m.alternate,K.H=m===null||m.memoizedState===null?EI:P2),h}function Fy(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Gg(h);if(h.$$typeof===w)return Ki(h)}throw Error(r(438,String(h)))}function v2(h){var m=null,_=an.updateQueue;if(_!==null&&(m=_.memoCache),m==null){var S=an.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(m={data:S.data.map(function(P){return P.slice()}),index:0})))}if(m==null&&(m={data:[],index:0}),_===null&&(_=Iy(),an.updateQueue=_),_.memoCache=m,_=m.data[m.index],_===void 0)for(_=m.data[m.index]=Array(h),S=0;S<h;S++)_[S]=R;return m.index++,_}function $l(h,m){return typeof m=="function"?m(h):m}function Uy(h){var m=Kr();return _2(m,Kn,h)}function _2(h,m,_){var S=h.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=_;var P=h.baseQueue,D=S.pending;if(D!==null){if(P!==null){var X=P.next;P.next=D.next,D.next=X}m.baseQueue=P=D,S.pending=null}if(D=h.baseState,P===null)h.memoizedState=D;else{m=P.next;var le=X=null,Ne=null,Je=m,ut=!1;do{var ft=Je.lane&-536870913;if(ft!==Je.lane?(wn&ft)===ft:(Hl&ft)===ft){var tt=Je.revertLane;if(tt===0)Ne!==null&&(Ne=Ne.next={lane:0,revertLane:0,gesture:null,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null}),ft===If&&(ut=!0);else if((Hl&tt)===tt){Je=Je.next,tt===If&&(ut=!0);continue}else ft={lane:0,revertLane:Je.revertLane,gesture:null,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null},Ne===null?(le=Ne=ft,X=D):Ne=Ne.next=ft,an.lanes|=tt,fu|=tt;ft=Je.action,Kd&&_(D,ft),D=Je.hasEagerState?Je.eagerState:_(D,ft)}else tt={lane:ft,revertLane:Je.revertLane,gesture:Je.gesture,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null},Ne===null?(le=Ne=tt,X=D):Ne=Ne.next=tt,an.lanes|=ft,fu|=ft;Je=Je.next}while(Je!==null&&Je!==m);if(Ne===null?X=D:Ne.next=le,!us(D,h.memoizedState)&&(ri=!0,ut&&(_=Ff,_!==null)))throw _;h.memoizedState=D,h.baseState=X,h.baseQueue=Ne,S.lastRenderedState=D}return P===null&&(S.lanes=0),[h.memoizedState,S.dispatch]}function w2(h){var m=Kr(),_=m.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var S=_.dispatch,P=_.pending,D=m.memoizedState;if(P!==null){_.pending=null;var X=P=P.next;do D=h(D,X.action),X=X.next;while(X!==P);us(D,m.memoizedState)||(ri=!0),m.memoizedState=D,m.baseQueue===null&&(m.baseState=D),_.lastRenderedState=D}return[D,S]}function G4(h,m,_){var S=an,P=Kr(),D=Tn;if(D){if(_===void 0)throw Error(r(407));_=_()}else _=m();var X=!us((Kn||P).memoizedState,_);if(X&&(P.memoizedState=_,ri=!0),P=P.queue,E2(K4.bind(null,S,P,h),[h]),P.getSnapshot!==m||X||ni!==null&&ni.memoizedState.tag&1){if(S.flags|=2048,Vf(9,{destroy:void 0},q4.bind(null,S,P,_,m),null),ar===null)throw Error(r(349));D||(Hl&127)!==0||W4(S,m,_)}return _}function W4(h,m,_){h.flags|=16384,h={getSnapshot:m,value:_},m=an.updateQueue,m===null?(m=Iy(),an.updateQueue=m,m.stores=[h]):(_=m.stores,_===null?m.stores=[h]:_.push(h))}function q4(h,m,_,S){m.value=_,m.getSnapshot=S,X4(m)&&Y4(h)}function K4(h,m,_){return _(function(){X4(m)&&Y4(h)})}function X4(h){var m=h.getSnapshot;h=h.value;try{var _=m();return!us(h,_)}catch{return!0}}function Y4(h){var m=Ud(h,2);m!==null&&Wa(m,h,2)}function S2(h){var m=Ea();if(typeof h=="function"){var _=h;if(h=_(),Kd){ze(!0);try{_()}finally{ze(!1)}}}return m.memoizedState=m.baseState=h,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:$l,lastRenderedState:h},m}function Z4(h,m,_,S){return h.baseState=_,_2(h,Kn,typeof S=="function"?S:$l)}function Hne(h,m,_,S,P){if(Hy(h))throw Error(r(485));if(h=m.action,h!==null){var D={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(X){D.listeners.push(X)}};K.T!==null?_(!0):D.isTransition=!1,S(D),_=m.pending,_===null?(D.next=m.pending=D,Q4(m,D)):(D.next=_.next,m.pending=_.next=D)}}function Q4(h,m){var _=m.action,S=m.payload,P=h.state;if(m.isTransition){var D=K.T,X={};K.T=X;try{var le=_(P,S),Ne=K.S;Ne!==null&&Ne(X,le),J4(h,m,le)}catch(Je){M2(h,m,Je)}finally{D!==null&&X.types!==null&&(D.types=X.types),K.T=D}}else try{D=_(P,S),J4(h,m,D)}catch(Je){M2(h,m,Je)}}function J4(h,m,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(S){eI(h,m,S)},function(S){return M2(h,m,S)}):eI(h,m,_)}function eI(h,m,_){m.status="fulfilled",m.value=_,tI(m),h.state=_,m=h.pending,m!==null&&(_=m.next,_===m?h.pending=null:(_=_.next,m.next=_,Q4(h,_)))}function M2(h,m,_){var S=h.pending;if(h.pending=null,S!==null){S=S.next;do m.status="rejected",m.reason=_,tI(m),m=m.next;while(m!==S)}h.action=null}function tI(h){h=h.listeners;for(var m=0;m<h.length;m++)(0,h[m])()}function nI(h,m){return m}function rI(h,m){if(Tn){var _=ar.formState;if(_!==null){e:{var S=an;if(Tn){if(hr){t:{for(var P=hr,D=Fs;P.nodeType!==8;){if(!D){P=null;break t}if(P=zs(P.nextSibling),P===null){P=null;break t}}D=P.data,P=D==="F!"||D==="F"?P:null}if(P){hr=zs(P.nextSibling),S=P.data==="F!";break e}}iu(S)}S=!1}S&&(m=_[0])}}return _=Ea(),_.memoizedState=_.baseState=m,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:nI,lastRenderedState:m},_.queue=S,_=wI.bind(null,an,S),S.dispatch=_,S=S2(!1),D=k2.bind(null,an,!1,S.queue),S=Ea(),P={state:m,dispatch:null,action:h,pending:null},S.queue=P,_=Hne.bind(null,an,P,D,_),P.dispatch=_,S.memoizedState=h,[m,_,!1]}function iI(h){var m=Kr();return aI(m,Kn,h)}function aI(h,m,_){if(m=_2(h,m,nI)[0],h=Uy($l)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var S=Gg(m)}catch(X){throw X===Uf?Cy:X}else S=m;m=Kr();var P=m.queue,D=P.dispatch;return _!==m.memoizedState&&(an.flags|=2048,Vf(9,{destroy:void 0},$ne.bind(null,P,_),null)),[S,D,h]}function $ne(h,m){h.action=m}function sI(h){var m=Kr(),_=Kn;if(_!==null)return aI(m,_,h);Kr(),m=m.memoizedState,_=Kr();var S=_.queue.dispatch;return _.memoizedState=h,[m,S,!1]}function Vf(h,m,_,S){return h={tag:h,create:_,deps:S,inst:m,next:null},m=an.updateQueue,m===null&&(m=Iy(),an.updateQueue=m),_=m.lastEffect,_===null?m.lastEffect=h.next=h:(S=_.next,_.next=h,h.next=S,m.lastEffect=h),h}function oI(){return Kr().memoizedState}function zy(h,m,_,S){var P=Ea();an.flags|=h,P.memoizedState=Vf(1|m,{destroy:void 0},_,S===void 0?null:S)}function By(h,m,_,S){var P=Kr();S=S===void 0?null:S;var D=P.memoizedState.inst;Kn!==null&&S!==null&&p2(S,Kn.memoizedState.deps)?P.memoizedState=Vf(m,D,_,S):(an.flags|=h,P.memoizedState=Vf(1|m,D,_,S))}function lI(h,m){zy(8390656,8,h,m)}function E2(h,m){By(2048,8,h,m)}function Vne(h){an.flags|=4;var m=an.updateQueue;if(m===null)m=Iy(),an.updateQueue=m,m.events=[h];else{var _=m.events;_===null?m.events=[h]:_.push(h)}}function cI(h){var m=Kr().memoizedState;return Vne({ref:m,nextImpl:h}),function(){if((Ln&2)!==0)throw Error(r(440));return m.impl.apply(void 0,arguments)}}function uI(h,m){return By(4,2,h,m)}function dI(h,m){return By(4,4,h,m)}function hI(h,m){if(typeof m=="function"){h=h();var _=m(h);return function(){typeof _=="function"?_():m(null)}}if(m!=null)return h=h(),m.current=h,function(){m.current=null}}function fI(h,m,_){_=_!=null?_.concat([h]):null,By(4,4,hI.bind(null,m,h),_)}function T2(){}function mI(h,m){var _=Kr();m=m===void 0?null:m;var S=_.memoizedState;return m!==null&&p2(m,S[1])?S[0]:(_.memoizedState=[h,m],h)}function pI(h,m){var _=Kr();m=m===void 0?null:m;var S=_.memoizedState;if(m!==null&&p2(m,S[1]))return S[0];if(S=h(),Kd){ze(!0);try{h()}finally{ze(!1)}}return _.memoizedState=[S,m],S}function A2(h,m,_){return _===void 0||(Hl&1073741824)!==0&&(wn&261930)===0?h.memoizedState=m:(h.memoizedState=_,h=g5(),an.lanes|=h,fu|=h,_)}function gI(h,m,_,S){return us(_,m)?_:Bf.current!==null?(h=A2(h,_,S),us(h,m)||(ri=!0),h):(Hl&42)===0||(Hl&1073741824)!==0&&(wn&261930)===0?(ri=!0,h.memoizedState=_):(h=g5(),an.lanes|=h,fu|=h,m)}function xI(h,m,_,S,P){var D=W.p;W.p=D!==0&&8>D?D:8;var X=K.T,le={};K.T=le,k2(h,!1,m,_);try{var Ne=P(),Je=K.S;if(Je!==null&&Je(le,Ne),Ne!==null&&typeof Ne=="object"&&typeof Ne.then=="function"){var ut=Une(Ne,S);Wg(h,m,ut,gs(h))}else Wg(h,m,S,gs(h))}catch(ft){Wg(h,m,{then:function(){},status:"rejected",reason:ft},gs())}finally{W.p=D,X!==null&&le.types!==null&&(X.types=le.types),K.T=X}}function Gne(){}function N2(h,m,_,S){if(h.tag!==5)throw Error(r(476));var P=bI(h).queue;xI(h,P,m,J,_===null?Gne:function(){return yI(h),_(S)})}function bI(h){var m=h.memoizedState;if(m!==null)return m;m={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$l,lastRenderedState:J},next:null};var _={};return m.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$l,lastRenderedState:_},next:null},h.memoizedState=m,h=h.alternate,h!==null&&(h.memoizedState=m),m}function yI(h){var m=bI(h);m.next===null&&(m=h.alternate.memoizedState),Wg(h,m.next.queue,{},gs())}function C2(){return Ki(cx)}function vI(){return Kr().memoizedState}function _I(){return Kr().memoizedState}function Wne(h){for(var m=h.return;m!==null;){switch(m.tag){case 24:case 3:var _=gs();h=ou(_);var S=lu(m,h,_);S!==null&&(Wa(S,m,_),Bg(S,m,_)),m={cache:i2()},h.payload=m;return}m=m.return}}function qne(h,m,_){var S=gs();_={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Hy(h)?SI(m,_):(_=qE(h,m,_,S),_!==null&&(Wa(_,h,S),MI(_,m,S)))}function wI(h,m,_){var S=gs();Wg(h,m,_,S)}function Wg(h,m,_,S){var P={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Hy(h))SI(m,P);else{var D=h.alternate;if(h.lanes===0&&(D===null||D.lanes===0)&&(D=m.lastRenderedReducer,D!==null))try{var X=m.lastRenderedState,le=D(X,_);if(P.hasEagerState=!0,P.eagerState=le,us(le,X))return wy(h,m,P,0),ar===null&&_y(),!1}catch{}finally{}if(_=qE(h,m,P,S),_!==null)return Wa(_,h,S),MI(_,m,S),!0}return!1}function k2(h,m,_,S){if(S={lane:2,revertLane:lT(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Hy(h)){if(m)throw Error(r(479))}else m=qE(h,_,S,2),m!==null&&Wa(m,h,2)}function Hy(h){var m=h.alternate;return h===an||m!==null&&m===an}function SI(h,m){Hf=Oy=!0;var _=h.pending;_===null?m.next=m:(m.next=_.next,_.next=m),h.pending=m}function MI(h,m,_){if((_&4194048)!==0){var S=m.lanes;S&=h.pendingLanes,_|=S,m.lanes=_,Nn(h,_)}}var qg={readContext:Ki,use:Fy,useCallback:Fr,useContext:Fr,useEffect:Fr,useImperativeHandle:Fr,useLayoutEffect:Fr,useInsertionEffect:Fr,useMemo:Fr,useReducer:Fr,useRef:Fr,useState:Fr,useDebugValue:Fr,useDeferredValue:Fr,useTransition:Fr,useSyncExternalStore:Fr,useId:Fr,useHostTransitionStatus:Fr,useFormState:Fr,useActionState:Fr,useOptimistic:Fr,useMemoCache:Fr,useCacheRefresh:Fr};qg.useEffectEvent=Fr;var EI={readContext:Ki,use:Fy,useCallback:function(h,m){return Ea().memoizedState=[h,m===void 0?null:m],h},useContext:Ki,useEffect:lI,useImperativeHandle:function(h,m,_){_=_!=null?_.concat([h]):null,zy(4194308,4,hI.bind(null,m,h),_)},useLayoutEffect:function(h,m){return zy(4194308,4,h,m)},useInsertionEffect:function(h,m){zy(4,2,h,m)},useMemo:function(h,m){var _=Ea();m=m===void 0?null:m;var S=h();if(Kd){ze(!0);try{h()}finally{ze(!1)}}return _.memoizedState=[S,m],S},useReducer:function(h,m,_){var S=Ea();if(_!==void 0){var P=_(m);if(Kd){ze(!0);try{_(m)}finally{ze(!1)}}}else P=m;return S.memoizedState=S.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},S.queue=h,h=h.dispatch=qne.bind(null,an,h),[S.memoizedState,h]},useRef:function(h){var m=Ea();return h={current:h},m.memoizedState=h},useState:function(h){h=S2(h);var m=h.queue,_=wI.bind(null,an,m);return m.dispatch=_,[h.memoizedState,_]},useDebugValue:T2,useDeferredValue:function(h,m){var _=Ea();return A2(_,h,m)},useTransition:function(){var h=S2(!1);return h=xI.bind(null,an,h.queue,!0,!1),Ea().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,m,_){var S=an,P=Ea();if(Tn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=m(),ar===null)throw Error(r(349));(wn&127)!==0||W4(S,m,_)}P.memoizedState=_;var D={value:_,getSnapshot:m};return P.queue=D,lI(K4.bind(null,S,D,h),[h]),S.flags|=2048,Vf(9,{destroy:void 0},q4.bind(null,S,D,_,m),null),_},useId:function(){var h=Ea(),m=ar.identifierPrefix;if(Tn){var _=Yo,S=Xo;_=(S&~(1<<32-Ue(S)-1)).toString(32)+_,m="_"+m+"R_"+_,_=Ly++,0<_&&(m+="H"+_.toString(32)),m+="_"}else _=zne++,m="_"+m+"r_"+_.toString(32)+"_";return h.memoizedState=m},useHostTransitionStatus:C2,useFormState:rI,useActionState:rI,useOptimistic:function(h){var m=Ea();m.memoizedState=m.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=_,m=k2.bind(null,an,!0,_),_.dispatch=m,[h,m]},useMemoCache:v2,useCacheRefresh:function(){return Ea().memoizedState=Wne.bind(null,an)},useEffectEvent:function(h){var m=Ea(),_={impl:h};return m.memoizedState=_,function(){if((Ln&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},P2={readContext:Ki,use:Fy,useCallback:mI,useContext:Ki,useEffect:E2,useImperativeHandle:fI,useInsertionEffect:uI,useLayoutEffect:dI,useMemo:pI,useReducer:Uy,useRef:oI,useState:function(){return Uy($l)},useDebugValue:T2,useDeferredValue:function(h,m){var _=Kr();return gI(_,Kn.memoizedState,h,m)},useTransition:function(){var h=Uy($l)[0],m=Kr().memoizedState;return[typeof h=="boolean"?h:Gg(h),m]},useSyncExternalStore:G4,useId:vI,useHostTransitionStatus:C2,useFormState:iI,useActionState:iI,useOptimistic:function(h,m){var _=Kr();return Z4(_,Kn,h,m)},useMemoCache:v2,useCacheRefresh:_I};P2.useEffectEvent=cI;var TI={readContext:Ki,use:Fy,useCallback:mI,useContext:Ki,useEffect:E2,useImperativeHandle:fI,useInsertionEffect:uI,useLayoutEffect:dI,useMemo:pI,useReducer:w2,useRef:oI,useState:function(){return w2($l)},useDebugValue:T2,useDeferredValue:function(h,m){var _=Kr();return Kn===null?A2(_,h,m):gI(_,Kn.memoizedState,h,m)},useTransition:function(){var h=w2($l)[0],m=Kr().memoizedState;return[typeof h=="boolean"?h:Gg(h),m]},useSyncExternalStore:G4,useId:vI,useHostTransitionStatus:C2,useFormState:sI,useActionState:sI,useOptimistic:function(h,m){var _=Kr();return Kn!==null?Z4(_,Kn,h,m):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:v2,useCacheRefresh:_I};TI.useEffectEvent=cI;function j2(h,m,_,S){m=h.memoizedState,_=_(S,m),_=_==null?m:f({},m,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var R2={enqueueSetState:function(h,m,_){h=h._reactInternals;var S=gs(),P=ou(S);P.payload=m,_!=null&&(P.callback=_),m=lu(h,P,S),m!==null&&(Wa(m,h,S),Bg(m,h,S))},enqueueReplaceState:function(h,m,_){h=h._reactInternals;var S=gs(),P=ou(S);P.tag=1,P.payload=m,_!=null&&(P.callback=_),m=lu(h,P,S),m!==null&&(Wa(m,h,S),Bg(m,h,S))},enqueueForceUpdate:function(h,m){h=h._reactInternals;var _=gs(),S=ou(_);S.tag=2,m!=null&&(S.callback=m),m=lu(h,S,_),m!==null&&(Wa(m,h,_),Bg(m,h,_))}};function AI(h,m,_,S,P,D,X){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(S,D,X):m.prototype&&m.prototype.isPureReactComponent?!Rg(_,S)||!Rg(P,D):!0}function NI(h,m,_,S){h=m.state,typeof m.componentWillReceiveProps=="function"&&m.componentWillReceiveProps(_,S),typeof m.UNSAFE_componentWillReceiveProps=="function"&&m.UNSAFE_componentWillReceiveProps(_,S),m.state!==h&&R2.enqueueReplaceState(m,m.state,null)}function Xd(h,m){var _=m;if("ref"in m){_={};for(var S in m)S!=="ref"&&(_[S]=m[S])}if(h=h.defaultProps){_===m&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function CI(h){vy(h)}function kI(h){console.error(h)}function PI(h){vy(h)}function $y(h,m){try{var _=h.onUncaughtError;_(m.value,{componentStack:m.stack})}catch(S){setTimeout(function(){throw S})}}function jI(h,m,_){try{var S=h.onCaughtError;S(_.value,{componentStack:_.stack,errorBoundary:m.tag===1?m.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function D2(h,m,_){return _=ou(_),_.tag=3,_.payload={element:null},_.callback=function(){$y(h,m)},_}function RI(h){return h=ou(h),h.tag=3,h}function DI(h,m,_,S){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var D=S.value;h.payload=function(){return P(D)},h.callback=function(){jI(m,_,S)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(h.callback=function(){jI(m,_,S),typeof P!="function"&&(mu===null?mu=new Set([this]):mu.add(this));var le=S.stack;this.componentDidCatch(S.value,{componentStack:le!==null?le:""})})}function Kne(h,m,_,S,P){if(_.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(m=_.alternate,m!==null&&Lf(m,_,P,!0),_=hs.current,_!==null){switch(_.tag){case 31:case 13:return Us===null?tv():_.alternate===null&&Ur===0&&(Ur=3),_.flags&=-257,_.flags|=65536,_.lanes=P,S===ky?_.flags|=16384:(m=_.updateQueue,m===null?_.updateQueue=new Set([S]):m.add(S),aT(h,S,P)),!1;case 22:return _.flags|=65536,S===ky?_.flags|=16384:(m=_.updateQueue,m===null?(m={transitions:null,markerInstances:null,retryQueue:new Set([S])},_.updateQueue=m):(_=m.retryQueue,_===null?m.retryQueue=new Set([S]):_.add(S)),aT(h,S,P)),!1}throw Error(r(435,_.tag))}return aT(h,S,P),tv(),!1}if(Tn)return m=hs.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=P,S!==JE&&(h=Error(r(422),{cause:S}),Lg(Os(h,_)))):(S!==JE&&(m=Error(r(423),{cause:S}),Lg(Os(m,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,S=Os(S,_),P=D2(h.stateNode,S,P),u2(h,P),Ur!==4&&(Ur=2)),!1;var D=Error(r(520),{cause:S});if(D=Os(D,_),tx===null?tx=[D]:tx.push(D),Ur!==4&&(Ur=2),m===null)return!0;S=Os(S,_),_=m;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=D2(_.stateNode,S,h),u2(_,h),!1;case 1:if(m=_.type,D=_.stateNode,(_.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(mu===null||!mu.has(D))))return _.flags|=65536,P&=-P,_.lanes|=P,P=RI(P),DI(P,h,_,S),u2(_,P),!1}_=_.return}while(_!==null);return!1}var O2=Error(r(461)),ri=!1;function Xi(h,m,_,S){m.child=h===null?F4(m,null,_,S):qd(m,h.child,_,S)}function OI(h,m,_,S,P){_=_.render;var D=m.ref;if("ref"in S){var X={};for(var le in S)le!=="ref"&&(X[le]=S[le])}else X=S;return $d(m),S=g2(h,m,_,X,D,P),le=x2(),h!==null&&!ri?(b2(h,m,P),Vl(h,m,P)):(Tn&&le&&ZE(m),m.flags|=1,Xi(h,m,S,P),m.child)}function LI(h,m,_,S,P){if(h===null){var D=_.type;return typeof D=="function"&&!KE(D)&&D.defaultProps===void 0&&_.compare===null?(m.tag=15,m.type=D,II(h,m,D,S,P)):(h=My(_.type,null,S,m,m.mode,P),h.ref=m.ref,h.return=m,m.child=h)}if(D=h.child,!$2(h,P)){var X=D.memoizedProps;if(_=_.compare,_=_!==null?_:Rg,_(X,S)&&h.ref===m.ref)return Vl(h,m,P)}return m.flags|=1,h=Fl(D,S),h.ref=m.ref,h.return=m,m.child=h}function II(h,m,_,S,P){if(h!==null){var D=h.memoizedProps;if(Rg(D,S)&&h.ref===m.ref)if(ri=!1,m.pendingProps=S=D,$2(h,P))(h.flags&131072)!==0&&(ri=!0);else return m.lanes=h.lanes,Vl(h,m,P)}return L2(h,m,_,S,P)}function FI(h,m,_,S){var P=S.children,D=h!==null?h.memoizedState:null;if(h===null&&m.stateNode===null&&(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((m.flags&128)!==0){if(D=D!==null?D.baseLanes|_:_,h!==null){for(S=m.child=h.child,P=0;S!==null;)P=P|S.lanes|S.childLanes,S=S.sibling;S=P&~D}else S=0,m.child=null;return UI(h,m,D,_,S)}if((_&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},h!==null&&Ny(m,D!==null?D.cachePool:null),D!==null?B4(m,D):h2(),H4(m);else return S=m.lanes=536870912,UI(h,m,D!==null?D.baseLanes|_:_,_,S)}else D!==null?(Ny(m,D.cachePool),B4(m,D),uu(),m.memoizedState=null):(h!==null&&Ny(m,null),h2(),uu());return Xi(h,m,P,_),m.child}function Kg(h,m){return h!==null&&h.tag===22||m.stateNode!==null||(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.sibling}function UI(h,m,_,S,P){var D=s2();return D=D===null?null:{parent:ti._currentValue,pool:D},m.memoizedState={baseLanes:_,cachePool:D},h!==null&&Ny(m,null),h2(),H4(m),h!==null&&Lf(h,m,S,!0),m.childLanes=P,null}function Vy(h,m){return m=Wy({mode:m.mode,children:m.children},h.mode),m.ref=h.ref,h.child=m,m.return=h,m}function zI(h,m,_){return qd(m,h.child,null,_),h=Vy(m,m.pendingProps),h.flags|=2,fs(m),m.memoizedState=null,h}function Xne(h,m,_){var S=m.pendingProps,P=(m.flags&128)!==0;if(m.flags&=-129,h===null){if(Tn){if(S.mode==="hidden")return h=Vy(m,S),m.lanes=536870912,Kg(null,h);if(m2(m),(h=hr)?(h=Q5(h,Fs),h=h!==null&&h.data==="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:nu!==null?{id:Xo,overflow:Yo}:null,retryLane:536870912,hydrationErrors:null},_=S4(h),_.return=m,m.child=_,qi=m,hr=null)):h=null,h===null)throw iu(m);return m.lanes=536870912,null}return Vy(m,S)}var D=h.memoizedState;if(D!==null){var X=D.dehydrated;if(m2(m),P)if(m.flags&256)m.flags&=-257,m=zI(h,m,_);else if(m.memoizedState!==null)m.child=h.child,m.flags|=128,m=null;else throw Error(r(558));else if(ri||Lf(h,m,_,!1),P=(_&h.childLanes)!==0,ri||P){if(S=ar,S!==null&&(X=Lr(S,_),X!==0&&X!==D.retryLane))throw D.retryLane=X,Ud(h,X),Wa(S,h,X),O2;tv(),m=zI(h,m,_)}else h=D.treeContext,hr=zs(X.nextSibling),qi=m,Tn=!0,ru=null,Fs=!1,h!==null&&T4(m,h),m=Vy(m,S),m.flags|=4096;return m}return h=Fl(h.child,{mode:S.mode,children:S.children}),h.ref=m.ref,m.child=h,h.return=m,h}function Gy(h,m){var _=m.ref;if(_===null)h!==null&&h.ref!==null&&(m.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(m.flags|=4194816)}}function L2(h,m,_,S,P){return $d(m),_=g2(h,m,_,S,void 0,P),S=x2(),h!==null&&!ri?(b2(h,m,P),Vl(h,m,P)):(Tn&&S&&ZE(m),m.flags|=1,Xi(h,m,_,P),m.child)}function BI(h,m,_,S,P,D){return $d(m),m.updateQueue=null,_=V4(m,S,_,P),$4(h),S=x2(),h!==null&&!ri?(b2(h,m,D),Vl(h,m,D)):(Tn&&S&&ZE(m),m.flags|=1,Xi(h,m,_,D),m.child)}function HI(h,m,_,S,P){if($d(m),m.stateNode===null){var D=jf,X=_.contextType;typeof X=="object"&&X!==null&&(D=Ki(X)),D=new _(S,D),m.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,D.updater=R2,m.stateNode=D,D._reactInternals=m,D=m.stateNode,D.props=S,D.state=m.memoizedState,D.refs={},l2(m),X=_.contextType,D.context=typeof X=="object"&&X!==null?Ki(X):jf,D.state=m.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(j2(m,_,X,S),D.state=m.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(X=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),X!==D.state&&R2.enqueueReplaceState(D,D.state,null),$g(m,S,D,P),Hg(),D.state=m.memoizedState),typeof D.componentDidMount=="function"&&(m.flags|=4194308),S=!0}else if(h===null){D=m.stateNode;var le=m.memoizedProps,Ne=Xd(_,le);D.props=Ne;var Je=D.context,ut=_.contextType;X=jf,typeof ut=="object"&&ut!==null&&(X=Ki(ut));var ft=_.getDerivedStateFromProps;ut=typeof ft=="function"||typeof D.getSnapshotBeforeUpdate=="function",le=m.pendingProps!==le,ut||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(le||Je!==X)&&NI(m,D,S,X),su=!1;var tt=m.memoizedState;D.state=tt,$g(m,S,D,P),Hg(),Je=m.memoizedState,le||tt!==Je||su?(typeof ft=="function"&&(j2(m,_,ft,S),Je=m.memoizedState),(Ne=su||AI(m,_,Ne,S,tt,Je,X))?(ut||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount()),typeof D.componentDidMount=="function"&&(m.flags|=4194308)):(typeof D.componentDidMount=="function"&&(m.flags|=4194308),m.memoizedProps=S,m.memoizedState=Je),D.props=S,D.state=Je,D.context=X,S=Ne):(typeof D.componentDidMount=="function"&&(m.flags|=4194308),S=!1)}else{D=m.stateNode,c2(h,m),X=m.memoizedProps,ut=Xd(_,X),D.props=ut,ft=m.pendingProps,tt=D.context,Je=_.contextType,Ne=jf,typeof Je=="object"&&Je!==null&&(Ne=Ki(Je)),le=_.getDerivedStateFromProps,(Je=typeof le=="function"||typeof D.getSnapshotBeforeUpdate=="function")||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(X!==ft||tt!==Ne)&&NI(m,D,S,Ne),su=!1,tt=m.memoizedState,D.state=tt,$g(m,S,D,P),Hg();var st=m.memoizedState;X!==ft||tt!==st||su||h!==null&&h.dependencies!==null&&Ty(h.dependencies)?(typeof le=="function"&&(j2(m,_,le,S),st=m.memoizedState),(ut=su||AI(m,_,ut,S,tt,st,Ne)||h!==null&&h.dependencies!==null&&Ty(h.dependencies))?(Je||typeof D.UNSAFE_componentWillUpdate!="function"&&typeof D.componentWillUpdate!="function"||(typeof D.componentWillUpdate=="function"&&D.componentWillUpdate(S,st,Ne),typeof D.UNSAFE_componentWillUpdate=="function"&&D.UNSAFE_componentWillUpdate(S,st,Ne)),typeof D.componentDidUpdate=="function"&&(m.flags|=4),typeof D.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof D.componentDidUpdate!="function"||X===h.memoizedProps&&tt===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&tt===h.memoizedState||(m.flags|=1024),m.memoizedProps=S,m.memoizedState=st),D.props=S,D.state=st,D.context=Ne,S=ut):(typeof D.componentDidUpdate!="function"||X===h.memoizedProps&&tt===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&tt===h.memoizedState||(m.flags|=1024),S=!1)}return D=S,Gy(h,m),S=(m.flags&128)!==0,D||S?(D=m.stateNode,_=S&&typeof _.getDerivedStateFromError!="function"?null:D.render(),m.flags|=1,h!==null&&S?(m.child=qd(m,h.child,null,P),m.child=qd(m,null,_,P)):Xi(h,m,_,P),m.memoizedState=D.state,h=m.child):h=Vl(h,m,P),h}function $I(h,m,_,S){return Bd(),m.flags|=256,Xi(h,m,_,S),m.child}var I2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function F2(h){return{baseLanes:h,cachePool:j4()}}function U2(h,m,_){return h=h!==null?h.childLanes&~_:0,m&&(h|=ps),h}function VI(h,m,_){var S=m.pendingProps,P=!1,D=(m.flags&128)!==0,X;if((X=D)||(X=h!==null&&h.memoizedState===null?!1:(qr.current&2)!==0),X&&(P=!0,m.flags&=-129),X=(m.flags&32)!==0,m.flags&=-33,h===null){if(Tn){if(P?cu(m):uu(),(h=hr)?(h=Q5(h,Fs),h=h!==null&&h.data!=="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:nu!==null?{id:Xo,overflow:Yo}:null,retryLane:536870912,hydrationErrors:null},_=S4(h),_.return=m,m.child=_,qi=m,hr=null)):h=null,h===null)throw iu(m);return _T(h)?m.lanes=32:m.lanes=536870912,null}var le=S.children;return S=S.fallback,P?(uu(),P=m.mode,le=Wy({mode:"hidden",children:le},P),S=zd(S,P,_,null),le.return=m,S.return=m,le.sibling=S,m.child=le,S=m.child,S.memoizedState=F2(_),S.childLanes=U2(h,X,_),m.memoizedState=I2,Kg(null,S)):(cu(m),z2(m,le))}var Ne=h.memoizedState;if(Ne!==null&&(le=Ne.dehydrated,le!==null)){if(D)m.flags&256?(cu(m),m.flags&=-257,m=B2(h,m,_)):m.memoizedState!==null?(uu(),m.child=h.child,m.flags|=128,m=null):(uu(),le=S.fallback,P=m.mode,S=Wy({mode:"visible",children:S.children},P),le=zd(le,P,_,null),le.flags|=2,S.return=m,le.return=m,S.sibling=le,m.child=S,qd(m,h.child,null,_),S=m.child,S.memoizedState=F2(_),S.childLanes=U2(h,X,_),m.memoizedState=I2,m=Kg(null,S));else if(cu(m),_T(le)){if(X=le.nextSibling&&le.nextSibling.dataset,X)var Je=X.dgst;X=Je,S=Error(r(419)),S.stack="",S.digest=X,Lg({value:S,source:null,stack:null}),m=B2(h,m,_)}else if(ri||Lf(h,m,_,!1),X=(_&h.childLanes)!==0,ri||X){if(X=ar,X!==null&&(S=Lr(X,_),S!==0&&S!==Ne.retryLane))throw Ne.retryLane=S,Ud(h,S),Wa(X,h,S),O2;vT(le)||tv(),m=B2(h,m,_)}else vT(le)?(m.flags|=192,m.child=h.child,m=null):(h=Ne.treeContext,hr=zs(le.nextSibling),qi=m,Tn=!0,ru=null,Fs=!1,h!==null&&T4(m,h),m=z2(m,S.children),m.flags|=4096);return m}return P?(uu(),le=S.fallback,P=m.mode,Ne=h.child,Je=Ne.sibling,S=Fl(Ne,{mode:"hidden",children:S.children}),S.subtreeFlags=Ne.subtreeFlags&65011712,Je!==null?le=Fl(Je,le):(le=zd(le,P,_,null),le.flags|=2),le.return=m,S.return=m,S.sibling=le,m.child=S,Kg(null,S),S=m.child,le=h.child.memoizedState,le===null?le=F2(_):(P=le.cachePool,P!==null?(Ne=ti._currentValue,P=P.parent!==Ne?{parent:Ne,pool:Ne}:P):P=j4(),le={baseLanes:le.baseLanes|_,cachePool:P}),S.memoizedState=le,S.childLanes=U2(h,X,_),m.memoizedState=I2,Kg(h.child,S)):(cu(m),_=h.child,h=_.sibling,_=Fl(_,{mode:"visible",children:S.children}),_.return=m,_.sibling=null,h!==null&&(X=m.deletions,X===null?(m.deletions=[h],m.flags|=16):X.push(h)),m.child=_,m.memoizedState=null,_)}function z2(h,m){return m=Wy({mode:"visible",children:m},h.mode),m.return=h,h.child=m}function Wy(h,m){return h=ds(22,h,null,m),h.lanes=0,h}function B2(h,m,_){return qd(m,h.child,null,_),h=z2(m,m.pendingProps.children),h.flags|=2,m.memoizedState=null,h}function GI(h,m,_){h.lanes|=m;var S=h.alternate;S!==null&&(S.lanes|=m),n2(h.return,m,_)}function H2(h,m,_,S,P,D){var X=h.memoizedState;X===null?h.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:S,tail:_,tailMode:P,treeForkCount:D}:(X.isBackwards=m,X.rendering=null,X.renderingStartTime=0,X.last=S,X.tail=_,X.tailMode=P,X.treeForkCount=D)}function WI(h,m,_){var S=m.pendingProps,P=S.revealOrder,D=S.tail;S=S.children;var X=qr.current,le=(X&2)!==0;if(le?(X=X&1|2,m.flags|=128):X&=1,Q(qr,X),Xi(h,m,S,_),S=Tn?Og:0,!le&&h!==null&&(h.flags&128)!==0)e:for(h=m.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&GI(h,_,m);else if(h.tag===19)GI(h,_,m);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===m)break e;for(;h.sibling===null;){if(h.return===null||h.return===m)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=m.child,P=null;_!==null;)h=_.alternate,h!==null&&Dy(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=m.child,m.child=null):(P=_.sibling,_.sibling=null),H2(m,!1,P,_,D,S);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=m.child,m.child=null;P!==null;){if(h=P.alternate,h!==null&&Dy(h)===null){m.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}H2(m,!0,_,null,D,S);break;case"together":H2(m,!1,null,null,void 0,S);break;default:m.memoizedState=null}return m.child}function Vl(h,m,_){if(h!==null&&(m.dependencies=h.dependencies),fu|=m.lanes,(_&m.childLanes)===0)if(h!==null){if(Lf(h,m,_,!1),(_&m.childLanes)===0)return null}else return null;if(h!==null&&m.child!==h.child)throw Error(r(153));if(m.child!==null){for(h=m.child,_=Fl(h,h.pendingProps),m.child=_,_.return=m;h.sibling!==null;)h=h.sibling,_=_.sibling=Fl(h,h.pendingProps),_.return=m;_.sibling=null}return m.child}function $2(h,m){return(h.lanes&m)!==0?!0:(h=h.dependencies,!!(h!==null&&Ty(h)))}function Yne(h,m,_){switch(m.tag){case 3:Te(m,m.stateNode.containerInfo),au(m,ti,h.memoizedState.cache),Bd();break;case 27:case 5:ce(m);break;case 4:Te(m,m.stateNode.containerInfo);break;case 10:au(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,m2(m),null;break;case 13:var S=m.memoizedState;if(S!==null)return S.dehydrated!==null?(cu(m),m.flags|=128,null):(_&m.child.childLanes)!==0?VI(h,m,_):(cu(m),h=Vl(h,m,_),h!==null?h.sibling:null);cu(m);break;case 19:var P=(h.flags&128)!==0;if(S=(_&m.childLanes)!==0,S||(Lf(h,m,_,!1),S=(_&m.childLanes)!==0),P){if(S)return WI(h,m,_);m.flags|=128}if(P=m.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),Q(qr,qr.current),S)break;return null;case 22:return m.lanes=0,FI(h,m,_,m.pendingProps);case 24:au(m,ti,h.memoizedState.cache)}return Vl(h,m,_)}function qI(h,m,_){if(h!==null)if(h.memoizedProps!==m.pendingProps)ri=!0;else{if(!$2(h,_)&&(m.flags&128)===0)return ri=!1,Yne(h,m,_);ri=(h.flags&131072)!==0}else ri=!1,Tn&&(m.flags&1048576)!==0&&E4(m,Og,m.index);switch(m.lanes=0,m.tag){case 16:e:{var S=m.pendingProps;if(h=Gd(m.elementType),m.type=h,typeof h=="function")KE(h)?(S=Xd(h,S),m.tag=1,m=HI(null,m,h,S,_)):(m.tag=0,m=L2(null,m,h,S,_));else{if(h!=null){var P=h.$$typeof;if(P===T){m.tag=11,m=OI(null,m,h,S,_);break e}else if(P===N){m.tag=14,m=LI(null,m,h,S,_);break e}}throw m=j(h)||h,Error(r(306,m,""))}}return m;case 0:return L2(h,m,m.type,m.pendingProps,_);case 1:return S=m.type,P=Xd(S,m.pendingProps),HI(h,m,S,P,_);case 3:e:{if(Te(m,m.stateNode.containerInfo),h===null)throw Error(r(387));S=m.pendingProps;var D=m.memoizedState;P=D.element,c2(h,m),$g(m,S,null,_);var X=m.memoizedState;if(S=X.cache,au(m,ti,S),S!==D.cache&&r2(m,[ti],_,!0),Hg(),S=X.element,D.isDehydrated)if(D={element:S,isDehydrated:!1,cache:X.cache},m.updateQueue.baseState=D,m.memoizedState=D,m.flags&256){m=$I(h,m,S,_);break e}else if(S!==P){P=Os(Error(r(424)),m),Lg(P),m=$I(h,m,S,_);break e}else{switch(h=m.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(hr=zs(h.firstChild),qi=m,Tn=!0,ru=null,Fs=!0,_=F4(m,null,S,_),m.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Bd(),S===P){m=Vl(h,m,_);break e}Xi(h,m,S,_)}m=m.child}return m;case 26:return Gy(h,m),h===null?(_=iF(m.type,null,m.pendingProps,null))?m.memoizedState=_:Tn||(_=m.type,h=m.pendingProps,S=lv(oe.current).createElement(_),S[rn]=m,S[Oe]=h,Yi(S,_,h),Le(S),m.stateNode=S):m.memoizedState=iF(m.type,h.memoizedProps,m.pendingProps,h.memoizedState),null;case 27:return ce(m),h===null&&Tn&&(S=m.stateNode=tF(m.type,m.pendingProps,oe.current),qi=m,Fs=!0,P=hr,bu(m.type)?(wT=P,hr=zs(S.firstChild)):hr=P),Xi(h,m,m.pendingProps.children,_),Gy(h,m),h===null&&(m.flags|=4194304),m.child;case 5:return h===null&&Tn&&((P=S=hr)&&(S=Tre(S,m.type,m.pendingProps,Fs),S!==null?(m.stateNode=S,qi=m,hr=zs(S.firstChild),Fs=!1,P=!0):P=!1),P||iu(m)),ce(m),P=m.type,D=m.pendingProps,X=h!==null?h.memoizedProps:null,S=D.children,xT(P,D)?S=null:X!==null&&xT(P,X)&&(m.flags|=32),m.memoizedState!==null&&(P=g2(h,m,Bne,null,null,_),cx._currentValue=P),Gy(h,m),Xi(h,m,S,_),m.child;case 6:return h===null&&Tn&&((h=_=hr)&&(_=Are(_,m.pendingProps,Fs),_!==null?(m.stateNode=_,qi=m,hr=null,h=!0):h=!1),h||iu(m)),null;case 13:return VI(h,m,_);case 4:return Te(m,m.stateNode.containerInfo),S=m.pendingProps,h===null?m.child=qd(m,null,S,_):Xi(h,m,S,_),m.child;case 11:return OI(h,m,m.type,m.pendingProps,_);case 7:return Xi(h,m,m.pendingProps,_),m.child;case 8:return Xi(h,m,m.pendingProps.children,_),m.child;case 12:return Xi(h,m,m.pendingProps.children,_),m.child;case 10:return S=m.pendingProps,au(m,m.type,S.value),Xi(h,m,S.children,_),m.child;case 9:return P=m.type._context,S=m.pendingProps.children,$d(m),P=Ki(P),S=S(P),m.flags|=1,Xi(h,m,S,_),m.child;case 14:return LI(h,m,m.type,m.pendingProps,_);case 15:return II(h,m,m.type,m.pendingProps,_);case 19:return WI(h,m,_);case 31:return Xne(h,m,_);case 22:return FI(h,m,_,m.pendingProps);case 24:return $d(m),S=Ki(ti),h===null?(P=s2(),P===null&&(P=ar,D=i2(),P.pooledCache=D,D.refCount++,D!==null&&(P.pooledCacheLanes|=_),P=D),m.memoizedState={parent:S,cache:P},l2(m),au(m,ti,P)):((h.lanes&_)!==0&&(c2(h,m),$g(m,null,null,_),Hg()),P=h.memoizedState,D=m.memoizedState,P.parent!==S?(P={parent:S,cache:S},m.memoizedState=P,m.lanes===0&&(m.memoizedState=m.updateQueue.baseState=P),au(m,ti,S)):(S=D.cache,au(m,ti,S),S!==P.cache&&r2(m,[ti],_,!0))),Xi(h,m,m.pendingProps.children,_),m.child;case 29:throw m.pendingProps}throw Error(r(156,m.tag))}function Gl(h){h.flags|=4}function V2(h,m,_,S,P){if((m=(h.mode&32)!==0)&&(m=!1),m){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(v5())h.flags|=8192;else throw Wd=ky,o2}else h.flags&=-16777217}function KI(h,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!cF(m))if(v5())h.flags|=8192;else throw Wd=ky,o2}function qy(h,m){m!==null&&(h.flags|=4),h.flags&16384&&(m=h.tag!==22?St():536870912,h.lanes|=m,Kf|=m)}function Xg(h,m){if(!Tn)switch(h.tailMode){case"hidden":m=h.tail;for(var _=null;m!==null;)m.alternate!==null&&(_=m),m=m.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var S=null;_!==null;)_.alternate!==null&&(S=_),_=_.sibling;S===null?m||h.tail===null?h.tail=null:h.tail.sibling=null:S.sibling=null}}function fr(h){var m=h.alternate!==null&&h.alternate.child===h.child,_=0,S=0;if(m)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags&65011712,S|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags,S|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=S,h.childLanes=_,m}function Zne(h,m,_){var S=m.pendingProps;switch(QE(m),m.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fr(m),null;case 1:return fr(m),null;case 3:return _=m.stateNode,S=null,h!==null&&(S=h.memoizedState.cache),m.memoizedState.cache!==S&&(m.flags|=2048),Bl(ti),me(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Of(m)?Gl(m):h===null||h.memoizedState.isDehydrated&&(m.flags&256)===0||(m.flags|=1024,e2())),fr(m),null;case 26:var P=m.type,D=m.memoizedState;return h===null?(Gl(m),D!==null?(fr(m),KI(m,D)):(fr(m),V2(m,P,null,S,_))):D?D!==h.memoizedState?(Gl(m),fr(m),KI(m,D)):(fr(m),m.flags&=-16777217):(h=h.memoizedProps,h!==S&&Gl(m),fr(m),V2(m,P,h,S,_)),null;case 27:if(Ce(m),_=oe.current,P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==S&&Gl(m);else{if(!S){if(m.stateNode===null)throw Error(r(166));return fr(m),null}h=te.current,Of(m)?A4(m):(h=tF(P,S,_),m.stateNode=h,Gl(m))}return fr(m),null;case 5:if(Ce(m),P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==S&&Gl(m);else{if(!S){if(m.stateNode===null)throw Error(r(166));return fr(m),null}if(D=te.current,Of(m))A4(m);else{var X=lv(oe.current);switch(D){case 1:D=X.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:D=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":D=X.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":D=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":D=X.createElement("div"),D.innerHTML="<script><\/script>",D=D.removeChild(D.firstChild);break;case"select":D=typeof S.is=="string"?X.createElement("select",{is:S.is}):X.createElement("select"),S.multiple?D.multiple=!0:S.size&&(D.size=S.size);break;default:D=typeof S.is=="string"?X.createElement(P,{is:S.is}):X.createElement(P)}}D[rn]=m,D[Oe]=S;e:for(X=m.child;X!==null;){if(X.tag===5||X.tag===6)D.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===m)break e;for(;X.sibling===null;){if(X.return===null||X.return===m)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}m.stateNode=D;e:switch(Yi(D,P,S),P){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&Gl(m)}}return fr(m),V2(m,m.type,h===null?null:h.memoizedProps,m.pendingProps,_),null;case 6:if(h&&m.stateNode!=null)h.memoizedProps!==S&&Gl(m);else{if(typeof S!="string"&&m.stateNode===null)throw Error(r(166));if(h=oe.current,Of(m)){if(h=m.stateNode,_=m.memoizedProps,S=null,P=qi,P!==null)switch(P.tag){case 27:case 5:S=P.memoizedProps}h[rn]=m,h=!!(h.nodeValue===_||S!==null&&S.suppressHydrationWarning===!0||V5(h.nodeValue,_)),h||iu(m,!0)}else h=lv(h).createTextNode(S),h[rn]=m,m.stateNode=h}return fr(m),null;case 31:if(_=m.memoizedState,h===null||h.memoizedState!==null){if(S=Of(m),_!==null){if(h===null){if(!S)throw Error(r(318));if(h=m.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[rn]=m}else Bd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;fr(m),h=!1}else _=e2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return m.flags&256?(fs(m),m):(fs(m),null);if((m.flags&128)!==0)throw Error(r(558))}return fr(m),null;case 13:if(S=m.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Of(m),S!==null&&S.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=m.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[rn]=m}else Bd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;fr(m),P=!1}else P=e2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return m.flags&256?(fs(m),m):(fs(m),null)}return fs(m),(m.flags&128)!==0?(m.lanes=_,m):(_=S!==null,h=h!==null&&h.memoizedState!==null,_&&(S=m.child,P=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(P=S.alternate.memoizedState.cachePool.pool),D=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(D=S.memoizedState.cachePool.pool),D!==P&&(S.flags|=2048)),_!==h&&_&&(m.child.flags|=8192),qy(m,m.updateQueue),fr(m),null);case 4:return me(),h===null&&hT(m.stateNode.containerInfo),fr(m),null;case 10:return Bl(m.type),fr(m),null;case 19:if(G(qr),S=m.memoizedState,S===null)return fr(m),null;if(P=(m.flags&128)!==0,D=S.rendering,D===null)if(P)Xg(S,!1);else{if(Ur!==0||h!==null&&(h.flags&128)!==0)for(h=m.child;h!==null;){if(D=Dy(h),D!==null){for(m.flags|=128,Xg(S,!1),h=D.updateQueue,m.updateQueue=h,qy(m,h),m.subtreeFlags=0,h=_,_=m.child;_!==null;)w4(_,h),_=_.sibling;return Q(qr,qr.current&1|2),Tn&&Ul(m,S.treeForkCount),m.child}h=h.sibling}S.tail!==null&&O()>Qy&&(m.flags|=128,P=!0,Xg(S,!1),m.lanes=4194304)}else{if(!P)if(h=Dy(D),h!==null){if(m.flags|=128,P=!0,h=h.updateQueue,m.updateQueue=h,qy(m,h),Xg(S,!0),S.tail===null&&S.tailMode==="hidden"&&!D.alternate&&!Tn)return fr(m),null}else 2*O()-S.renderingStartTime>Qy&&_!==536870912&&(m.flags|=128,P=!0,Xg(S,!1),m.lanes=4194304);S.isBackwards?(D.sibling=m.child,m.child=D):(h=S.last,h!==null?h.sibling=D:m.child=D,S.last=D)}return S.tail!==null?(h=S.tail,S.rendering=h,S.tail=h.sibling,S.renderingStartTime=O(),h.sibling=null,_=qr.current,Q(qr,P?_&1|2:_&1),Tn&&Ul(m,S.treeForkCount),h):(fr(m),null);case 22:case 23:return fs(m),f2(),S=m.memoizedState!==null,h!==null?h.memoizedState!==null!==S&&(m.flags|=8192):S&&(m.flags|=8192),S?(_&536870912)!==0&&(m.flags&128)===0&&(fr(m),m.subtreeFlags&6&&(m.flags|=8192)):fr(m),_=m.updateQueue,_!==null&&qy(m,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),S=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(S=m.memoizedState.cachePool.pool),S!==_&&(m.flags|=2048),h!==null&&G(Vd),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),Bl(ti),fr(m),null;case 25:return null;case 30:return null}throw Error(r(156,m.tag))}function Qne(h,m){switch(QE(m),m.tag){case 1:return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 3:return Bl(ti),me(),h=m.flags,(h&65536)!==0&&(h&128)===0?(m.flags=h&-65537|128,m):null;case 26:case 27:case 5:return Ce(m),null;case 31:if(m.memoizedState!==null){if(fs(m),m.alternate===null)throw Error(r(340));Bd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 13:if(fs(m),h=m.memoizedState,h!==null&&h.dehydrated!==null){if(m.alternate===null)throw Error(r(340));Bd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 19:return G(qr),null;case 4:return me(),null;case 10:return Bl(m.type),null;case 22:case 23:return fs(m),f2(),h!==null&&G(Vd),h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 24:return Bl(ti),null;case 25:return null;default:return null}}function XI(h,m){switch(QE(m),m.tag){case 3:Bl(ti),me();break;case 26:case 27:case 5:Ce(m);break;case 4:me();break;case 31:m.memoizedState!==null&&fs(m);break;case 13:fs(m);break;case 19:G(qr);break;case 10:Bl(m.type);break;case 22:case 23:fs(m),f2(),h!==null&&G(Vd);break;case 24:Bl(ti)}}function Yg(h,m){try{var _=m.updateQueue,S=_!==null?_.lastEffect:null;if(S!==null){var P=S.next;_=P;do{if((_.tag&h)===h){S=void 0;var D=_.create,X=_.inst;S=D(),X.destroy=S}_=_.next}while(_!==P)}}catch(le){Hn(m,m.return,le)}}function du(h,m,_){try{var S=m.updateQueue,P=S!==null?S.lastEffect:null;if(P!==null){var D=P.next;S=D;do{if((S.tag&h)===h){var X=S.inst,le=X.destroy;if(le!==void 0){X.destroy=void 0,P=m;var Ne=_,Je=le;try{Je()}catch(ut){Hn(P,Ne,ut)}}}S=S.next}while(S!==D)}}catch(ut){Hn(m,m.return,ut)}}function YI(h){var m=h.updateQueue;if(m!==null){var _=h.stateNode;try{z4(m,_)}catch(S){Hn(h,h.return,S)}}}function ZI(h,m,_){_.props=Xd(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(S){Hn(h,m,S)}}function Zg(h,m){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var S=h.stateNode;break;case 30:S=h.stateNode;break;default:S=h.stateNode}typeof _=="function"?h.refCleanup=_(S):_.current=S}}catch(P){Hn(h,m,P)}}function Zo(h,m){var _=h.ref,S=h.refCleanup;if(_!==null)if(typeof S=="function")try{S()}catch(P){Hn(h,m,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Hn(h,m,P)}else _.current=null}function QI(h){var m=h.type,_=h.memoizedProps,S=h.stateNode;try{e:switch(m){case"button":case"input":case"select":case"textarea":_.autoFocus&&S.focus();break e;case"img":_.src?S.src=_.src:_.srcSet&&(S.srcset=_.srcSet)}}catch(P){Hn(h,h.return,P)}}function G2(h,m,_){try{var S=h.stateNode;vre(S,h.type,_,m),S[Oe]=m}catch(P){Hn(h,h.return,P)}}function JI(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&bu(h.type)||h.tag===4}function W2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||JI(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&&bu(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 q2(h,m,_){var S=h.tag;if(S===5||S===6)h=h.stateNode,m?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,m):(m=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,m.appendChild(h),_=_._reactRootContainer,_!=null||m.onclick!==null||(m.onclick=Ll));else if(S!==4&&(S===27&&bu(h.type)&&(_=h.stateNode,m=null),h=h.child,h!==null))for(q2(h,m,_),h=h.sibling;h!==null;)q2(h,m,_),h=h.sibling}function Ky(h,m,_){var S=h.tag;if(S===5||S===6)h=h.stateNode,m?_.insertBefore(h,m):_.appendChild(h);else if(S!==4&&(S===27&&bu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Ky(h,m,_),h=h.sibling;h!==null;)Ky(h,m,_),h=h.sibling}function e5(h){var m=h.stateNode,_=h.memoizedProps;try{for(var S=h.type,P=m.attributes;P.length;)m.removeAttributeNode(P[0]);Yi(m,S,_),m[rn]=h,m[Oe]=_}catch(D){Hn(h,h.return,D)}}var Wl=!1,ii=!1,K2=!1,t5=typeof WeakSet=="function"?WeakSet:Set,ji=null;function Jne(h,m){if(h=h.containerInfo,pT=pv,h=f4(h),BE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var S=_.getSelection&&_.getSelection();if(S&&S.rangeCount!==0){_=S.anchorNode;var P=S.anchorOffset,D=S.focusNode;S=S.focusOffset;try{_.nodeType,D.nodeType}catch{_=null;break e}var X=0,le=-1,Ne=-1,Je=0,ut=0,ft=h,tt=null;t:for(;;){for(var st;ft!==_||P!==0&&ft.nodeType!==3||(le=X+P),ft!==D||S!==0&&ft.nodeType!==3||(Ne=X+S),ft.nodeType===3&&(X+=ft.nodeValue.length),(st=ft.firstChild)!==null;)tt=ft,ft=st;for(;;){if(ft===h)break t;if(tt===_&&++Je===P&&(le=X),tt===D&&++ut===S&&(Ne=X),(st=ft.nextSibling)!==null)break;ft=tt,tt=ft.parentNode}ft=st}_=le===-1||Ne===-1?null:{start:le,end:Ne}}else _=null}_=_||{start:0,end:0}}else _=null;for(gT={focusedElem:h,selectionRange:_},pv=!1,ji=m;ji!==null;)if(m=ji,h=m.child,(m.subtreeFlags&1028)!==0&&h!==null)h.return=m,ji=h;else for(;ji!==null;){switch(m=ji,D=m.alternate,h=m.flags,m.tag){case 0:if((h&4)!==0&&(h=m.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&D!==null){h=void 0,_=m,P=D.memoizedProps,D=D.memoizedState,S=_.stateNode;try{var Ot=Xd(_.type,P);h=S.getSnapshotBeforeUpdate(Ot,D),S.__reactInternalSnapshotBeforeUpdate=h}catch(Wt){Hn(_,_.return,Wt)}}break;case 3:if((h&1024)!==0){if(h=m.stateNode.containerInfo,_=h.nodeType,_===9)yT(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":yT(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=m.sibling,h!==null){h.return=m.return,ji=h;break}ji=m.return}}function n5(h,m,_){var S=_.flags;switch(_.tag){case 0:case 11:case 15:Kl(h,_),S&4&&Yg(5,_);break;case 1:if(Kl(h,_),S&4)if(h=_.stateNode,m===null)try{h.componentDidMount()}catch(X){Hn(_,_.return,X)}else{var P=Xd(_.type,m.memoizedProps);m=m.memoizedState;try{h.componentDidUpdate(P,m,h.__reactInternalSnapshotBeforeUpdate)}catch(X){Hn(_,_.return,X)}}S&64&&YI(_),S&512&&Zg(_,_.return);break;case 3:if(Kl(h,_),S&64&&(h=_.updateQueue,h!==null)){if(m=null,_.child!==null)switch(_.child.tag){case 27:case 5:m=_.child.stateNode;break;case 1:m=_.child.stateNode}try{z4(h,m)}catch(X){Hn(_,_.return,X)}}break;case 27:m===null&&S&4&&e5(_);case 26:case 5:Kl(h,_),m===null&&S&4&&QI(_),S&512&&Zg(_,_.return);break;case 12:Kl(h,_);break;case 31:Kl(h,_),S&4&&a5(h,_);break;case 13:Kl(h,_),S&4&&s5(h,_),S&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=lre.bind(null,_),Nre(h,_))));break;case 22:if(S=_.memoizedState!==null||Wl,!S){m=m!==null&&m.memoizedState!==null||ii,P=Wl;var D=ii;Wl=S,(ii=m)&&!D?Xl(h,_,(_.subtreeFlags&8772)!==0):Kl(h,_),Wl=P,ii=D}break;case 30:break;default:Kl(h,_)}}function r5(h){var m=h.alternate;m!==null&&(h.alternate=null,r5(m)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(m=h.stateNode,m!==null&&at(m)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var yr=null,Ha=!1;function ql(h,m,_){for(_=_.child;_!==null;)i5(h,m,_),_=_.sibling}function i5(h,m,_){if(ae&&typeof ae.onCommitFiberUnmount=="function")try{ae.onCommitFiberUnmount(de,_)}catch{}switch(_.tag){case 26:ii||Zo(_,m),ql(h,m,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:ii||Zo(_,m);var S=yr,P=Ha;bu(_.type)&&(yr=_.stateNode,Ha=!1),ql(h,m,_),sx(_.stateNode),yr=S,Ha=P;break;case 5:ii||Zo(_,m);case 6:if(S=yr,P=Ha,yr=null,ql(h,m,_),yr=S,Ha=P,yr!==null)if(Ha)try{(yr.nodeType===9?yr.body:yr.nodeName==="HTML"?yr.ownerDocument.body:yr).removeChild(_.stateNode)}catch(D){Hn(_,m,D)}else try{yr.removeChild(_.stateNode)}catch(D){Hn(_,m,D)}break;case 18:yr!==null&&(Ha?(h=yr,Y5(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),nm(h)):Y5(yr,_.stateNode));break;case 4:S=yr,P=Ha,yr=_.stateNode.containerInfo,Ha=!0,ql(h,m,_),yr=S,Ha=P;break;case 0:case 11:case 14:case 15:du(2,_,m),ii||du(4,_,m),ql(h,m,_);break;case 1:ii||(Zo(_,m),S=_.stateNode,typeof S.componentWillUnmount=="function"&&ZI(_,m,S)),ql(h,m,_);break;case 21:ql(h,m,_);break;case 22:ii=(S=ii)||_.memoizedState!==null,ql(h,m,_),ii=S;break;default:ql(h,m,_)}}function a5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{nm(h)}catch(_){Hn(m,m.return,_)}}}function s5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{nm(h)}catch(_){Hn(m,m.return,_)}}function ere(h){switch(h.tag){case 31:case 13:case 19:var m=h.stateNode;return m===null&&(m=h.stateNode=new t5),m;case 22:return h=h.stateNode,m=h._retryCache,m===null&&(m=h._retryCache=new t5),m;default:throw Error(r(435,h.tag))}}function Xy(h,m){var _=ere(h);m.forEach(function(S){if(!_.has(S)){_.add(S);var P=cre.bind(null,h,S);S.then(P,P)}})}function $a(h,m){var _=m.deletions;if(_!==null)for(var S=0;S<_.length;S++){var P=_[S],D=h,X=m,le=X;e:for(;le!==null;){switch(le.tag){case 27:if(bu(le.type)){yr=le.stateNode,Ha=!1;break e}break;case 5:yr=le.stateNode,Ha=!1;break e;case 3:case 4:yr=le.stateNode.containerInfo,Ha=!0;break e}le=le.return}if(yr===null)throw Error(r(160));i5(D,X,P),yr=null,Ha=!1,D=P.alternate,D!==null&&(D.return=null),P.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)o5(m,h),m=m.sibling}var wo=null;function o5(h,m){var _=h.alternate,S=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:$a(m,h),Va(h),S&4&&(du(3,h,h.return),Yg(3,h),du(5,h,h.return));break;case 1:$a(m,h),Va(h),S&512&&(ii||_===null||Zo(_,_.return)),S&64&&Wl&&(h=h.updateQueue,h!==null&&(S=h.callbacks,S!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?S:_.concat(S))));break;case 26:var P=wo;if($a(m,h),Va(h),S&512&&(ii||_===null||Zo(_,_.return)),S&4){var D=_!==null?_.memoizedState:null;if(S=h.memoizedState,_===null)if(S===null)if(h.stateNode===null){e:{S=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(S){case"title":D=P.getElementsByTagName("title")[0],(!D||D[Ke]||D[rn]||D.namespaceURI==="http://www.w3.org/2000/svg"||D.hasAttribute("itemprop"))&&(D=P.createElement(S),P.head.insertBefore(D,P.querySelector("head > title"))),Yi(D,S,_),D[rn]=h,Le(D),S=D;break e;case"link":var X=oF("link","href",P).get(S+(_.href||""));if(X){for(var le=0;le<X.length;le++)if(D=X[le],D.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&D.getAttribute("rel")===(_.rel==null?null:_.rel)&&D.getAttribute("title")===(_.title==null?null:_.title)&&D.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){X.splice(le,1);break t}}D=P.createElement(S),Yi(D,S,_),P.head.appendChild(D);break;case"meta":if(X=oF("meta","content",P).get(S+(_.content||""))){for(le=0;le<X.length;le++)if(D=X[le],D.getAttribute("content")===(_.content==null?null:""+_.content)&&D.getAttribute("name")===(_.name==null?null:_.name)&&D.getAttribute("property")===(_.property==null?null:_.property)&&D.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&D.getAttribute("charset")===(_.charSet==null?null:_.charSet)){X.splice(le,1);break t}}D=P.createElement(S),Yi(D,S,_),P.head.appendChild(D);break;default:throw Error(r(468,S))}D[rn]=h,Le(D),S=D}h.stateNode=S}else lF(P,h.type,h.stateNode);else h.stateNode=sF(P,S,h.memoizedProps);else D!==S?(D===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):D.count--,S===null?lF(P,h.type,h.stateNode):sF(P,S,h.memoizedProps)):S===null&&h.stateNode!==null&&G2(h,h.memoizedProps,_.memoizedProps)}break;case 27:$a(m,h),Va(h),S&512&&(ii||_===null||Zo(_,_.return)),_!==null&&S&4&&G2(h,h.memoizedProps,_.memoizedProps);break;case 5:if($a(m,h),Va(h),S&512&&(ii||_===null||Zo(_,_.return)),h.flags&32){P=h.stateNode;try{Ko(P,"")}catch(Ot){Hn(h,h.return,Ot)}}S&4&&h.stateNode!=null&&(P=h.memoizedProps,G2(h,P,_!==null?_.memoizedProps:P)),S&1024&&(K2=!0);break;case 6:if($a(m,h),Va(h),S&4){if(h.stateNode===null)throw Error(r(162));S=h.memoizedProps,_=h.stateNode;try{_.nodeValue=S}catch(Ot){Hn(h,h.return,Ot)}}break;case 3:if(dv=null,P=wo,wo=cv(m.containerInfo),$a(m,h),wo=P,Va(h),S&4&&_!==null&&_.memoizedState.isDehydrated)try{nm(m.containerInfo)}catch(Ot){Hn(h,h.return,Ot)}K2&&(K2=!1,l5(h));break;case 4:S=wo,wo=cv(h.stateNode.containerInfo),$a(m,h),Va(h),wo=S;break;case 12:$a(m,h),Va(h);break;case 31:$a(m,h),Va(h),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,Xy(h,S)));break;case 13:$a(m,h),Va(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Zy=O()),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,Xy(h,S)));break;case 22:P=h.memoizedState!==null;var Ne=_!==null&&_.memoizedState!==null,Je=Wl,ut=ii;if(Wl=Je||P,ii=ut||Ne,$a(m,h),ii=ut,Wl=Je,Va(h),S&8192)e:for(m=h.stateNode,m._visibility=P?m._visibility&-2:m._visibility|1,P&&(_===null||Ne||Wl||ii||Yd(h)),_=null,m=h;;){if(m.tag===5||m.tag===26){if(_===null){Ne=_=m;try{if(D=Ne.stateNode,P)X=D.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{le=Ne.stateNode;var ft=Ne.memoizedProps.style,tt=ft!=null&&ft.hasOwnProperty("display")?ft.display:null;le.style.display=tt==null||typeof tt=="boolean"?"":(""+tt).trim()}}catch(Ot){Hn(Ne,Ne.return,Ot)}}}else if(m.tag===6){if(_===null){Ne=m;try{Ne.stateNode.nodeValue=P?"":Ne.memoizedProps}catch(Ot){Hn(Ne,Ne.return,Ot)}}}else if(m.tag===18){if(_===null){Ne=m;try{var st=Ne.stateNode;P?Z5(st,!0):Z5(Ne.stateNode,!1)}catch(Ot){Hn(Ne,Ne.return,Ot)}}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===h)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break e;for(;m.sibling===null;){if(m.return===null||m.return===h)break e;_===m&&(_=null),m=m.return}_===m&&(_=null),m.sibling.return=m.return,m=m.sibling}S&4&&(S=h.updateQueue,S!==null&&(_=S.retryQueue,_!==null&&(S.retryQueue=null,Xy(h,_))));break;case 19:$a(m,h),Va(h),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,Xy(h,S)));break;case 30:break;case 21:break;default:$a(m,h),Va(h)}}function Va(h){var m=h.flags;if(m&2){try{for(var _,S=h.return;S!==null;){if(JI(S)){_=S;break}S=S.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,D=W2(h);Ky(h,D,P);break;case 5:var X=_.stateNode;_.flags&32&&(Ko(X,""),_.flags&=-33);var le=W2(h);Ky(h,le,X);break;case 3:case 4:var Ne=_.stateNode.containerInfo,Je=W2(h);q2(h,Je,Ne);break;default:throw Error(r(161))}}catch(ut){Hn(h,h.return,ut)}h.flags&=-3}m&4096&&(h.flags&=-4097)}function l5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var m=h;l5(m),m.tag===5&&m.flags&1024&&m.stateNode.reset(),h=h.sibling}}function Kl(h,m){if(m.subtreeFlags&8772)for(m=m.child;m!==null;)n5(h,m.alternate,m),m=m.sibling}function Yd(h){for(h=h.child;h!==null;){var m=h;switch(m.tag){case 0:case 11:case 14:case 15:du(4,m,m.return),Yd(m);break;case 1:Zo(m,m.return);var _=m.stateNode;typeof _.componentWillUnmount=="function"&&ZI(m,m.return,_),Yd(m);break;case 27:sx(m.stateNode);case 26:case 5:Zo(m,m.return),Yd(m);break;case 22:m.memoizedState===null&&Yd(m);break;case 30:Yd(m);break;default:Yd(m)}h=h.sibling}}function Xl(h,m,_){for(_=_&&(m.subtreeFlags&8772)!==0,m=m.child;m!==null;){var S=m.alternate,P=h,D=m,X=D.flags;switch(D.tag){case 0:case 11:case 15:Xl(P,D,_),Yg(4,D);break;case 1:if(Xl(P,D,_),S=D,P=S.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Je){Hn(S,S.return,Je)}if(S=D,P=S.updateQueue,P!==null){var le=S.stateNode;try{var Ne=P.shared.hiddenCallbacks;if(Ne!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ne.length;P++)U4(Ne[P],le)}catch(Je){Hn(S,S.return,Je)}}_&&X&64&&YI(D),Zg(D,D.return);break;case 27:e5(D);case 26:case 5:Xl(P,D,_),_&&S===null&&X&4&&QI(D),Zg(D,D.return);break;case 12:Xl(P,D,_);break;case 31:Xl(P,D,_),_&&X&4&&a5(P,D);break;case 13:Xl(P,D,_),_&&X&4&&s5(P,D);break;case 22:D.memoizedState===null&&Xl(P,D,_),Zg(D,D.return);break;case 30:break;default:Xl(P,D,_)}m=m.sibling}}function X2(h,m){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(h=m.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Ig(_))}function Y2(h,m){h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&Ig(h))}function So(h,m,_,S){if(m.subtreeFlags&10256)for(m=m.child;m!==null;)c5(h,m,_,S),m=m.sibling}function c5(h,m,_,S){var P=m.flags;switch(m.tag){case 0:case 11:case 15:So(h,m,_,S),P&2048&&Yg(9,m);break;case 1:So(h,m,_,S);break;case 3:So(h,m,_,S),P&2048&&(h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&Ig(h)));break;case 12:if(P&2048){So(h,m,_,S),h=m.stateNode;try{var D=m.memoizedProps,X=D.id,le=D.onPostCommit;typeof le=="function"&&le(X,m.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ne){Hn(m,m.return,Ne)}}else So(h,m,_,S);break;case 31:So(h,m,_,S);break;case 13:So(h,m,_,S);break;case 23:break;case 22:D=m.stateNode,X=m.alternate,m.memoizedState!==null?D._visibility&2?So(h,m,_,S):Qg(h,m):D._visibility&2?So(h,m,_,S):(D._visibility|=2,Gf(h,m,_,S,(m.subtreeFlags&10256)!==0||!1)),P&2048&&X2(X,m);break;case 24:So(h,m,_,S),P&2048&&Y2(m.alternate,m);break;default:So(h,m,_,S)}}function Gf(h,m,_,S,P){for(P=P&&((m.subtreeFlags&10256)!==0||!1),m=m.child;m!==null;){var D=h,X=m,le=_,Ne=S,Je=X.flags;switch(X.tag){case 0:case 11:case 15:Gf(D,X,le,Ne,P),Yg(8,X);break;case 23:break;case 22:var ut=X.stateNode;X.memoizedState!==null?ut._visibility&2?Gf(D,X,le,Ne,P):Qg(D,X):(ut._visibility|=2,Gf(D,X,le,Ne,P)),P&&Je&2048&&X2(X.alternate,X);break;case 24:Gf(D,X,le,Ne,P),P&&Je&2048&&Y2(X.alternate,X);break;default:Gf(D,X,le,Ne,P)}m=m.sibling}}function Qg(h,m){if(m.subtreeFlags&10256)for(m=m.child;m!==null;){var _=h,S=m,P=S.flags;switch(S.tag){case 22:Qg(_,S),P&2048&&X2(S.alternate,S);break;case 24:Qg(_,S),P&2048&&Y2(S.alternate,S);break;default:Qg(_,S)}m=m.sibling}}var Jg=8192;function Wf(h,m,_){if(h.subtreeFlags&Jg)for(h=h.child;h!==null;)u5(h,m,_),h=h.sibling}function u5(h,m,_){switch(h.tag){case 26:Wf(h,m,_),h.flags&Jg&&h.memoizedState!==null&&zre(_,wo,h.memoizedState,h.memoizedProps);break;case 5:Wf(h,m,_);break;case 3:case 4:var S=wo;wo=cv(h.stateNode.containerInfo),Wf(h,m,_),wo=S;break;case 22:h.memoizedState===null&&(S=h.alternate,S!==null&&S.memoizedState!==null?(S=Jg,Jg=16777216,Wf(h,m,_),Jg=S):Wf(h,m,_));break;default:Wf(h,m,_)}}function d5(h){var m=h.alternate;if(m!==null&&(h=m.child,h!==null)){m.child=null;do m=h.sibling,h.sibling=null,h=m;while(h!==null)}}function ex(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var S=m[_];ji=S,f5(S,h)}d5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)h5(h),h=h.sibling}function h5(h){switch(h.tag){case 0:case 11:case 15:ex(h),h.flags&2048&&du(9,h,h.return);break;case 3:ex(h);break;case 12:ex(h);break;case 22:var m=h.stateNode;h.memoizedState!==null&&m._visibility&2&&(h.return===null||h.return.tag!==13)?(m._visibility&=-3,Yy(h)):ex(h);break;default:ex(h)}}function Yy(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var S=m[_];ji=S,f5(S,h)}d5(h)}for(h=h.child;h!==null;){switch(m=h,m.tag){case 0:case 11:case 15:du(8,m,m.return),Yy(m);break;case 22:_=m.stateNode,_._visibility&2&&(_._visibility&=-3,Yy(m));break;default:Yy(m)}h=h.sibling}}function f5(h,m){for(;ji!==null;){var _=ji;switch(_.tag){case 0:case 11:case 15:du(8,_,m);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var S=_.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:Ig(_.memoizedState.cache)}if(S=_.child,S!==null)S.return=_,ji=S;else e:for(_=h;ji!==null;){S=ji;var P=S.sibling,D=S.return;if(r5(S),S===_){ji=null;break e}if(P!==null){P.return=D,ji=P;break e}ji=D}}}var tre={getCacheForType:function(h){var m=Ki(ti),_=m.data.get(h);return _===void 0&&(_=h(),m.data.set(h,_)),_},cacheSignal:function(){return Ki(ti).controller.signal}},nre=typeof WeakMap=="function"?WeakMap:Map,Ln=0,ar=null,xn=null,wn=0,Bn=0,ms=null,hu=!1,qf=!1,Z2=!1,Yl=0,Ur=0,fu=0,Zd=0,Q2=0,ps=0,Kf=0,tx=null,Ga=null,J2=!1,Zy=0,m5=0,Qy=1/0,Jy=null,mu=null,pi=0,pu=null,Xf=null,Zl=0,eT=0,tT=null,p5=null,nx=0,nT=null;function gs(){return(Ln&2)!==0&&wn!==0?wn&-wn:K.T!==null?lT():Tr()}function g5(){if(ps===0)if((wn&536870912)===0||Tn){var h=ve;ve<<=1,(ve&3932160)===0&&(ve=262144),ps=h}else ps=536870912;return h=hs.current,h!==null&&(h.flags|=32),ps}function Wa(h,m,_){(h===ar&&(Bn===2||Bn===9)||h.cancelPendingCommit!==null)&&(Yf(h,0),gu(h,wn,ps,!1)),qt(h,_),((Ln&2)===0||h!==ar)&&(h===ar&&((Ln&2)===0&&(Zd|=_),Ur===4&&gu(h,wn,ps,!1)),Qo(h))}function x5(h,m,_){if((Ln&6)!==0)throw Error(r(327));var S=!_&&(m&127)===0&&(m&h.expiredLanes)===0||Xe(h,m),P=S?are(h,m):iT(h,m,!0),D=S;do{if(P===0){qf&&!S&&gu(h,m,0,!1);break}else{if(_=h.current.alternate,D&&!rre(_)){P=iT(h,m,!1),D=!1;continue}if(P===2){if(D=m,h.errorRecoveryDisabledLanes&D)var X=0;else X=h.pendingLanes&-536870913,X=X!==0?X:X&536870912?536870912:0;if(X!==0){m=X;e:{var le=h;P=tx;var Ne=le.current.memoizedState.isDehydrated;if(Ne&&(Yf(le,X).flags|=256),X=iT(le,X,!1),X!==2){if(Z2&&!Ne){le.errorRecoveryDisabledLanes|=D,Zd|=D,P=4;break e}D=Ga,Ga=P,D!==null&&(Ga===null?Ga=D:Ga.push.apply(Ga,D))}P=X}if(D=!1,P!==2)continue}}if(P===1){Yf(h,0),gu(h,m,0,!0);break}e:{switch(S=h,D=P,D){case 0:case 1:throw Error(r(345));case 4:if((m&4194048)!==m)break;case 6:gu(S,m,ps,!hu);break e;case 2:Ga=null;break;case 3:case 5:break;default:throw Error(r(329))}if((m&62914560)===m&&(P=Zy+300-O(),10<P)){if(gu(S,m,ps,!hu),we(S,0,!0)!==0)break e;Zl=m,S.timeoutHandle=K5(b5.bind(null,S,_,Ga,Jy,J2,m,ps,Zd,Kf,hu,D,"Throttled",-0,0),P);break e}b5(S,_,Ga,Jy,J2,m,ps,Zd,Kf,hu,D,null,-0,0)}}break}while(!0);Qo(h)}function b5(h,m,_,S,P,D,X,le,Ne,Je,ut,ft,tt,st){if(h.timeoutHandle=-1,ft=m.subtreeFlags,ft&8192||(ft&16785408)===16785408){ft={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ll},u5(m,D,ft);var Ot=(D&62914560)===D?Zy-O():(D&4194048)===D?m5-O():0;if(Ot=Bre(ft,Ot),Ot!==null){Zl=D,h.cancelPendingCommit=Ot(T5.bind(null,h,m,D,_,S,P,X,le,Ne,ut,ft,null,tt,st)),gu(h,D,X,!Je);return}}T5(h,m,D,_,S,P,X,le,Ne)}function rre(h){for(var m=h;;){var _=m.tag;if((_===0||_===11||_===15)&&m.flags&16384&&(_=m.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var S=0;S<_.length;S++){var P=_[S],D=P.getSnapshot;P=P.value;try{if(!us(D(),P))return!1}catch{return!1}}if(_=m.child,m.subtreeFlags&16384&&_!==null)_.return=m,m=_;else{if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return!0;m=m.return}m.sibling.return=m.return,m=m.sibling}}return!0}function gu(h,m,_,S){m&=~Q2,m&=~Zd,h.suspendedLanes|=m,h.pingedLanes&=~m,S&&(h.warmLanes|=m),S=h.expirationTimes;for(var P=m;0<P;){var D=31-Ue(P),X=1<<D;S[D]=-1,P&=~X}_!==0&&kn(h,_,m)}function ev(){return(Ln&6)===0?(rx(0),!1):!0}function rT(){if(xn!==null){if(Bn===0)var h=xn.return;else h=xn,zl=Hd=null,y2(h),zf=null,Ug=0,h=xn;for(;h!==null;)XI(h.alternate,h),h=h.return;xn=null}}function Yf(h,m){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Sre(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Zl=0,rT(),ar=h,xn=_=Fl(h.current,null),wn=m,Bn=0,ms=null,hu=!1,qf=Xe(h,m),Z2=!1,Kf=ps=Q2=Zd=fu=Ur=0,Ga=tx=null,J2=!1,(m&8)!==0&&(m|=m&32);var S=h.entangledLanes;if(S!==0)for(h=h.entanglements,S&=m;0<S;){var P=31-Ue(S),D=1<<P;m|=h[P],S&=~D}return Yl=m,_y(),_}function y5(h,m){an=null,K.H=qg,m===Uf||m===Cy?(m=O4(),Bn=3):m===o2?(m=O4(),Bn=4):Bn=m===O2?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,ms=m,xn===null&&(Ur=1,$y(h,Os(m,h.current)))}function v5(){var h=hs.current;return h===null?!0:(wn&4194048)===wn?Us===null:(wn&62914560)===wn||(wn&536870912)!==0?h===Us:!1}function _5(){var h=K.H;return K.H=qg,h===null?qg:h}function w5(){var h=K.A;return K.A=tre,h}function tv(){Ur=4,hu||(wn&4194048)!==wn&&hs.current!==null||(qf=!0),(fu&134217727)===0&&(Zd&134217727)===0||ar===null||gu(ar,wn,ps,!1)}function iT(h,m,_){var S=Ln;Ln|=2;var P=_5(),D=w5();(ar!==h||wn!==m)&&(Jy=null,Yf(h,m)),m=!1;var X=Ur;e:do try{if(Bn!==0&&xn!==null){var le=xn,Ne=ms;switch(Bn){case 8:rT(),X=6;break e;case 3:case 2:case 9:case 6:hs.current===null&&(m=!0);var Je=Bn;if(Bn=0,ms=null,Zf(h,le,Ne,Je),_&&qf){X=0;break e}break;default:Je=Bn,Bn=0,ms=null,Zf(h,le,Ne,Je)}}ire(),X=Ur;break}catch(ut){y5(h,ut)}while(!0);return m&&h.shellSuspendCounter++,zl=Hd=null,Ln=S,K.H=P,K.A=D,xn===null&&(ar=null,wn=0,_y()),X}function ire(){for(;xn!==null;)S5(xn)}function are(h,m){var _=Ln;Ln|=2;var S=_5(),P=w5();ar!==h||wn!==m?(Jy=null,Qy=O()+500,Yf(h,m)):qf=Xe(h,m);e:do try{if(Bn!==0&&xn!==null){m=xn;var D=ms;t:switch(Bn){case 1:Bn=0,ms=null,Zf(h,m,D,1);break;case 2:case 9:if(R4(D)){Bn=0,ms=null,M5(m);break}m=function(){Bn!==2&&Bn!==9||ar!==h||(Bn=7),Qo(h)},D.then(m,m);break e;case 3:Bn=7;break e;case 4:Bn=5;break e;case 7:R4(D)?(Bn=0,ms=null,M5(m)):(Bn=0,ms=null,Zf(h,m,D,7));break;case 5:var X=null;switch(xn.tag){case 26:X=xn.memoizedState;case 5:case 27:var le=xn;if(X?cF(X):le.stateNode.complete){Bn=0,ms=null;var Ne=le.sibling;if(Ne!==null)xn=Ne;else{var Je=le.return;Je!==null?(xn=Je,nv(Je)):xn=null}break t}}Bn=0,ms=null,Zf(h,m,D,5);break;case 6:Bn=0,ms=null,Zf(h,m,D,6);break;case 8:rT(),Ur=6;break e;default:throw Error(r(462))}}sre();break}catch(ut){y5(h,ut)}while(!0);return zl=Hd=null,K.H=S,K.A=P,Ln=_,xn!==null?0:(ar=null,wn=0,_y(),Ur)}function sre(){for(;xn!==null&&!Me();)S5(xn)}function S5(h){var m=qI(h.alternate,h,Yl);h.memoizedProps=h.pendingProps,m===null?nv(h):xn=m}function M5(h){var m=h,_=m.alternate;switch(m.tag){case 15:case 0:m=BI(_,m,m.pendingProps,m.type,void 0,wn);break;case 11:m=BI(_,m,m.pendingProps,m.type.render,m.ref,wn);break;case 5:y2(m);default:XI(_,m),m=xn=w4(m,Yl),m=qI(_,m,Yl)}h.memoizedProps=h.pendingProps,m===null?nv(h):xn=m}function Zf(h,m,_,S){zl=Hd=null,y2(m),zf=null,Ug=0;var P=m.return;try{if(Kne(h,P,m,_,wn)){Ur=1,$y(h,Os(_,h.current)),xn=null;return}}catch(D){if(P!==null)throw xn=P,D;Ur=1,$y(h,Os(_,h.current)),xn=null;return}m.flags&32768?(Tn||S===1?h=!0:qf||(wn&536870912)!==0?h=!1:(hu=h=!0,(S===2||S===9||S===3||S===6)&&(S=hs.current,S!==null&&S.tag===13&&(S.flags|=16384))),E5(m,h)):nv(m)}function nv(h){var m=h;do{if((m.flags&32768)!==0){E5(m,hu);return}h=m.return;var _=Zne(m.alternate,m,Yl);if(_!==null){xn=_;return}if(m=m.sibling,m!==null){xn=m;return}xn=m=h}while(m!==null);Ur===0&&(Ur=5)}function E5(h,m){do{var _=Qne(h.alternate,h);if(_!==null){_.flags&=32767,xn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!m&&(h=h.sibling,h!==null)){xn=h;return}xn=h=_}while(h!==null);Ur=6,xn=null}function T5(h,m,_,S,P,D,X,le,Ne){h.cancelPendingCommit=null;do rv();while(pi!==0);if((Ln&6)!==0)throw Error(r(327));if(m!==null){if(m===h.current)throw Error(r(177));if(D=m.lanes|m.childLanes,D|=WE,Ft(h,_,D,X,le,Ne),h===ar&&(xn=ar=null,wn=0),Xf=m,pu=h,Zl=_,eT=D,tT=P,p5=S,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,ure(_e,function(){return P5(),null})):(h.callbackNode=null,h.callbackPriority=0),S=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||S){S=K.T,K.T=null,P=W.p,W.p=2,X=Ln,Ln|=4;try{Jne(h,m,_)}finally{Ln=X,W.p=P,K.T=S}}pi=1,A5(),N5(),C5()}}function A5(){if(pi===1){pi=0;var h=pu,m=Xf,_=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var S=W.p;W.p=2;var P=Ln;Ln|=4;try{o5(m,h);var D=gT,X=f4(h.containerInfo),le=D.focusedElem,Ne=D.selectionRange;if(X!==le&&le&&le.ownerDocument&&h4(le.ownerDocument.documentElement,le)){if(Ne!==null&&BE(le)){var Je=Ne.start,ut=Ne.end;if(ut===void 0&&(ut=Je),"selectionStart"in le)le.selectionStart=Je,le.selectionEnd=Math.min(ut,le.value.length);else{var ft=le.ownerDocument||document,tt=ft&&ft.defaultView||window;if(tt.getSelection){var st=tt.getSelection(),Ot=le.textContent.length,Wt=Math.min(Ne.start,Ot),Yn=Ne.end===void 0?Wt:Math.min(Ne.end,Ot);!st.extend&&Wt>Yn&&(X=Yn,Yn=Wt,Wt=X);var $e=d4(le,Wt),Re=d4(le,Yn);if($e&&Re&&(st.rangeCount!==1||st.anchorNode!==$e.node||st.anchorOffset!==$e.offset||st.focusNode!==Re.node||st.focusOffset!==Re.offset)){var Qe=ft.createRange();Qe.setStart($e.node,$e.offset),st.removeAllRanges(),Wt>Yn?(st.addRange(Qe),st.extend(Re.node,Re.offset)):(Qe.setEnd(Re.node,Re.offset),st.addRange(Qe))}}}}for(ft=[],st=le;st=st.parentNode;)st.nodeType===1&&ft.push({element:st,left:st.scrollLeft,top:st.scrollTop});for(typeof le.focus=="function"&&le.focus(),le=0;le<ft.length;le++){var ht=ft[le];ht.element.scrollLeft=ht.left,ht.element.scrollTop=ht.top}}pv=!!pT,gT=pT=null}finally{Ln=P,W.p=S,K.T=_}}h.current=m,pi=2}}function N5(){if(pi===2){pi=0;var h=pu,m=Xf,_=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var S=W.p;W.p=2;var P=Ln;Ln|=4;try{n5(h,m.alternate,m)}finally{Ln=P,W.p=S,K.T=_}}pi=3}}function C5(){if(pi===4||pi===3){pi=0,U();var h=pu,m=Xf,_=Zl,S=p5;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?pi=5:(pi=0,Xf=pu=null,k5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(mu=null),br(_),m=m.stateNode,ae&&typeof ae.onCommitFiberRoot=="function")try{ae.onCommitFiberRoot(de,m,void 0,(m.current.flags&128)===128)}catch{}if(S!==null){m=K.T,P=W.p,W.p=2,K.T=null;try{for(var D=h.onRecoverableError,X=0;X<S.length;X++){var le=S[X];D(le.value,{componentStack:le.stack})}}finally{K.T=m,W.p=P}}(Zl&3)!==0&&rv(),Qo(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===nT?nx++:(nx=0,nT=h):nx=0,rx(0)}}function k5(h,m){(h.pooledCacheLanes&=m)===0&&(m=h.pooledCache,m!=null&&(h.pooledCache=null,Ig(m)))}function rv(){return A5(),N5(),C5(),P5()}function P5(){if(pi!==5)return!1;var h=pu,m=eT;eT=0;var _=br(Zl),S=K.T,P=W.p;try{W.p=32>_?32:_,K.T=null,_=tT,tT=null;var D=pu,X=Zl;if(pi=0,Xf=pu=null,Zl=0,(Ln&6)!==0)throw Error(r(331));var le=Ln;if(Ln|=4,h5(D.current),c5(D,D.current,X,_),Ln=le,rx(0,!1),ae&&typeof ae.onPostCommitFiberRoot=="function")try{ae.onPostCommitFiberRoot(de,D)}catch{}return!0}finally{W.p=P,K.T=S,k5(h,m)}}function j5(h,m,_){m=Os(_,m),m=D2(h.stateNode,m,2),h=lu(h,m,2),h!==null&&(qt(h,2),Qo(h))}function Hn(h,m,_){if(h.tag===3)j5(h,h,_);else for(;m!==null;){if(m.tag===3){j5(m,h,_);break}else if(m.tag===1){var S=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(mu===null||!mu.has(S))){h=Os(_,h),_=RI(2),S=lu(m,_,2),S!==null&&(DI(_,S,m,h),qt(S,2),Qo(S));break}}m=m.return}}function aT(h,m,_){var S=h.pingCache;if(S===null){S=h.pingCache=new nre;var P=new Set;S.set(m,P)}else P=S.get(m),P===void 0&&(P=new Set,S.set(m,P));P.has(_)||(Z2=!0,P.add(_),h=ore.bind(null,h,m,_),m.then(h,h))}function ore(h,m,_){var S=h.pingCache;S!==null&&S.delete(m),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,ar===h&&(wn&_)===_&&(Ur===4||Ur===3&&(wn&62914560)===wn&&300>O()-Zy?(Ln&2)===0&&Yf(h,0):Q2|=_,Kf===wn&&(Kf=0)),Qo(h)}function R5(h,m){m===0&&(m=St()),h=Ud(h,m),h!==null&&(qt(h,m),Qo(h))}function lre(h){var m=h.memoizedState,_=0;m!==null&&(_=m.retryLane),R5(h,_)}function cre(h,m){var _=0;switch(h.tag){case 31:case 13:var S=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:S=h.stateNode;break;case 22:S=h.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(m),R5(h,_)}function ure(h,m){return ue(h,m)}var iv=null,Qf=null,sT=!1,av=!1,oT=!1,xu=0;function Qo(h){h!==Qf&&h.next===null&&(Qf===null?iv=Qf=h:Qf=Qf.next=h),av=!0,sT||(sT=!0,hre())}function rx(h,m){if(!oT&&av){oT=!0;do for(var _=!1,S=iv;S!==null;){if(h!==0){var P=S.pendingLanes;if(P===0)var D=0;else{var X=S.suspendedLanes,le=S.pingedLanes;D=(1<<31-Ue(42|h)+1)-1,D&=P&~(X&~le),D=D&201326741?D&201326741|1:D?D|2:0}D!==0&&(_=!0,I5(S,D))}else D=wn,D=we(S,S===ar?D:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(D&3)===0||Xe(S,D)||(_=!0,I5(S,D));S=S.next}while(_);oT=!1}}function dre(){D5()}function D5(){av=sT=!1;var h=0;xu!==0&&wre()&&(h=xu);for(var m=O(),_=null,S=iv;S!==null;){var P=S.next,D=O5(S,m);D===0?(S.next=null,_===null?iv=P:_.next=P,P===null&&(Qf=_)):(_=S,(h!==0||(D&3)!==0)&&(av=!0)),S=P}pi!==0&&pi!==5||rx(h),xu!==0&&(xu=0)}function O5(h,m){for(var _=h.suspendedLanes,S=h.pingedLanes,P=h.expirationTimes,D=h.pendingLanes&-62914561;0<D;){var X=31-Ue(D),le=1<<X,Ne=P[X];Ne===-1?((le&_)===0||(le&S)!==0)&&(P[X]=ot(le,m)):Ne<=m&&(h.expiredLanes|=le),D&=~le}if(m=ar,_=wn,_=we(h,h===m?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),S=h.callbackNode,_===0||h===m&&(Bn===2||Bn===9)||h.cancelPendingCommit!==null)return S!==null&&S!==null&&Ee(S),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Xe(h,_)){if(m=_&-_,m===h.callbackPriority)return m;switch(S!==null&&Ee(S),br(_)){case 2:case 8:_=ye;break;case 32:_=_e;break;case 268435456:_=Ve;break;default:_=_e}return S=L5.bind(null,h),_=ue(_,S),h.callbackPriority=m,h.callbackNode=_,m}return S!==null&&S!==null&&Ee(S),h.callbackPriority=2,h.callbackNode=null,2}function L5(h,m){if(pi!==0&&pi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(rv()&&h.callbackNode!==_)return null;var S=wn;return S=we(h,h===ar?S:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),S===0?null:(x5(h,S,m),O5(h,O()),h.callbackNode!=null&&h.callbackNode===_?L5.bind(null,h):null)}function I5(h,m){if(rv())return null;x5(h,m,!0)}function hre(){Mre(function(){(Ln&6)!==0?ue(be,dre):D5()})}function lT(){if(xu===0){var h=If;h===0&&(h=nt,nt<<=1,(nt&261888)===0&&(nt=256)),xu=h}return xu}function F5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:fy(""+h)}function U5(h,m){var _=m.ownerDocument.createElement("input");return _.name=m.name,_.value=m.value,h.id&&_.setAttribute("form",h.id),m.parentNode.insertBefore(_,m),h=new FormData(h),_.parentNode.removeChild(_),h}function fre(h,m,_,S,P){if(m==="submit"&&_&&_.stateNode===P){var D=F5((P[Oe]||null).action),X=S.submitter;X&&(m=(m=X[Oe]||null)?F5(m.formAction):X.getAttribute("formAction"),m!==null&&(D=m,X=null));var le=new xy("action","action",null,S,P);h.push({event:le,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(xu!==0){var Ne=X?U5(P,X):new FormData(P);N2(_,{pending:!0,data:Ne,method:P.method,action:D},null,Ne)}}else typeof D=="function"&&(le.preventDefault(),Ne=X?U5(P,X):new FormData(P),N2(_,{pending:!0,data:Ne,method:P.method,action:D},D,Ne))},currentTarget:P}]})}}for(var cT=0;cT<GE.length;cT++){var uT=GE[cT],mre=uT.toLowerCase(),pre=uT[0].toUpperCase()+uT.slice(1);_o(mre,"on"+pre)}_o(g4,"onAnimationEnd"),_o(x4,"onAnimationIteration"),_o(b4,"onAnimationStart"),_o("dblclick","onDoubleClick"),_o("focusin","onFocus"),_o("focusout","onBlur"),_o(Pne,"onTransitionRun"),_o(jne,"onTransitionStart"),_o(Rne,"onTransitionCancel"),_o(y4,"onTransitionEnd"),Mt("onMouseEnter",["mouseout","mouseover"]),Mt("onMouseLeave",["mouseout","mouseover"]),Mt("onPointerEnter",["pointerout","pointerover"]),Mt("onPointerLeave",["pointerout","pointerover"]),mt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),mt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),mt("onBeforeInput",["compositionend","keypress","textInput","paste"]),mt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),mt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),mt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ix="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(" "),gre=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ix));function z5(h,m){m=(m&4)!==0;for(var _=0;_<h.length;_++){var S=h[_],P=S.event;S=S.listeners;e:{var D=void 0;if(m)for(var X=S.length-1;0<=X;X--){var le=S[X],Ne=le.instance,Je=le.currentTarget;if(le=le.listener,Ne!==D&&P.isPropagationStopped())break e;D=le,P.currentTarget=Je;try{D(P)}catch(ut){vy(ut)}P.currentTarget=null,D=Ne}else for(X=0;X<S.length;X++){if(le=S[X],Ne=le.instance,Je=le.currentTarget,le=le.listener,Ne!==D&&P.isPropagationStopped())break e;D=le,P.currentTarget=Je;try{D(P)}catch(ut){vy(ut)}P.currentTarget=null,D=Ne}}}}function bn(h,m){var _=m[Gr];_===void 0&&(_=m[Gr]=new Set);var S=h+"__bubble";_.has(S)||(B5(m,h,2,!1),_.add(S))}function dT(h,m,_){var S=0;m&&(S|=4),B5(_,h,S,m)}var sv="_reactListening"+Math.random().toString(36).slice(2);function hT(h){if(!h[sv]){h[sv]=!0,Pe.forEach(function(_){_!=="selectionchange"&&(gre.has(_)||dT(_,!1,h),dT(_,!0,h))});var m=h.nodeType===9?h:h.ownerDocument;m===null||m[sv]||(m[sv]=!0,dT("selectionchange",!1,m))}}function B5(h,m,_,S){switch(gF(m)){case 2:var P=Vre;break;case 8:P=Gre;break;default:P=AT}_=P.bind(null,m,_,h),P=void 0,!jE||m!=="touchstart"&&m!=="touchmove"&&m!=="wheel"||(P=!0),S?P!==void 0?h.addEventListener(m,_,{capture:!0,passive:P}):h.addEventListener(m,_,!0):P!==void 0?h.addEventListener(m,_,{passive:P}):h.addEventListener(m,_,!1)}function fT(h,m,_,S,P){var D=S;if((m&1)===0&&(m&2)===0&&S!==null)e:for(;;){if(S===null)return;var X=S.tag;if(X===3||X===4){var le=S.stateNode.containerInfo;if(le===P)break;if(X===4)for(X=S.return;X!==null;){var Ne=X.tag;if((Ne===3||Ne===4)&&X.stateNode.containerInfo===P)return;X=X.return}for(;le!==null;){if(X=At(le),X===null)return;if(Ne=X.tag,Ne===5||Ne===6||Ne===26||Ne===27){S=D=X;continue e}le=le.parentNode}}S=S.return}WL(function(){var Je=D,ut=kE(_),ft=[];e:{var tt=v4.get(h);if(tt!==void 0){var st=xy,Ot=h;switch(h){case"keypress":if(py(_)===0)break e;case"keydown":case"keyup":st=cne;break;case"focusin":Ot="focus",st=LE;break;case"focusout":Ot="blur",st=LE;break;case"beforeblur":case"afterblur":st=LE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":st=XL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":st=Zte;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":st=hne;break;case g4:case x4:case b4:st=ene;break;case y4:st=mne;break;case"scroll":case"scrollend":st=Xte;break;case"wheel":st=gne;break;case"copy":case"cut":case"paste":st=nne;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":st=ZL;break;case"toggle":case"beforetoggle":st=bne}var Wt=(m&4)!==0,Yn=!Wt&&(h==="scroll"||h==="scrollend"),$e=Wt?tt!==null?tt+"Capture":null:tt;Wt=[];for(var Re=Je,Qe;Re!==null;){var ht=Re;if(Qe=ht.stateNode,ht=ht.tag,ht!==5&&ht!==26&&ht!==27||Qe===null||$e===null||(ht=Tg(Re,$e),ht!=null&&Wt.push(ax(Re,ht,Qe))),Yn)break;Re=Re.return}0<Wt.length&&(tt=new st(tt,Ot,null,_,ut),ft.push({event:tt,listeners:Wt}))}}if((m&7)===0){e:{if(tt=h==="mouseover"||h==="pointerover",st=h==="mouseout"||h==="pointerout",tt&&_!==CE&&(Ot=_.relatedTarget||_.fromElement)&&(At(Ot)||Ot[Jt]))break e;if((st||tt)&&(tt=ut.window===ut?ut:(tt=ut.ownerDocument)?tt.defaultView||tt.parentWindow:window,st?(Ot=_.relatedTarget||_.toElement,st=Je,Ot=Ot?At(Ot):null,Ot!==null&&(Yn=a(Ot),Wt=Ot.tag,Ot!==Yn||Wt!==5&&Wt!==27&&Wt!==6)&&(Ot=null)):(st=null,Ot=Je),st!==Ot)){if(Wt=XL,ht="onMouseLeave",$e="onMouseEnter",Re="mouse",(h==="pointerout"||h==="pointerover")&&(Wt=ZL,ht="onPointerLeave",$e="onPointerEnter",Re="pointer"),Yn=st==null?tt:Ae(st),Qe=Ot==null?tt:Ae(Ot),tt=new Wt(ht,Re+"leave",st,_,ut),tt.target=Yn,tt.relatedTarget=Qe,ht=null,At(ut)===Je&&(Wt=new Wt($e,Re+"enter",Ot,_,ut),Wt.target=Qe,Wt.relatedTarget=Yn,ht=Wt),Yn=ht,st&&Ot)t:{for(Wt=xre,$e=st,Re=Ot,Qe=0,ht=$e;ht;ht=Wt(ht))Qe++;ht=0;for(var Bt=Re;Bt;Bt=Wt(Bt))ht++;for(;0<Qe-ht;)$e=Wt($e),Qe--;for(;0<ht-Qe;)Re=Wt(Re),ht--;for(;Qe--;){if($e===Re||Re!==null&&$e===Re.alternate){Wt=$e;break t}$e=Wt($e),Re=Wt(Re)}Wt=null}else Wt=null;st!==null&&H5(ft,tt,st,Wt,!1),Ot!==null&&Yn!==null&&H5(ft,Yn,Ot,Wt,!0)}}e:{if(tt=Je?Ae(Je):window,st=tt.nodeName&&tt.nodeName.toLowerCase(),st==="select"||st==="input"&&tt.type==="file")var Pn=a4;else if(r4(tt))if(s4)Pn=Nne;else{Pn=Tne;var It=Ene}else st=tt.nodeName,!st||st.toLowerCase()!=="input"||tt.type!=="checkbox"&&tt.type!=="radio"?Je&&NE(Je.elementType)&&(Pn=a4):Pn=Ane;if(Pn&&(Pn=Pn(h,Je))){i4(ft,Pn,_,ut);break e}It&&It(h,tt,Je),h==="focusout"&&Je&&tt.type==="number"&&Je.memoizedProps.value!=null&&ki(tt,"number",tt.value)}switch(It=Je?Ae(Je):window,h){case"focusin":(r4(It)||It.contentEditable==="true")&&(Cf=It,HE=Je,Dg=null);break;case"focusout":Dg=HE=Cf=null;break;case"mousedown":$E=!0;break;case"contextmenu":case"mouseup":case"dragend":$E=!1,m4(ft,_,ut);break;case"selectionchange":if(kne)break;case"keydown":case"keyup":m4(ft,_,ut)}var sn;if(FE)e:{switch(h){case"compositionstart":var Sn="onCompositionStart";break e;case"compositionend":Sn="onCompositionEnd";break e;case"compositionupdate":Sn="onCompositionUpdate";break e}Sn=void 0}else Nf?t4(h,_)&&(Sn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Sn="onCompositionStart");Sn&&(QL&&_.locale!=="ko"&&(Nf||Sn!=="onCompositionStart"?Sn==="onCompositionEnd"&&Nf&&(sn=qL()):(tu=ut,RE="value"in tu?tu.value:tu.textContent,Nf=!0)),It=ov(Je,Sn),0<It.length&&(Sn=new YL(Sn,h,null,_,ut),ft.push({event:Sn,listeners:It}),sn?Sn.data=sn:(sn=n4(_),sn!==null&&(Sn.data=sn)))),(sn=vne?_ne(h,_):wne(h,_))&&(Sn=ov(Je,"onBeforeInput"),0<Sn.length&&(It=new YL("onBeforeInput","beforeinput",null,_,ut),ft.push({event:It,listeners:Sn}),It.data=sn)),fre(ft,h,Je,_,ut)}z5(ft,m)})}function ax(h,m,_){return{instance:h,listener:m,currentTarget:_}}function ov(h,m){for(var _=m+"Capture",S=[];h!==null;){var P=h,D=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||D===null||(P=Tg(h,_),P!=null&&S.unshift(ax(h,P,D)),P=Tg(h,m),P!=null&&S.push(ax(h,P,D))),h.tag===3)return S;h=h.return}return[]}function xre(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function H5(h,m,_,S,P){for(var D=m._reactName,X=[];_!==null&&_!==S;){var le=_,Ne=le.alternate,Je=le.stateNode;if(le=le.tag,Ne!==null&&Ne===S)break;le!==5&&le!==26&&le!==27||Je===null||(Ne=Je,P?(Je=Tg(_,D),Je!=null&&X.unshift(ax(_,Je,Ne))):P||(Je=Tg(_,D),Je!=null&&X.push(ax(_,Je,Ne)))),_=_.return}X.length!==0&&h.push({event:m,listeners:X})}var bre=/\r\n?/g,yre=/\u0000|\uFFFD/g;function $5(h){return(typeof h=="string"?h:""+h).replace(bre,`
- `).replace(yre,"")}function V5(h,m){return m=$5(m),$5(h)===m}function Xn(h,m,_,S,P,D){switch(_){case"children":typeof S=="string"?m==="body"||m==="textarea"&&S===""||Ko(h,S):(typeof S=="number"||typeof S=="bigint")&&m!=="body"&&Ko(h,""+S);break;case"className":zt(h,"class",S);break;case"tabIndex":zt(h,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":zt(h,_,S);break;case"style":VL(h,S,D);break;case"data":if(m!=="object"){zt(h,"data",S);break}case"src":case"href":if(S===""&&(m!=="a"||_!=="href")){h.removeAttribute(_);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){h.removeAttribute(_);break}S=fy(""+S),h.setAttribute(_,S);break;case"action":case"formAction":if(typeof S=="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 D=="function"&&(_==="formAction"?(m!=="input"&&Xn(h,m,"name",P.name,P,null),Xn(h,m,"formEncType",P.formEncType,P,null),Xn(h,m,"formMethod",P.formMethod,P,null),Xn(h,m,"formTarget",P.formTarget,P,null)):(Xn(h,m,"encType",P.encType,P,null),Xn(h,m,"method",P.method,P,null),Xn(h,m,"target",P.target,P,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){h.removeAttribute(_);break}S=fy(""+S),h.setAttribute(_,S);break;case"onClick":S!=null&&(h.onclick=Ll);break;case"onScroll":S!=null&&bn("scroll",h);break;case"onScrollEnd":S!=null&&bn("scrollend",h);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":h.muted=S&&typeof S!="function"&&typeof S!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(S==null||typeof S=="function"||typeof S=="boolean"||typeof S=="symbol"){h.removeAttribute("xlink:href");break}_=fy(""+S),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":S!=null&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,""+S):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":S&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":S===!0?h.setAttribute(_,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,S):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?h.setAttribute(_,S):h.removeAttribute(_);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?h.removeAttribute(_):h.setAttribute(_,S);break;case"popover":bn("beforetoggle",h),bn("toggle",h),Yt(h,"popover",S);break;case"xlinkActuate":on(h,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":on(h,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":on(h,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":on(h,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":on(h,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":on(h,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":on(h,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":on(h,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":on(h,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":Yt(h,"is",S);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=qte.get(_)||_,Yt(h,_,S))}}function mT(h,m,_,S,P,D){switch(_){case"style":VL(h,S,D);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof S=="string"?Ko(h,S):(typeof S=="number"||typeof S=="bigint")&&Ko(h,""+S);break;case"onScroll":S!=null&&bn("scroll",h);break;case"onScrollEnd":S!=null&&bn("scrollend",h);break;case"onClick":S!=null&&(h.onclick=Ll);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ct.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),m=_.slice(2,P?_.length-7:void 0),D=h[Oe]||null,D=D!=null?D[_]:null,typeof D=="function"&&h.removeEventListener(m,D,P),typeof S=="function")){typeof D!="function"&&D!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(m,S,P);break e}_ in h?h[_]=S:S===!0?h.setAttribute(_,""):Yt(h,_,S)}}}function Yi(h,m,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":bn("error",h),bn("load",h);var S=!1,P=!1,D;for(D in _)if(_.hasOwnProperty(D)){var X=_[D];if(X!=null)switch(D){case"src":S=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:Xn(h,m,D,X,_,null)}}P&&Xn(h,m,"srcSet",_.srcSet,_,null),S&&Xn(h,m,"src",_.src,_,null);return;case"input":bn("invalid",h);var le=D=X=P=null,Ne=null,Je=null;for(S in _)if(_.hasOwnProperty(S)){var ut=_[S];if(ut!=null)switch(S){case"name":P=ut;break;case"type":X=ut;break;case"checked":Ne=ut;break;case"defaultChecked":Je=ut;break;case"value":D=ut;break;case"defaultValue":le=ut;break;case"children":case"dangerouslySetInnerHTML":if(ut!=null)throw Error(r(137,m));break;default:Xn(h,m,S,ut,_,null)}}zn(h,D,le,Ne,Je,X,P,!1);return;case"select":bn("invalid",h),S=X=D=null;for(P in _)if(_.hasOwnProperty(P)&&(le=_[P],le!=null))switch(P){case"value":D=le;break;case"defaultValue":X=le;break;case"multiple":S=le;default:Xn(h,m,P,le,_,null)}m=D,_=X,h.multiple=!!S,m!=null?mi(h,!!S,m,!1):_!=null&&mi(h,!!S,_,!0);return;case"textarea":bn("invalid",h),D=P=S=null;for(X in _)if(_.hasOwnProperty(X)&&(le=_[X],le!=null))switch(X){case"value":S=le;break;case"defaultValue":P=le;break;case"children":D=le;break;case"dangerouslySetInnerHTML":if(le!=null)throw Error(r(91));break;default:Xn(h,m,X,le,_,null)}Wi(h,S,P,D);return;case"option":for(Ne in _)if(_.hasOwnProperty(Ne)&&(S=_[Ne],S!=null))switch(Ne){case"selected":h.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:Xn(h,m,Ne,S,_,null)}return;case"dialog":bn("beforetoggle",h),bn("toggle",h),bn("cancel",h),bn("close",h);break;case"iframe":case"object":bn("load",h);break;case"video":case"audio":for(S=0;S<ix.length;S++)bn(ix[S],h);break;case"image":bn("error",h),bn("load",h);break;case"details":bn("toggle",h);break;case"embed":case"source":case"link":bn("error",h),bn("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(Je in _)if(_.hasOwnProperty(Je)&&(S=_[Je],S!=null))switch(Je){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:Xn(h,m,Je,S,_,null)}return;default:if(NE(m)){for(ut in _)_.hasOwnProperty(ut)&&(S=_[ut],S!==void 0&&mT(h,m,ut,S,_,void 0));return}}for(le in _)_.hasOwnProperty(le)&&(S=_[le],S!=null&&Xn(h,m,le,S,_,null))}function vre(h,m,_,S){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,D=null,X=null,le=null,Ne=null,Je=null,ut=null;for(st in _){var ft=_[st];if(_.hasOwnProperty(st)&&ft!=null)switch(st){case"checked":break;case"value":break;case"defaultValue":Ne=ft;default:S.hasOwnProperty(st)||Xn(h,m,st,null,S,ft)}}for(var tt in S){var st=S[tt];if(ft=_[tt],S.hasOwnProperty(tt)&&(st!=null||ft!=null))switch(tt){case"type":D=st;break;case"name":P=st;break;case"checked":Je=st;break;case"defaultChecked":ut=st;break;case"value":X=st;break;case"defaultValue":le=st;break;case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,m));break;default:st!==ft&&Xn(h,m,tt,st,S,ft)}}vo(h,X,le,Ne,Je,ut,D,P);return;case"select":st=X=le=tt=null;for(D in _)if(Ne=_[D],_.hasOwnProperty(D)&&Ne!=null)switch(D){case"value":break;case"multiple":st=Ne;default:S.hasOwnProperty(D)||Xn(h,m,D,null,S,Ne)}for(P in S)if(D=S[P],Ne=_[P],S.hasOwnProperty(P)&&(D!=null||Ne!=null))switch(P){case"value":tt=D;break;case"defaultValue":le=D;break;case"multiple":X=D;default:D!==Ne&&Xn(h,m,P,D,S,Ne)}m=le,_=X,S=st,tt!=null?mi(h,!!_,tt,!1):!!S!=!!_&&(m!=null?mi(h,!!_,m,!0):mi(h,!!_,_?[]:"",!1));return;case"textarea":st=tt=null;for(le in _)if(P=_[le],_.hasOwnProperty(le)&&P!=null&&!S.hasOwnProperty(le))switch(le){case"value":break;case"children":break;default:Xn(h,m,le,null,S,P)}for(X in S)if(P=S[X],D=_[X],S.hasOwnProperty(X)&&(P!=null||D!=null))switch(X){case"value":tt=P;break;case"defaultValue":st=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==D&&Xn(h,m,X,P,S,D)}Pi(h,tt,st);return;case"option":for(var Ot in _)if(tt=_[Ot],_.hasOwnProperty(Ot)&&tt!=null&&!S.hasOwnProperty(Ot))switch(Ot){case"selected":h.selected=!1;break;default:Xn(h,m,Ot,null,S,tt)}for(Ne in S)if(tt=S[Ne],st=_[Ne],S.hasOwnProperty(Ne)&&tt!==st&&(tt!=null||st!=null))switch(Ne){case"selected":h.selected=tt&&typeof tt!="function"&&typeof tt!="symbol";break;default:Xn(h,m,Ne,tt,S,st)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Wt in _)tt=_[Wt],_.hasOwnProperty(Wt)&&tt!=null&&!S.hasOwnProperty(Wt)&&Xn(h,m,Wt,null,S,tt);for(Je in S)if(tt=S[Je],st=_[Je],S.hasOwnProperty(Je)&&tt!==st&&(tt!=null||st!=null))switch(Je){case"children":case"dangerouslySetInnerHTML":if(tt!=null)throw Error(r(137,m));break;default:Xn(h,m,Je,tt,S,st)}return;default:if(NE(m)){for(var Yn in _)tt=_[Yn],_.hasOwnProperty(Yn)&&tt!==void 0&&!S.hasOwnProperty(Yn)&&mT(h,m,Yn,void 0,S,tt);for(ut in S)tt=S[ut],st=_[ut],!S.hasOwnProperty(ut)||tt===st||tt===void 0&&st===void 0||mT(h,m,ut,tt,S,st);return}}for(var $e in _)tt=_[$e],_.hasOwnProperty($e)&&tt!=null&&!S.hasOwnProperty($e)&&Xn(h,m,$e,null,S,tt);for(ft in S)tt=S[ft],st=_[ft],!S.hasOwnProperty(ft)||tt===st||tt==null&&st==null||Xn(h,m,ft,tt,S,st)}function G5(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function _re(){if(typeof performance.getEntriesByType=="function"){for(var h=0,m=0,_=performance.getEntriesByType("resource"),S=0;S<_.length;S++){var P=_[S],D=P.transferSize,X=P.initiatorType,le=P.duration;if(D&&le&&G5(X)){for(X=0,le=P.responseEnd,S+=1;S<_.length;S++){var Ne=_[S],Je=Ne.startTime;if(Je>le)break;var ut=Ne.transferSize,ft=Ne.initiatorType;ut&&G5(ft)&&(Ne=Ne.responseEnd,X+=ut*(Ne<le?1:(le-Je)/(Ne-Je)))}if(--S,m+=8*(D+X)/(P.duration/1e3),h++,10<h)break}}if(0<h)return m/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var pT=null,gT=null;function lv(h){return h.nodeType===9?h:h.ownerDocument}function W5(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 q5(h,m){if(h===0)switch(m){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&m==="foreignObject"?0:h}function xT(h,m){return h==="textarea"||h==="noscript"||typeof m.children=="string"||typeof m.children=="number"||typeof m.children=="bigint"||typeof m.dangerouslySetInnerHTML=="object"&&m.dangerouslySetInnerHTML!==null&&m.dangerouslySetInnerHTML.__html!=null}var bT=null;function wre(){var h=window.event;return h&&h.type==="popstate"?h===bT?!1:(bT=h,!0):(bT=null,!1)}var K5=typeof setTimeout=="function"?setTimeout:void 0,Sre=typeof clearTimeout=="function"?clearTimeout:void 0,X5=typeof Promise=="function"?Promise:void 0,Mre=typeof queueMicrotask=="function"?queueMicrotask:typeof X5<"u"?function(h){return X5.resolve(null).then(h).catch(Ere)}:K5;function Ere(h){setTimeout(function(){throw h})}function bu(h){return h==="head"}function Y5(h,m){var _=m,S=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(S===0){h.removeChild(P),nm(m);return}S--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")S++;else if(_==="html")sx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,sx(_);for(var D=_.firstChild;D;){var X=D.nextSibling,le=D.nodeName;D[Ke]||le==="SCRIPT"||le==="STYLE"||le==="LINK"&&D.rel.toLowerCase()==="stylesheet"||_.removeChild(D),D=X}}else _==="body"&&sx(h.ownerDocument.body);_=P}while(_);nm(m)}function Z5(h,m){var _=h;h=0;do{var S=_.nextSibling;if(_.nodeType===1?m?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(m?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),S&&S.nodeType===8)if(_=S.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=S}while(_)}function yT(h){var m=h.firstChild;for(m&&m.nodeType===10&&(m=m.nextSibling);m;){var _=m;switch(m=m.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":yT(_),at(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Tre(h,m,_,S){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==m.toLowerCase()){if(!S&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(S){if(!h[Ke])switch(m){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(D=h.getAttribute("rel"),D==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(D!==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(D=h.getAttribute("src"),(D!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&D&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(m==="input"&&h.type==="hidden"){var D=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===D)return h}else return h;if(h=zs(h.nextSibling),h===null)break}return null}function Are(h,m,_){if(m==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=zs(h.nextSibling),h===null))return null;return h}function Q5(h,m){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!m||(h=zs(h.nextSibling),h===null))return null;return h}function vT(h){return h.data==="$?"||h.data==="$~"}function _T(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Nre(h,m){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=m;else if(h.data!=="$?"||_.readyState!=="loading")m();else{var S=function(){m(),_.removeEventListener("DOMContentLoaded",S)};_.addEventListener("DOMContentLoaded",S),h._reactRetry=S}}function zs(h){for(;h!=null;h=h.nextSibling){var m=h.nodeType;if(m===1||m===3)break;if(m===8){if(m=h.data,m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"||m==="F!"||m==="F")break;if(m==="/$"||m==="/&")return null}}return h}var wT=null;function J5(h){h=h.nextSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(m===0)return zs(h.nextSibling);m--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||m++}h=h.nextSibling}return null}function eF(h){h=h.previousSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(m===0)return h;m--}else _!=="/$"&&_!=="/&"||m++}h=h.previousSibling}return null}function tF(h,m,_){switch(m=lv(_),h){case"html":if(h=m.documentElement,!h)throw Error(r(452));return h;case"head":if(h=m.head,!h)throw Error(r(453));return h;case"body":if(h=m.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function sx(h){for(var m=h.attributes;m.length;)h.removeAttributeNode(m[0]);at(h)}var Bs=new Map,nF=new Set;function cv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Ql=W.d;W.d={f:Cre,r:kre,D:Pre,C:jre,L:Rre,m:Dre,X:Lre,S:Ore,M:Ire};function Cre(){var h=Ql.f(),m=ev();return h||m}function kre(h){var m=ie(h);m!==null&&m.tag===5&&m.type==="form"?yI(m):Ql.r(h)}var Jf=typeof document>"u"?null:document;function rF(h,m,_){var S=Jf;if(S&&typeof m=="string"&&m){var P=Fn(m);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),nF.has(P)||(nF.add(P),h={rel:h,crossOrigin:_,href:m},S.querySelector(P)===null&&(m=S.createElement("link"),Yi(m,"link",h),Le(m),S.head.appendChild(m)))}}function Pre(h){Ql.D(h),rF("dns-prefetch",h,null)}function jre(h,m){Ql.C(h,m),rF("preconnect",h,m)}function Rre(h,m,_){Ql.L(h,m,_);var S=Jf;if(S&&h&&m){var P='link[rel="preload"][as="'+Fn(m)+'"]';m==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Fn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Fn(_.imageSizes)+'"]')):P+='[href="'+Fn(h)+'"]';var D=P;switch(m){case"style":D=em(h);break;case"script":D=tm(h)}Bs.has(D)||(h=f({rel:"preload",href:m==="image"&&_&&_.imageSrcSet?void 0:h,as:m},_),Bs.set(D,h),S.querySelector(P)!==null||m==="style"&&S.querySelector(ox(D))||m==="script"&&S.querySelector(lx(D))||(m=S.createElement("link"),Yi(m,"link",h),Le(m),S.head.appendChild(m)))}}function Dre(h,m){Ql.m(h,m);var _=Jf;if(_&&h){var S=m&&typeof m.as=="string"?m.as:"script",P='link[rel="modulepreload"][as="'+Fn(S)+'"][href="'+Fn(h)+'"]',D=P;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":D=tm(h)}if(!Bs.has(D)&&(h=f({rel:"modulepreload",href:h},m),Bs.set(D,h),_.querySelector(P)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(lx(D)))return}S=_.createElement("link"),Yi(S,"link",h),Le(S),_.head.appendChild(S)}}}function Ore(h,m,_){Ql.S(h,m,_);var S=Jf;if(S&&h){var P=Fe(S).hoistableStyles,D=em(h);m=m||"default";var X=P.get(D);if(!X){var le={loading:0,preload:null};if(X=S.querySelector(ox(D)))le.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":m},_),(_=Bs.get(D))&&ST(h,_);var Ne=X=S.createElement("link");Le(Ne),Yi(Ne,"link",h),Ne._p=new Promise(function(Je,ut){Ne.onload=Je,Ne.onerror=ut}),Ne.addEventListener("load",function(){le.loading|=1}),Ne.addEventListener("error",function(){le.loading|=2}),le.loading|=4,uv(X,m,S)}X={type:"stylesheet",instance:X,count:1,state:le},P.set(D,X)}}}function Lre(h,m){Ql.X(h,m);var _=Jf;if(_&&h){var S=Fe(_).hoistableScripts,P=tm(h),D=S.get(P);D||(D=_.querySelector(lx(P)),D||(h=f({src:h,async:!0},m),(m=Bs.get(P))&&MT(h,m),D=_.createElement("script"),Le(D),Yi(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(P,D))}}function Ire(h,m){Ql.M(h,m);var _=Jf;if(_&&h){var S=Fe(_).hoistableScripts,P=tm(h),D=S.get(P);D||(D=_.querySelector(lx(P)),D||(h=f({src:h,async:!0,type:"module"},m),(m=Bs.get(P))&&MT(h,m),D=_.createElement("script"),Le(D),Yi(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(P,D))}}function iF(h,m,_,S){var P=(P=oe.current)?cv(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"?(m=em(_.href),_=Fe(P).hoistableStyles,S=_.get(m),S||(S={type:"style",instance:null,count:0,state:null},_.set(m,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=em(_.href);var D=Fe(P).hoistableStyles,X=D.get(h);if(X||(P=P.ownerDocument||P,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},D.set(h,X),(D=P.querySelector(ox(h)))&&!D._p&&(X.instance=D,X.state.loading=5),Bs.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Bs.set(h,_),D||Fre(P,h,_,X.state))),m&&S===null)throw Error(r(528,""));return X}if(m&&S!==null)throw Error(r(529,""));return null;case"script":return m=_.async,_=_.src,typeof _=="string"&&m&&typeof m!="function"&&typeof m!="symbol"?(m=tm(_),_=Fe(P).hoistableScripts,S=_.get(m),S||(S={type:"script",instance:null,count:0,state:null},_.set(m,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function em(h){return'href="'+Fn(h)+'"'}function ox(h){return'link[rel="stylesheet"]['+h+"]"}function aF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function Fre(h,m,_,S){h.querySelector('link[rel="preload"][as="style"]['+m+"]")?S.loading=1:(m=h.createElement("link"),S.preload=m,m.addEventListener("load",function(){return S.loading|=1}),m.addEventListener("error",function(){return S.loading|=2}),Yi(m,"link",_),Le(m),h.head.appendChild(m))}function tm(h){return'[src="'+Fn(h)+'"]'}function lx(h){return"script[async]"+h}function sF(h,m,_){if(m.count++,m.instance===null)switch(m.type){case"style":var S=h.querySelector('style[data-href~="'+Fn(_.href)+'"]');if(S)return m.instance=S,Le(S),S;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return S=(h.ownerDocument||h).createElement("style"),Le(S),Yi(S,"style",P),uv(S,_.precedence,h),m.instance=S;case"stylesheet":P=em(_.href);var D=h.querySelector(ox(P));if(D)return m.state.loading|=4,m.instance=D,Le(D),D;S=aF(_),(P=Bs.get(P))&&ST(S,P),D=(h.ownerDocument||h).createElement("link"),Le(D);var X=D;return X._p=new Promise(function(le,Ne){X.onload=le,X.onerror=Ne}),Yi(D,"link",S),m.state.loading|=4,uv(D,_.precedence,h),m.instance=D;case"script":return D=tm(_.src),(P=h.querySelector(lx(D)))?(m.instance=P,Le(P),P):(S=_,(P=Bs.get(D))&&(S=f({},_),MT(S,P)),h=h.ownerDocument||h,P=h.createElement("script"),Le(P),Yi(P,"link",S),h.head.appendChild(P),m.instance=P);case"void":return null;default:throw Error(r(443,m.type))}else m.type==="stylesheet"&&(m.state.loading&4)===0&&(S=m.instance,m.state.loading|=4,uv(S,_.precedence,h));return m.instance}function uv(h,m,_){for(var S=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=S.length?S[S.length-1]:null,D=P,X=0;X<S.length;X++){var le=S[X];if(le.dataset.precedence===m)D=le;else if(D!==P)break}D?D.parentNode.insertBefore(h,D.nextSibling):(m=_.nodeType===9?_.head:_,m.insertBefore(h,m.firstChild))}function ST(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.title==null&&(h.title=m.title)}function MT(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.integrity==null&&(h.integrity=m.integrity)}var dv=null;function oF(h,m,_){if(dv===null){var S=new Map,P=dv=new Map;P.set(_,S)}else P=dv,S=P.get(_),S||(S=new Map,P.set(_,S));if(S.has(h))return S;for(S.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var D=_[P];if(!(D[Ke]||D[rn]||h==="link"&&D.getAttribute("rel")==="stylesheet")&&D.namespaceURI!=="http://www.w3.org/2000/svg"){var X=D.getAttribute(m)||"";X=h+X;var le=S.get(X);le?le.push(D):S.set(X,[D])}}return S}function lF(h,m,_){h=h.ownerDocument||h,h.head.insertBefore(_,m==="title"?h.querySelector("head > title"):null)}function Ure(h,m,_){if(_===1||m.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof m.precedence!="string"||typeof m.href!="string"||m.href==="")break;return!0;case"link":if(typeof m.rel!="string"||typeof m.href!="string"||m.href===""||m.onLoad||m.onError)break;switch(m.rel){case"stylesheet":return h=m.disabled,typeof m.precedence=="string"&&h==null;default:return!0}case"script":if(m.async&&typeof m.async!="function"&&typeof m.async!="symbol"&&!m.onLoad&&!m.onError&&m.src&&typeof m.src=="string")return!0}return!1}function cF(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function zre(h,m,_,S){if(_.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=em(S.href),D=m.querySelector(ox(P));if(D){m=D._p,m!==null&&typeof m=="object"&&typeof m.then=="function"&&(h.count++,h=hv.bind(h),m.then(h,h)),_.state.loading|=4,_.instance=D,Le(D);return}D=m.ownerDocument||m,S=aF(S),(P=Bs.get(P))&&ST(S,P),D=D.createElement("link"),Le(D);var X=D;X._p=new Promise(function(le,Ne){X.onload=le,X.onerror=Ne}),Yi(D,"link",S),_.instance=D}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,m),(m=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=hv.bind(h),m.addEventListener("load",_),m.addEventListener("error",_))}}var ET=0;function Bre(h,m){return h.stylesheets&&h.count===0&&mv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var S=setTimeout(function(){if(h.stylesheets&&mv(h,h.stylesheets),h.unsuspend){var D=h.unsuspend;h.unsuspend=null,D()}},6e4+m);0<h.imgBytes&&ET===0&&(ET=62500*_re());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&mv(h,h.stylesheets),h.unsuspend)){var D=h.unsuspend;h.unsuspend=null,D()}},(h.imgBytes>ET?50:800)+m);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(S),clearTimeout(P)}}:null}function hv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)mv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var fv=null;function mv(h,m){h.stylesheets=null,h.unsuspend!==null&&(h.count++,fv=new Map,m.forEach(Hre,h),fv=null,hv.call(h))}function Hre(h,m){if(!(m.state.loading&4)){var _=fv.get(h);if(_)var S=_.get(null);else{_=new Map,fv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),D=0;D<P.length;D++){var X=P[D];(X.nodeName==="LINK"||X.getAttribute("media")!=="not all")&&(_.set(X.dataset.precedence,X),S=X)}S&&_.set(null,S)}P=m.instance,X=P.getAttribute("data-precedence"),D=_.get(X)||S,D===S&&_.set(null,P),_.set(X,P),this.count++,S=hv.bind(this),P.addEventListener("load",S),P.addEventListener("error",S),D?D.parentNode.insertBefore(P,D.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),m.state.loading|=4}}var cx={$$typeof:w,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function $re(h,m,_,S,P,D,X,le,Ne){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=Dt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dt(0),this.hiddenUpdates=Dt(null),this.identifierPrefix=S,this.onUncaughtError=P,this.onCaughtError=D,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ne,this.incompleteTransitions=new Map}function uF(h,m,_,S,P,D,X,le,Ne,Je,ut,ft){return h=new $re(h,m,_,X,Ne,Je,ut,ft,le),m=1,D===!0&&(m|=24),D=ds(3,null,null,m),h.current=D,D.stateNode=h,m=i2(),m.refCount++,h.pooledCache=m,m.refCount++,D.memoizedState={element:S,isDehydrated:_,cache:m},l2(D),h}function dF(h){return h?(h=jf,h):jf}function hF(h,m,_,S,P,D){P=dF(P),S.context===null?S.context=P:S.pendingContext=P,S=ou(m),S.payload={element:_},D=D===void 0?null:D,D!==null&&(S.callback=D),_=lu(h,S,m),_!==null&&(Wa(_,h,m),Bg(_,h,m))}function fF(h,m){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<m?_:m}}function TT(h,m){fF(h,m),(h=h.alternate)&&fF(h,m)}function mF(h){if(h.tag===13||h.tag===31){var m=Ud(h,67108864);m!==null&&Wa(m,h,67108864),TT(h,67108864)}}function pF(h){if(h.tag===13||h.tag===31){var m=gs();m=Er(m);var _=Ud(h,m);_!==null&&Wa(_,h,m),TT(h,m)}}var pv=!0;function Vre(h,m,_,S){var P=K.T;K.T=null;var D=W.p;try{W.p=2,AT(h,m,_,S)}finally{W.p=D,K.T=P}}function Gre(h,m,_,S){var P=K.T;K.T=null;var D=W.p;try{W.p=8,AT(h,m,_,S)}finally{W.p=D,K.T=P}}function AT(h,m,_,S){if(pv){var P=NT(S);if(P===null)fT(h,m,S,gv,_),xF(h,S);else if(qre(P,h,m,_,S))S.stopPropagation();else if(xF(h,S),m&4&&-1<Wre.indexOf(h)){for(;P!==null;){var D=ie(P);if(D!==null)switch(D.tag){case 3:if(D=D.stateNode,D.current.memoizedState.isDehydrated){var X=je(D.pendingLanes);if(X!==0){var le=D;for(le.pendingLanes|=2,le.entangledLanes|=2;X;){var Ne=1<<31-Ue(X);le.entanglements[1]|=Ne,X&=~Ne}Qo(D),(Ln&6)===0&&(Qy=O()+500,rx(0))}}break;case 31:case 13:le=Ud(D,2),le!==null&&Wa(le,D,2),ev(),TT(D,2)}if(D=NT(S),D===null&&fT(h,m,S,gv,_),D===P)break;P=D}P!==null&&S.stopPropagation()}else fT(h,m,S,null,_)}}function NT(h){return h=kE(h),CT(h)}var gv=null;function CT(h){if(gv=null,h=At(h),h!==null){var m=a(h);if(m===null)h=null;else{var _=m.tag;if(_===13){if(h=s(m),h!==null)return h;h=null}else if(_===31){if(h=l(m),h!==null)return h;h=null}else if(_===3){if(m.stateNode.current.memoizedState.isDehydrated)return m.tag===3?m.stateNode.containerInfo:null;h=null}else m!==h&&(h=null)}}return gv=h,null}function gF(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 be:return 2;case ye:return 8;case _e:case We:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var kT=!1,yu=null,vu=null,_u=null,ux=new Map,dx=new Map,wu=[],Wre="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 xF(h,m){switch(h){case"focusin":case"focusout":yu=null;break;case"dragenter":case"dragleave":vu=null;break;case"mouseover":case"mouseout":_u=null;break;case"pointerover":case"pointerout":ux.delete(m.pointerId);break;case"gotpointercapture":case"lostpointercapture":dx.delete(m.pointerId)}}function hx(h,m,_,S,P,D){return h===null||h.nativeEvent!==D?(h={blockedOn:m,domEventName:_,eventSystemFlags:S,nativeEvent:D,targetContainers:[P]},m!==null&&(m=ie(m),m!==null&&mF(m)),h):(h.eventSystemFlags|=S,m=h.targetContainers,P!==null&&m.indexOf(P)===-1&&m.push(P),h)}function qre(h,m,_,S,P){switch(m){case"focusin":return yu=hx(yu,h,m,_,S,P),!0;case"dragenter":return vu=hx(vu,h,m,_,S,P),!0;case"mouseover":return _u=hx(_u,h,m,_,S,P),!0;case"pointerover":var D=P.pointerId;return ux.set(D,hx(ux.get(D)||null,h,m,_,S,P)),!0;case"gotpointercapture":return D=P.pointerId,dx.set(D,hx(dx.get(D)||null,h,m,_,S,P)),!0}return!1}function bF(h){var m=At(h.target);if(m!==null){var _=a(m);if(_!==null){if(m=_.tag,m===13){if(m=s(_),m!==null){h.blockedOn=m,ei(h.priority,function(){pF(_)});return}}else if(m===31){if(m=l(_),m!==null){h.blockedOn=m,ei(h.priority,function(){pF(_)});return}}else if(m===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function xv(h){if(h.blockedOn!==null)return!1;for(var m=h.targetContainers;0<m.length;){var _=NT(h.nativeEvent);if(_===null){_=h.nativeEvent;var S=new _.constructor(_.type,_);CE=S,_.target.dispatchEvent(S),CE=null}else return m=ie(_),m!==null&&mF(m),h.blockedOn=_,!1;m.shift()}return!0}function yF(h,m,_){xv(h)&&_.delete(m)}function Kre(){kT=!1,yu!==null&&xv(yu)&&(yu=null),vu!==null&&xv(vu)&&(vu=null),_u!==null&&xv(_u)&&(_u=null),ux.forEach(yF),dx.forEach(yF)}function bv(h,m){h.blockedOn===m&&(h.blockedOn=null,kT||(kT=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Kre)))}var yv=null;function vF(h){yv!==h&&(yv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){yv===h&&(yv=null);for(var m=0;m<h.length;m+=3){var _=h[m],S=h[m+1],P=h[m+2];if(typeof S!="function"){if(CT(S||_)===null)continue;break}var D=ie(_);D!==null&&(h.splice(m,3),m-=3,N2(D,{pending:!0,data:P,method:_.method,action:S},S,P))}}))}function nm(h){function m(Ne){return bv(Ne,h)}yu!==null&&bv(yu,h),vu!==null&&bv(vu,h),_u!==null&&bv(_u,h),ux.forEach(m),dx.forEach(m);for(var _=0;_<wu.length;_++){var S=wu[_];S.blockedOn===h&&(S.blockedOn=null)}for(;0<wu.length&&(_=wu[0],_.blockedOn===null);)bF(_),_.blockedOn===null&&wu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(S=0;S<_.length;S+=3){var P=_[S],D=_[S+1],X=P[Oe]||null;if(typeof D=="function")X||vF(_);else if(X){var le=null;if(D&&D.hasAttribute("formAction")){if(P=D,X=D[Oe]||null)le=X.formAction;else if(CT(P)!==null)continue}else le=X.action;typeof le=="function"?_[S+1]=le:(_.splice(S,3),S-=3),vF(_)}}}function _F(){function h(D){D.canIntercept&&D.info==="react-transition"&&D.intercept({handler:function(){return new Promise(function(X){return P=X})},focusReset:"manual",scroll:"manual"})}function m(){P!==null&&(P(),P=null),S||setTimeout(_,20)}function _(){if(!S&&!navigation.transition){var D=navigation.currentEntry;D&&D.url!=null&&navigation.navigate(D.url,{state:D.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",m),navigation.addEventListener("navigateerror",m),setTimeout(_,100),function(){S=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",m),navigation.removeEventListener("navigateerror",m),P!==null&&(P(),P=null)}}}function PT(h){this._internalRoot=h}vv.prototype.render=PT.prototype.render=function(h){var m=this._internalRoot;if(m===null)throw Error(r(409));var _=m.current,S=gs();hF(_,S,h,m,null,null)},vv.prototype.unmount=PT.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var m=h.containerInfo;hF(h.current,2,null,h,null,null),ev(),m[Jt]=null}};function vv(h){this._internalRoot=h}vv.prototype.unstable_scheduleHydration=function(h){if(h){var m=Tr();h={blockedOn:null,target:h,priority:m};for(var _=0;_<wu.length&&m!==0&&m<wu[_].priority;_++);wu.splice(_,0,h),_===0&&bF(h)}};var wF=e.version;if(wF!=="19.2.0")throw Error(r(527,wF,"19.2.0"));W.findDOMNode=function(h){var m=h._reactInternals;if(m===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(m),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Xre={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var _v=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_v.isDisabled&&_v.supportsFiber)try{de=_v.inject(Xre),ae=_v}catch{}}return mx.createRoot=function(h,m){if(!i(h))throw Error(r(299));var _=!1,S="",P=CI,D=kI,X=PI;return m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(S=m.identifierPrefix),m.onUncaughtError!==void 0&&(P=m.onUncaughtError),m.onCaughtError!==void 0&&(D=m.onCaughtError),m.onRecoverableError!==void 0&&(X=m.onRecoverableError)),m=uF(h,1,!1,null,null,_,S,null,P,D,X,_F),h[Jt]=m.current,hT(h),new PT(m)},mx.hydrateRoot=function(h,m,_){if(!i(h))throw Error(r(299));var S=!1,P="",D=CI,X=kI,le=PI,Ne=null;return _!=null&&(_.unstable_strictMode===!0&&(S=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(D=_.onUncaughtError),_.onCaughtError!==void 0&&(X=_.onCaughtError),_.onRecoverableError!==void 0&&(le=_.onRecoverableError),_.formState!==void 0&&(Ne=_.formState)),m=uF(h,1,!0,m,_??null,S,P,Ne,D,X,le,_F),m.context=dF(null),_=m.current,S=gs(),S=Er(S),P=ou(S),P.callback=null,lu(_,P,S),_=S,m.current.lanes=_,qt(m,_),Qo(m),h[Jt]=m.current,hT(h),new vv(m)},mx.version="19.2.0",mx}var jF;function sie(){if(jF)return DT.exports;jF=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(),DT.exports=aie(),DT.exports}var oie=sie();const Kt=t=>typeof t=="string",px=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},RF=t=>t==null?"":""+t,lie=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},cie=/###/g,DF=t=>t&&t.indexOf("###")>-1?t.replace(cie,"."):t,OF=t=>!t||Kt(t),n0=(t,e,n)=>{const r=Kt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(OF(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 OF(t)?{}:{obj:t,k:DF(r[i])}},LF=(t,e,n)=>{const{obj:r,k:i}=n0(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),l=n0(t,s,Object);for(;l.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),l=n0(t,s,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},uie=(t,e,n,r)=>{const{obj:i,k:a}=n0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},j1=(t,e)=>{const{obj:n,k:r}=n0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},die=(t,e,n)=>{const r=j1(t,n);return r!==void 0?r:j1(e,n)},Y9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Kt(t[r])||t[r]instanceof String||Kt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):Y9(t[r],e[r],n):t[r]=e[r]);return t},rm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var hie={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const fie=t=>Kt(t)?t.replace(/[&<>"'\/]/g,e=>hie[e]):t;class mie{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 pie=[" ",",","?","!",";"],gie=new mie(20),xie=(t,e,n)=>{e=e||"",n=n||"";const r=pie.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=gie.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},Dk=(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,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],s=i[l],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},E0=t=>t?.replace("_","-"),bie={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 R1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||bie,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:(Kt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new R1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new R1(this.logger,e)}}var ul=new R1;let WS=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 IF extends WS{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 l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):Kt(r)&&a?l.push(...r.split(a)):l.push(r)));const c=j1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!s||!Kt(r)?c:Dk(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 l=[e,n];r&&(l=l.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),LF(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(Kt(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 l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=j1(this.data,l)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Y9(c,r,a):c={...c,...r},LF(this.data,l,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 Z9={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 Q9=Symbol("i18next/PATH_KEY");function yie(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===Q9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Ok(t,e){const{[Q9]:n}=t(yie());return n.join(e?.keySeparator??".")}const FF={},FT=t=>!Kt(t)&&typeof t!="boolean"&&typeof t!="number";class D1 extends WS{constructor(e,n={}){super(),lie(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ul.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=FT(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,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!xie(e,r,i);if(s&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:Kt(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:Kt(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=Ok(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:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let x=p?.res;const v=p?.usedKey||l,y=p?.exactUsedKey||l,b=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!Kt(i.count),A=D1.hasDefaultValue(i),C=T?this.pluralResolver.getSuffix(f,i.count,i):"",N=i.ordinal&&T?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",F=T&&!i.ordinal&&i.count===0,k=F&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${N}`]||i.defaultValue;let R=x;w&&!x&&A&&(R=k);const I=FT(R),L=Object.prototype.toString.apply(R);if(w&&R&&I&&b.indexOf(L)<0&&!(Kt(E)&&Array.isArray(R))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,R,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(p.res=q,p.usedParams=this.getUsedParamsDetails(i),p):q}if(s){const q=Array.isArray(R),j=q?[]:{},V=q?y:v;for(const K in R)if(Object.prototype.hasOwnProperty.call(R,K)){const W=`${V}${s}${K}`;A&&!x?j[K]=this.translate(W,{...i,defaultValue:FT(k)?k[K]:void 0,joinArrays:!1,ns:c}):j[K]=this.translate(W,{...i,joinArrays:!1,ns:c}),j[K]===W&&(j[K]=R[K])}x=j}}else if(w&&Kt(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,j=!1;!this.isValidLookup(x)&&A&&(q=!0,x=k),this.isValidLookup(x)||(j=!0,x=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:x,W=A&&k!==x&&this.options.updateMissing;if(j||q||W){if(this.logger.log(W?"updateKey":"missingKey",f,u,l,W?k:x),s){const B=this.resolve(l,{...i,keySeparator:!1});B&&B.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 J=[];const ee=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ee&&ee[0])for(let B=0;B<ee.length;B++)J.push(ee[B]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(i.lng||this.language):J.push(i.lng||this.language);const Z=(B,G,Q)=>{const te=A&&Q!==x?Q:K;this.options.missingKeyHandler?this.options.missingKeyHandler(B,u,G,te,W,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(B,u,G,te,W,i),this.emit("missingKey",B,u,G,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?J.forEach(B=>{const G=this.pluralResolver.getSuffixes(B,i);F&&i[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(Q=>{Z([B],l+Q,i[`defaultValue${Q}`]||k)})}):Z(J,l,k))}x=this.extendTranslation(x,e,i,p,r),j&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(j||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,q?x:void 0,i))}return a?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Kt(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&&!Kt(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,l=Kt(s)?[s]:s;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=Z9.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,s,l;return Kt(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&&!Kt(n.count),p=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(Kt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(y=>{this.isValidLookup(r)||(l=y,!FF[`${v[0]}-${y}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(FF[`${v[0]}-${y}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(b=>{if(this.isValidLookup(r))return;s=b;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,b,y,n);else{let T;g&&(T=this.pluralResolver.getSuffix(b,n.count,n));const A=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&T.indexOf(C)===0&&E.push(d+T.replace(C,this.options.pluralSeparator)),E.push(d+T),p&&E.push(d+A)),x){const N=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(N),g&&(n.ordinal&&T.indexOf(C)===0&&E.push(N+T.replace(C,this.options.pluralSeparator)),E.push(N+T),p&&E.push(N+A))}}let w;for(;w=E.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(b,y,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:s,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Kt(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 UF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ul.create("languageUtils")}getScriptPartFromCode(e){if(e=E0(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=E0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Kt(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)),Kt(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 Kt(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))):Kt(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const zF={zero:0,one:1,two:2,few:3,many:4,other:5},BF={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class vie{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=ul.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=E0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let 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)=>zF[i]-zF[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const HF=(t,e,n,r=".",i=!0)=>{let a=die(t,e,n);return!a&&i&&Kt(n)&&(a=Dk(t,n,r),a===void 0&&(a=Dk(e,n,r))),a},UT=t=>t.replace(/\$/g,"$$$$");class _ie{constructor(e={}){this.logger=ul.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:s,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:v,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:fie,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?rm(a):s||"{{",this.suffix=l?rm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?rm(g):p||rm("$t("),this.nestingSuffix=x?rm(x):v||rm(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=E!==void 0?E:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,s,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const b=HF(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(b,void 0,r,{...i,...n,interpolationkey:p}):b}const x=p.split(this.formatSeparator),v=x.shift().trim(),y=x.join(this.formatSeparator).trim();return this.format(HF(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>UT(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?UT(this.escape(p)):UT(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const x=a[1].trim();if(s=u(x),s===void 0)if(typeof d=="function"){const y=d(e,a,i);s=Kt(y)?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),s="";else!Kt(s)&&!this.useRawValueToEscape&&(s=RF(s));const v=p.safeValue(s);if(e=e.replace(a[0],v),f?(p.regex.lastIndex+=s.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,s;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;c=f[0],g=this.interpolate(g,s);const p=g.match(/'/g),x=g.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{s=JSON.parse(g),u&&(s={...u,...s})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${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&&!Kt(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(l.call(this,i[1].trim(),s),s),a&&i[0]===e&&!Kt(a))return a;Kt(a)||(a=RF(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const wie=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(s=>{if(s){const[l,...c]=s.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},$F=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 l=e[s];return l||(l=t(E0(r),i),e[s]=l),l(n)}},Sie=t=>(e,n,r)=>t(E0(n),r)(e);class Mie{constructor(e={}){this.logger=ul.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?$F:Sie;this.formats={number:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a});return l=>s.format(l)}),currency:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>s.format(l)}),datetime:r((i,a)=>{const s=new Intl.DateTimeFormat(i,{...a});return l=>s.format(l)}),relativetime:r((i,a)=>{const s=new Intl.RelativeTimeFormat(i,{...a});return l=>s.format(l,a.range||"day")}),list:r((i,a)=>{const s=new Intl.ListFormat(i,{...a});return l=>s.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=$F(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=wie(c);if(this.formats[u]){let f=l;try{const g=i?.formatParams?.[i.interpolationkey]||{},p=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const Eie=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Tie extends WS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=ul.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},s={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?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||(l[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(l),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 l={};this.queue.forEach(c=>{uie(c.loaded,[a],s),Eie(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,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 l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,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=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Kt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Kt(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,l)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,s),!s&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,s,l)})}saveMissing(e,n,r,i,a,s={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...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=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const VF=()=>({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]),Kt(t[1])&&(e.defaultValue=t[1]),Kt(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}),GF=t=>(Kt(t.ns)&&(t.ns=[t.ns]),Kt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Kt(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),Sv=()=>{},Aie=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class r0 extends WS{constructor(e={},n){if(super(),this.options=GF(e),this.services={},this.logger=ul,this.modules={external:[]},Aie(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&&(Kt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=VF();this.options={...r,...this.options,...GF(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?ul.init(i(this.modules.logger),this.options):ul.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Mie;const d=new UF(this.options);this.store=new IF(this.options.resources,this.options);const f=this.services;f.logger=ul,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new vie(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new _ie(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Tie(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new D1(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Sv),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const l=px(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=Sv){let r=n;const i=Kt(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=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).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?.(l=>s(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=px();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=Sv),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"&&Z9.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=px();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},s=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=Kt(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Kt(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?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,...l)=>{let c;typeof s!="object"?c=this.options.overloadTranslationOptionHandler([a,s].concat(l)):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=Ok(f,{...this.options,...s})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Ok(a,{...this.options,...s})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return Kt(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=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,s);if(l!==void 0)return l}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=px();return this.options.ns?(Kt(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=px();Kt(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 UF(VF());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 r0(e,n);return r.createInstance=r0.createInstance,r}cloneInstance(e={},n=Sv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new r0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new IF(l,i),a.services.resourceStore=a.store}return a.translator=new D1(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const za=r0.createInstance();za.createInstance;za.dir;za.init;za.loadResources;za.reloadResources;za.use;za.changeLanguage;za.getFixedT;za.t;za.exists;za.setDefaultNamespace;za.hasLoadedNamespace;za.loadNamespaces;za.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);qh(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},WF={},J9=(t,e,n,r)=>{qh(n)&&WF[n]||(qh(n)&&(WF[n]=new Date),Nie(t,e,n,r))},eG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Lk=(t,e,n)=>{t.loadNamespaces(e,eG(t,n))},qF=(t,e,n,r)=>{if(qh(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Lk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,eG(t,r))},Cie=(t,e,n={})=>!e.languages||!e.languages.length?(J9(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}}),qh=t=>typeof t=="string",kie=t=>typeof t=="object"&&t!==null,Pie=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,jie={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Rie=t=>jie[t],Die=t=>t.replace(Pie,Rie);let Ik={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Die};const Oie=(t={})=>{Ik={...Ik,...t}},Lie=()=>Ik;let tG;const Iie=t=>{tG=t},Fie=()=>tG,Uie={type:"3rdParty",init(t){Oie(t.options.react),Iie(t)}},zie=M.createContext();class Bie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var zT={exports:{}},BT={};var KF;function Hie(){if(KF)return BT;KF=1;var t=Jp();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 l(f,g){var p=g(),x=r({inst:{value:p,getSnapshot:g}}),v=x[0].inst,y=x[1];return a(function(){v.value=p,v.getSnapshot=g,c(v)&&y({inst:v})},[f,p,g]),i(function(){return c(v)&&y({inst:v}),f(function(){c(v)&&y({inst:v})})},[f]),s(p),p}function c(f){var g=f.getSnapshot;f=f.value;try{var p=g();return!n(f,p)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return BT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,BT}var XF;function nG(){return XF||(XF=1,zT.exports=Hie()),zT.exports}var Xj=nG();const $ie=(t,e)=>qh(e)?e:kie(e)&&qh(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Vie={t:$ie,ready:!1},Gie=()=>()=>{},eg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=M.useContext(zie)||{},a=n||r||Fie();a&&!a.reportNamespaces&&(a.reportNamespaces=new Bie),a||J9(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=M.useMemo(()=>({...Lie(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=s,u=i||a?.options?.defaultNS,d=qh(u)?[u]:u||["translation"],f=M.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const g=M.useRef(0),p=M.useCallback(k=>{if(!a)return Gie;const{bindI18n:R,bindI18nStore:I}=s,L=()=>{g.current+=1,k()};return R&&a.on(R,L),I&&a.store.on(I,L),()=>{R&&R.split(" ").forEach(q=>a.off(q,L)),I&&I.split(" ").forEach(q=>a.store.off(q,L))}},[a,s]),x=M.useRef(),v=M.useCallback(()=>{if(!a)return Vie;const k=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(V=>Cie(V,a,s)),R=e.lng||a.language,I=g.current,L=x.current;if(L&&L.ready===k&&L.lng===R&&L.keyPrefix===c&&L.revision===I)return L;const j={t:a.getFixedT(R,s.nsMode==="fallback"?f:f[0],c),ready:k,lng:R,keyPrefix:c,revision:I};return x.current=j,j},[a,f,c,s,e.lng]),[y,b]=M.useState(0),{t:E,ready:w}=Xj.useSyncExternalStore(p,v,v);M.useEffect(()=>{if(a&&!w&&!l){const k=()=>b(R=>R+1);e.lng?qF(a,e.lng,f,k):Lk(a,f,k)}},[a,e.lng,f,w,l,y]);const T=a||{},A=M.useRef(null),C=M.useRef(),N=k=>{const R=Object.getOwnPropertyDescriptors(k);R.__original&&delete R.__original;const I=Object.create(Object.getPrototypeOf(k),R);if(!Object.prototype.hasOwnProperty.call(I,"__original"))try{Object.defineProperty(I,"__original",{value:k,writable:!1,enumerable:!1,configurable:!1})}catch{}return I},F=M.useMemo(()=>{const k=T,R=k?.language;let I=k;k&&(A.current&&A.current.__original===k?C.current!==R?(I=N(k),A.current=I,C.current=R):I=A.current:(I=N(k),A.current=I,C.current=R));const L=[E,I,w];return L.t=E,L.i18n=I,L.ready=w,L},[E,T,w,T.resolvedLanguage,T.language,T.languages]);if(a&&l&&!w)throw new Promise(k=>{const R=()=>k();e.lng?qF(a,e.lng,f,R):Lk(a,f,R)});return F},{slice:Wie,forEach:qie}=[];function Kie(t){return qie.call(Wie.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Xie(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 YF=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Yie=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(!YF.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!YF.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},ZF={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=Yie(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 Zie={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return ZF.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&ZF.create(n,t,r,i,a)}},Qie={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 l=a[s].indexOf("=");l>0&&a[s].substring(0,l)===e&&(n=a[s].substring(l+1))}}return n}},Jie={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 l=0;l<s.length;l++){const c=s[l].indexOf("=");c>0&&s[l].substring(0,c)===e&&(r=s[l].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 im=null;const QF=()=>{if(im!==null)return im;try{if(im=typeof window<"u"&&window.localStorage!==null,!im)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{im=!1}return im};var eae={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&QF())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&QF()&&window.localStorage.setItem(n,t)}};let am=null;const JF=()=>{if(am!==null)return am;try{if(am=typeof window<"u"&&window.sessionStorage!==null,!am)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{am=!1}return am};var tae={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&JF())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&JF()&&window.sessionStorage.setItem(n,t)}},nae={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},rae={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}},iae={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}},aae={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 rG=!1;try{document.cookie,rG=!0}catch{}const iG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];rG||iG.splice(1,1);const sae=()=>({order:iG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class aG{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=Kie(n,this.options||{},sae()),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(Zie),this.addDetector(Qie),this.addDetector(eae),this.addDetector(tae),this.addDetector(nae),this.addDetector(rae),this.addDetector(iae),this.addDetector(aae),this.addDetector(Jie)}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&&!Xie(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)}))}}aG.type="languageDetector";const oae={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?"}},lae={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?"}},cae={en:{translation:oae},de:{translation:lae}};za.use(aG).use(Uie).init({resources:cae,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const eU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var tU="popstate";function uae(t={}){function e(r,i){let{pathname:a,search:s,hash:l}=r.location;return Fk("",{pathname:a,search:s,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:T0(i)}return hae(e,n,null,t)}function Pr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Ho(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function dae(){return Math.random().toString(36).substring(2,10)}function nU(t,e){return{usr:t.state,key:t.key,idx:e}}function Fk(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?tg(e):e,state:n,key:e&&e.key||r||dae()}}function T0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function tg(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 hae(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,s=i.history,l="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(){l="POP";let y=d(),b=y==null?null:y-u;u=y,c&&c({action:l,location:v.location,delta:b})}function g(y,b){l="PUSH";let E=Fk(v.location,y,b);u=d()+1;let w=nU(E,u),T=v.createHref(E);try{s.pushState(w,"",T)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;i.location.assign(T)}a&&c&&c({action:l,location:v.location,delta:1})}function p(y,b){l="REPLACE";let E=Fk(v.location,y,b);u=d();let w=nU(E,u),T=v.createHref(E);s.replaceState(w,"",T),a&&c&&c({action:l,location:v.location,delta:0})}function x(y){return fae(y)}let v={get action(){return l},get location(){return t(i,s)},listen(y){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(tU,f),c=y,()=>{i.removeEventListener(tU,f),c=null}},createHref(y){return e(i,y)},createURL:x,encodeLocation(y){let b=x(y);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:g,replace:p,go(y){return s.go(y)}};return v}function fae(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Pr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:T0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function sG(t,e,n="/"){return mae(t,e,n,!1)}function mae(t,e,n,r){let i=typeof e=="string"?tg(e):e,a=Ic(i.pathname||"/",n);if(a==null)return null;let s=oG(t);pae(s);let l=null;for(let c=0;l==null&&c<s.length;++c){let u=Tae(a);l=Mae(s[c],u,r)}return l}function oG(t,e=[],n=[],r="",i=!1){let a=(s,l,c=i,u)=>{let d={relativePath:u===void 0?s.path||"":u,caseSensitive:s.caseSensitive===!0,childrenIndex:l,route:s};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;Pr(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=Cc([r,d.relativePath]),g=n.concat(d);s.children&&s.children.length>0&&(Pr(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),oG(s.children,e,g,f,c)),!(s.path==null&&!s.index)&&e.push({path:f,score:wae(f,s.index),routesMeta:g})};return t.forEach((s,l)=>{if(s.path===""||!s.path?.includes("?"))a(s,l);else for(let c of lG(s.path))a(s,l,!0,c)}),e}function lG(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=lG(r.join("/")),l=[];return l.push(...s.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...s),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function pae(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Sae(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var gae=/^:[\w-]+$/,xae=3,bae=2,yae=1,vae=10,_ae=-2,rU=t=>t==="*";function wae(t,e){let n=t.split("/"),r=n.length;return n.some(rU)&&(r+=_ae),e&&(r+=bae),n.filter(i=>!rU(i)).reduce((i,a)=>i+(gae.test(a)?xae:a===""?yae:vae),r)}function Sae(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 Mae(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",s=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=O1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=O1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),s.push({params:i,pathname:Cc([a,f.pathname]),pathnameBase:Pae(Cc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=Cc([a,f.pathnameBase]))}return s}function O1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Eae(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],s=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=l[g]||"";s=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[g];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:s,pattern:t}}function Eae(t,e=!1,n=!0){Ho(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,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function Tae(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Ho(!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 Ic(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 Aae=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Nae=t=>Aae.test(t);function Cae(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?tg(t):t,a;if(n)if(Nae(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Ho(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=iU(n.substring(1),"/"):a=iU(n,e)}else a=e;return{pathname:a,search:jae(r),hash:Rae(i)}}function iU(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 HT(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 kae(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function cG(t){let e=kae(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function uG(t,e,n,r=!1){let i;typeof t=="string"?i=tg(t):(i={...t},Pr(!i.pathname||!i.pathname.includes("?"),HT("?","pathname","search",i)),Pr(!i.pathname||!i.pathname.includes("#"),HT("#","pathname","hash",i)),Pr(!i.search||!i.search.includes("#"),HT("#","search","hash",i)));let a=t===""||i.pathname==="",s=a?"/":i.pathname,l;if(s==null)l=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("/")}l=f>=0?e[f]:"/"}let c=Cae(i,l),u=s&&s!=="/"&&s.endsWith("/"),d=(a||s===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Cc=t=>t.join("/").replace(/\/\/+/g,"/"),Pae=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),jae=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Rae=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Dae(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 dG=["POST","PUT","PATCH","DELETE"];new Set(dG);var Oae=["GET",...dG];new Set(Oae);var ng=M.createContext(null);ng.displayName="DataRouter";var qS=M.createContext(null);qS.displayName="DataRouterState";M.createContext(!1);var hG=M.createContext({isTransitioning:!1});hG.displayName="ViewTransition";var Lae=M.createContext(new Map);Lae.displayName="Fetchers";var Iae=M.createContext(null);Iae.displayName="Await";var Nl=M.createContext(null);Nl.displayName="Navigation";var vb=M.createContext(null);vb.displayName="Location";var Go=M.createContext({outlet:null,matches:[],isDataRoute:!1});Go.displayName="Route";var Yj=M.createContext(null);Yj.displayName="RouteError";function Fae(t,{relative:e}={}){Pr(_b(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=M.useContext(Nl),{hash:i,pathname:a,search:s}=Sb(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Cc([n,a])),r.createHref({pathname:l,search:s,hash:i})}function _b(){return M.useContext(vb)!=null}function Nd(){return Pr(_b(),"useLocation() may be used only in the context of a <Router> component."),M.useContext(vb).location}var fG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function mG(t){M.useContext(Nl).static||M.useLayoutEffect(t)}function wb(){let{isDataRoute:t}=M.useContext(Go);return t?Jae():Uae()}function Uae(){Pr(_b(),"useNavigate() may be used only in the context of a <Router> component.");let t=M.useContext(ng),{basename:e,navigator:n}=M.useContext(Nl),{matches:r}=M.useContext(Go),{pathname:i}=Nd(),a=JSON.stringify(cG(r)),s=M.useRef(!1);return mG(()=>{s.current=!0}),M.useCallback((c,u={})=>{if(Ho(s.current,fG),!s.current)return;if(typeof c=="number"){n.go(c);return}let d=uG(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Cc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var zae=M.createContext(null);function Bae(t){let e=M.useContext(Go).outlet;return M.useMemo(()=>e&&M.createElement(zae.Provider,{value:t},e),[e,t])}function Zj(){let{matches:t}=M.useContext(Go),e=t[t.length-1];return e?e.params:{}}function Sb(t,{relative:e}={}){let{matches:n}=M.useContext(Go),{pathname:r}=Nd(),i=JSON.stringify(cG(n));return M.useMemo(()=>uG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Hae(t,e){return pG(t,e)}function pG(t,e,n,r,i){Pr(_b(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=M.useContext(Nl),{matches:s}=M.useContext(Go),l=s[s.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let E=f&&f.path||"";gG(u,!f||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let g=Nd(),p;if(e){let E=typeof e=="string"?tg(e):e;Pr(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),p=E}else p=g;let x=p.pathname||"/",v=x;if(d!=="/"){let E=d.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let y=sG(t,{pathname:v});Ho(f||y!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Ho(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=qae(y&&y.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:Cc([d,a.encodeLocation?a.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:Cc([d,a.encodeLocation?a.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),s,n,r,i);return e&&b?M.createElement(vb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},b):b}function $ae(){let t=Qae(),e=Dae(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=M.createElement(M.Fragment,null,M.createElement("p",null,"💿 Hey developer 👋"),M.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",M.createElement("code",{style:a},"ErrorBoundary")," or"," ",M.createElement("code",{style:a},"errorElement")," prop on your route.")),M.createElement(M.Fragment,null,M.createElement("h2",null,"Unexpected Application Error!"),M.createElement("h3",{style:{fontStyle:"italic"}},e),n?M.createElement("pre",{style:i},n):null,s)}var Vae=M.createElement($ae,null),Gae=class extends M.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?M.createElement(Go.Provider,{value:this.props.routeContext},M.createElement(Yj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Wae({routeContext:t,match:e,children:n}){let r=M.useContext(ng);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),M.createElement(Go.Provider,{value:t},n)}function qae(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);Pr(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 l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:g,errors:p}=n,x=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,g)=>{let p,x=!1,v=null,y=null;n&&(p=s&&f.route.id?s[f.route.id]:void 0,v=f.route.errorElement||Vae,l&&(c<0&&g===0?(gG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,y=null):c===g&&(x=!0,y=f.route.hydrateFallbackElement||null)));let b=e.concat(a.slice(0,g+1)),E=()=>{let w;return p?w=v:x?w=y:f.route.Component?w=M.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,M.createElement(Wae,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?M.createElement(Gae,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:E(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):E()},null)}function Qj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Kae(t){let e=M.useContext(ng);return Pr(e,Qj(t)),e}function Xae(t){let e=M.useContext(qS);return Pr(e,Qj(t)),e}function Yae(t){let e=M.useContext(Go);return Pr(e,Qj(t)),e}function Jj(t){let e=Yae(t),n=e.matches[e.matches.length-1];return Pr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Zae(){return Jj("useRouteId")}function Qae(){let t=M.useContext(Yj),e=Xae("useRouteError"),n=Jj("useRouteError");return t!==void 0?t:e.errors?.[n]}function Jae(){let{router:t}=Kae("useNavigate"),e=Jj("useNavigate"),n=M.useRef(!1);return mG(()=>{n.current=!0}),M.useCallback(async(i,a={})=>{Ho(n.current,fG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var aU={};function gG(t,e,n){!e&&!aU[t]&&(aU[t]=!0,Ho(!1,n))}M.memo(ese);function ese({routes:t,future:e,state:n,unstable_onError:r}){return pG(t,void 0,n,r,e)}function tse(t){return Bae(t.context)}function Xa(t){Pr(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function nse({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Pr(!_b(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),l=M.useMemo(()=>({basename:s,navigator:i,static:a,future:{}}),[s,i,a]);typeof n=="string"&&(n=tg(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,p=M.useMemo(()=>{let x=Ic(c,s);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[s,c,u,d,f,g,r]);return Ho(p!=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.`),p==null?null:M.createElement(Nl.Provider,{value:l},M.createElement(vb.Provider,{children:e,value:p}))}function rse({children:t,location:e}){return Hae(Uk(t),e)}function Uk(t,e=[]){let n=[];return M.Children.forEach(t,(r,i)=>{if(!M.isValidElement(r))return;let a=[...e,i];if(r.type===M.Fragment){n.push.apply(n,Uk(r.props.children,a));return}Pr(r.type===Xa,`[${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>`),Pr(!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=Uk(r.props.children,a)),n.push(s)}),n}var l1="get",c1="application/x-www-form-urlencoded";function KS(t){return t!=null&&typeof t.tagName=="string"}function ise(t){return KS(t)&&t.tagName.toLowerCase()==="button"}function ase(t){return KS(t)&&t.tagName.toLowerCase()==="form"}function sse(t){return KS(t)&&t.tagName.toLowerCase()==="input"}function ose(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function lse(t,e){return t.button===0&&(!e||e==="_self")&&!ose(t)}var Mv=null;function cse(){if(Mv===null)try{new FormData(document.createElement("form"),0),Mv=!1}catch{Mv=!0}return Mv}var use=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function $T(t){return t!=null&&!use.has(t)?(Ho(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${c1}"`),null):t}function dse(t,e){let n,r,i,a,s;if(ase(t)){let l=t.getAttribute("action");r=l?Ic(l,e):null,n=t.getAttribute("method")||l1,i=$T(t.getAttribute("enctype"))||c1,a=new FormData(t)}else if(ise(t)||sse(t)&&(t.type==="submit"||t.type==="image")){let l=t.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||l.getAttribute("action");if(r=c?Ic(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||l1,i=$T(t.getAttribute("formenctype"))||$T(l.getAttribute("enctype"))||c1,a=new FormData(l,t),!cse()){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(KS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=l1,r=null,i=c1,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 eR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function hse(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&&Ic(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function fse(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 mse(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 pse(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await fse(a,n);return s.links?s.links():[]}return[]}));return yse(r.flat(1).filter(mse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function sU(t,e,n,r,i,a){let s=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>s(c,u)||l(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(s(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function gse(t,e,{includeHydrateFallback:n}={}){return xse(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 xse(t){return[...new Set(t)]}function bse(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function yse(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(bse(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function xG(){let t=M.useContext(ng);return eR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function vse(){let t=M.useContext(qS);return eR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var tR=M.createContext(void 0);tR.displayName="FrameworkContext";function bG(){let t=M.useContext(tR);return eR(t,"You must render this element inside a <HydratedRouter> element"),t}function _se(t,e){let n=M.useContext(tR),[r,i]=M.useState(!1),[a,s]=M.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=M.useRef(null);M.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let v=b=>{b.forEach(E=>{s(E.isIntersecting)})},y=new IntersectionObserver(v,{threshold:.5});return g.current&&y.observe(g.current),()=>{y.disconnect()}}},[t]),M.useEffect(()=>{if(r){let v=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(v)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:gx(l,p),onBlur:gx(c,x),onMouseEnter:gx(u,p),onMouseLeave:gx(d,x),onTouchStart:gx(f,p)}]:[!1,g,{}]}function gx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function wse({page:t,...e}){let{router:n}=xG(),r=M.useMemo(()=>sG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?M.createElement(Mse,{page:t,matches:r,...e}):null}function Sse(t){let{manifest:e,routeModules:n}=bG(),[r,i]=M.useState([]);return M.useEffect(()=>{let a=!1;return pse(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function Mse({page:t,matches:e,...n}){let r=Nd(),{manifest:i,routeModules:a}=bG(),{basename:s}=xG(),{loaderData:l,matches:c}=vse(),u=M.useMemo(()=>sU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=M.useMemo(()=>sU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=M.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,v=!1;if(e.forEach(b=>{let E=i.routes[b.route.id];!E||!E.hasLoader||(!u.some(w=>w.route.id===b.route.id)&&b.route.id in l&&a[b.route.id]?.shouldRevalidate||E.hasClientLoader?v=!0:x.add(b.route.id))}),x.size===0)return[];let y=hse(t,s,"data");return v&&x.size>0&&y.searchParams.set("_routes",e.filter(b=>x.has(b.route.id)).map(b=>b.route.id).join(",")),[y.pathname+y.search]},[s,l,r,i,u,e,t,a]),g=M.useMemo(()=>gse(d,i),[d,i]),p=Sse(d);return M.createElement(M.Fragment,null,f.map(x=>M.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>M.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),p.map(({key:x,link:v})=>M.createElement("link",{key:x,nonce:n.nonce,...v})))}function Ese(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var yG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{yG&&(window.__reactRouterVersion="7.9.6")}catch{}function Tse({basename:t,children:e,window:n}){let r=M.useRef();r.current==null&&(r.current=uae({window:n,v5Compat:!0}));let i=r.current,[a,s]=M.useState({action:i.action,location:i.location}),l=M.useCallback(c=>{M.startTransition(()=>s(c))},[s]);return M.useLayoutEffect(()=>i.listen(l),[i,l]),M.createElement(nse,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var vG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,_c=M.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:s,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},p){let{basename:x}=M.useContext(Nl),v=typeof u=="string"&&vG.test(u),y,b=!1;if(typeof u=="string"&&v&&(y=u,yG))try{let k=new URL(window.location.href),R=u.startsWith("//")?new URL(k.protocol+u):new URL(u),I=Ic(R.pathname,x);R.origin===k.origin&&I!=null?u=I+R.search+R.hash:b=!0}catch{Ho(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=Fae(u,{relative:i}),[w,T,A]=_se(r,g),C=Cse(u,{replace:s,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f});function N(k){e&&e(k),k.defaultPrevented||C(k)}let F=M.createElement("a",{...g,...A,href:y||E,onClick:b||a?e:N,ref:Ese(p,T),target:c,"data-discover":!v&&n==="render"?"true":void 0});return w&&!v?M.createElement(M.Fragment,null,F,M.createElement(wse,{page:E})):F});_c.displayName="Link";var $x=M.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:s,viewTransition:l,children:c,...u},d){let f=Sb(s,{relative:u.relative}),g=Nd(),p=M.useContext(qS),{navigator:x,basename:v}=M.useContext(Nl),y=p!=null&&Dse(f)&&l===!0,b=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(E=E.toLowerCase(),w=w?w.toLowerCase():null,b=b.toLowerCase()),w&&v&&(w=Ic(w,v)||w);const T=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let A=E===b||!i&&E.startsWith(b)&&E.charAt(T)==="/",C=w!=null&&(w===b||!i&&w.startsWith(b)&&w.charAt(b.length)==="/"),N={isActive:A,isPending:C,isTransitioning:y},F=A?e:void 0,k;typeof r=="function"?k=r(N):k=[r,A?"active":null,C?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(N):a;return M.createElement(_c,{...u,"aria-current":F,className:k,ref:d,style:R,to:s,viewTransition:l},typeof c=="function"?c(N):c)});$x.displayName="NavLink";var Ase=M.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:s=l1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},p)=>{let x=jse(),v=Rse(l,{relative:u}),y=s.toLowerCase()==="get"?"get":"post",b=typeof l=="string"&&vG.test(l),E=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let T=w.nativeEvent.submitter,A=T?.getAttribute("formmethod")||s;x(T||w.currentTarget,{fetcherKey:e,method:A,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return M.createElement("form",{ref:p,method:y,action:v,onSubmit:r?c:E,...g,"data-discover":!b&&t==="render"?"true":void 0})});Ase.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 _G(t){let e=M.useContext(ng);return Pr(e,Nse(t)),e}function Cse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let l=wb(),c=Nd(),u=Sb(t,{relative:a});return M.useCallback(d=>{if(lse(d,e)){d.preventDefault();let f=n!==void 0?n:T0(c)===T0(u);l(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:s})}},[c,l,u,n,r,e,t,i,a,s])}var kse=0,Pse=()=>`__${String(++kse)}__`;function jse(){let{router:t}=_G("useSubmit"),{basename:e}=M.useContext(Nl),n=Zae();return M.useCallback(async(r,i={})=>{let{action:a,method:s,encType:l,formData:c,body:u}=dse(r,e);if(i.navigate===!1){let d=i.fetcherKey||Pse();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||l,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||l,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function Rse(t,{relative:e}={}){let{basename:n}=M.useContext(Nl),r=M.useContext(Go);Pr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Sb(t||".",{relative:e})},s=Nd();if(t==null){a.search=s.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Cc([n,a.pathname])),T0(a)}function Dse(t,{relative:e}={}){let n=M.useContext(hG);Pr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=_G("useViewTransitionState"),i=Sb(t,{relative:e});if(!n.isTransitioning)return!1;let a=Ic(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=Ic(n.nextLocation.pathname,r)||n.nextLocation.pathname;return O1(i.pathname,s)!=null||O1(i.pathname,a)!=null}var wc=X9();const Ose=bo(wc);var rg=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(){}},Lse={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ise=class{#e=Lse;#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)}},Sh=new Ise;function Fse(t){setTimeout(t,0)}var Kh=typeof window>"u"||"Deno"in globalThis;function Ca(){}function Use(t,e){return typeof t=="function"?t(e):t}function zk(t){return typeof t=="number"&&t>=0&&t!==1/0}function wG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function id(t,e){return typeof t=="function"?t(e):t}function Ys(t,e){return typeof t=="function"?t(e):t}function oU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:l}=t;if(s){if(r){if(e.queryHash!==nR(s,e.options))return!1}else if(!A0(e.queryKey,s))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||a&&!a(e))}function lU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Xh(e.options.mutationKey)!==Xh(a))return!1}else if(!A0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function nR(t,e){return(e?.queryKeyHashFn||Xh)(t)}function Xh(t){return JSON.stringify(t,(e,n)=>Bk(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function A0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>A0(t[n],e[n])):!1}var zse=Object.prototype.hasOwnProperty;function SG(t,e){if(t===e)return t;const n=cU(t)&&cU(e);if(!n&&!(Bk(t)&&Bk(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,l=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){l[d]=f,(n?u<i:zse.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){l[d]=g;continue}const p=SG(f,g);l[d]=p,p===f&&c++}return i===s&&c===i?t:l}function L1(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 cU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Bk(t){if(!uU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!uU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function uU(t){return Object.prototype.toString.call(t)==="[object Object]"}function Bse(t){return new Promise(e=>{Sh.setTimeout(e,t)})}function Hk(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?SG(t,e):e}function Hse(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function $se(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var rR=Symbol();function MG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===rR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function EG(t,e){return typeof t=="function"?t(...e):!!t}var Vse=class extends rg{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Kh&&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 Vse;function $k(){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 Gse=Fse;function Wse(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Gse;const a=l=>{e?t.push(l):i(()=>{n(l)})},s=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||s()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var yi=Wse(),qse=class extends rg{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Kh&&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}},I1=new qse;function Kse(t){return Math.min(1e3*2**t,3e4)}function TG(t){return(t??"online")==="online"?I1.isOnline():!0}var Vk=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function AG(t){let e=!1,n=0,r;const i=$k(),a=()=>i.status!=="pending",s=v=>{if(!a()){const y=new Vk(v);g(y),t.onCancel?.(y)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>iR.isFocused()&&(t.networkMode==="always"||I1.isOnline())&&t.canRun(),d=()=>TG(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},g=v=>{a()||(r?.(),i.reject(v))},p=()=>new Promise(v=>{r=y=>{(a()||u())&&v(y)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let v;const y=n===0?t.initialPromise:void 0;try{v=y??t.fn()}catch(b){v=Promise.reject(b)}Promise.resolve(v).then(f).catch(b=>{if(a())return;const E=t.retry??(Kh?0:3),w=t.retryDelay??Kse,T=typeof w=="function"?w(n,b):w,A=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(e||!A){g(b);return}n++,t.onFail?.(n,b),Bse(T).then(()=>u()?void 0:p()).then(()=>{e?g(b):x()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var NG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zk(this.gcTime)&&(this.#e=Sh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Kh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Sh.clearTimeout(this.#e),this.#e=void 0)}},Xse=class extends NG{#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=hU(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=hU(this.options);e.data!==void 0&&(this.setState(dU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Hk(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(Ca).catch(Ca):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ys(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===rR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>id(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!wG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=MG(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},s=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(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=AG({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof Vk&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#a({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Vk){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#a({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...CG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...dU(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),yi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function CG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:TG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function dU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function hU(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 Yse=class extends rg{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=$k(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),fU(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Gk(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Gk(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 Ys(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&&!L1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&mU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Ys(this.options.enabled,this.#t)!==Ys(e.enabled,this.#t)||id(this.options.staleTime,this.#t)!==id(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Ys(this.options.enabled,this.#t)!==Ys(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 Qse(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ca)),e}#g(){this.#v();const t=id(this.options.staleTime,this.#t);if(Kh||this.#i.isStale||!zk(t))return;const n=wG(this.#i.dataUpdatedAt,t)+1;this.#c=Sh.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,!(Kh||Ys(this.options.enabled,this.#t)===!1||!zk(this.#l)||this.#l===0)&&(this.#u=Sh.setInterval(()=>{(this.options.refetchIntervalInBackground||iR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Sh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Sh.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 F=this.hasListeners(),k=!F&&fU(t,e),R=F&&mU(t,n,e,r);(k||R)&&(d={...d,...CG(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:v}=d;g=d.data;let y=!1;if(e.placeholderData!==void 0&&g===void 0&&v==="pending"){let F;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(F=i.data,y=!0):F=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,F!==void 0&&(v="success",g=Hk(i?.data,F,e),f=!0)}if(e.select&&g!==void 0&&!y)if(i&&g===a?.data&&e.select===this.#p)g=this.#h;else try{this.#p=e.select,g=e.select(g),g=Hk(i?.data,g,e),this.#h=g,this.#a=null}catch(F){this.#a=F}this.#a&&(p=this.#a,g=this.#h,x=Date.now(),v="error");const b=d.fetchStatus==="fetching",E=v==="pending",w=v==="error",T=E&&b,A=g!==void 0,N={status:v,fetchStatus:d.fetchStatus,isPending:E,isSuccess:v==="success",isError:w,isInitialLoading:T,isLoading:T,data:g,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!E,isLoadingError:w&&!A,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&A,isStale:aR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ys(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const F=I=>{N.status==="error"?I.reject(N.error):N.data!==void 0&&I.resolve(N.data)},k=()=>{const I=this.#o=N.promise=$k();F(I)},R=this.#o;switch(R.status){case"pending":t.queryHash===n.queryHash&&F(R);break;case"fulfilled":(N.status==="error"||N.data!==R.value)&&k();break;case"rejected":(N.status!=="error"||N.error!==R.reason)&&k();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),L1(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const a=new Set(i??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(s=>{const l=s;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){yi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Zse(t,e){return Ys(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function fU(t,e){return Zse(t,e)||t.state.data!==void 0&&Gk(t,e,e.refetchOnMount)}function Gk(t,e,n){if(Ys(e.enabled,t)!==!1&&id(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&aR(t,e)}return!1}function mU(t,e,n,r){return(t!==e||Ys(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&aR(t,n)}function aR(t,e){return Ys(e.enabled,t)!==!1&&t.isStaleByTime(id(e.staleTime,t))}function Qse(t,e){return!L1(t.getCurrentResult(),e)}function pU(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 l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=MG(e.options,e.fetchOptions),p=async(x,v,y)=>{if(d)return Promise.reject();if(v==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:v,direction:y?"backward":"forward",meta:e.options.meta};return f(C),C})(),w=await g(E),{maxPages:T}=e.options,A=y?$se:Hse;return{pages:A(x.pages,w,T),pageParams:A(x.pageParams,v,T)}};if(i&&a.length){const x=i==="backward",v=x?Jse:gU,y={pages:a,pageParams:s},b=v(r,y);l=await p(y,b,x)}else{const x=t??a.length;do{const v=c===0?s[0]??r.initialPageParam:gU(r,l);if(c>0&&v==null)break;l=await p(l,v),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function gU(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 Jse(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var eoe=class extends NG{#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||kG(),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=AG({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),yi.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function kG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var toe=class extends rg{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 eoe({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=Ev(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=Ev(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=Ev(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=Ev(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){yi.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=>lU(e,n))}findAll(t={}){return this.getAll().filter(e=>lU(t,e))}notify(t){yi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return yi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ca))))}};function Ev(t){return t.options.scope?.id}var noe=class extends rg{#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),L1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Xh(n.mutationKey)!==Xh(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??kG();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){yi.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)})})}},roe=class extends rg{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??nR(r,e);let a=this.get(i);return a||(a=new Xse({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(){yi.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=>oU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>oU(t,n)):e}notify(t){yi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){yi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){yi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ioe=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new roe,this.#t=t.mutationCache||new toe,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=I1.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(id(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=Use(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return yi.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;yi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return yi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=yi.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ca).catch(Ca)}invalidateQueries(t,e={}){return yi.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=yi.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(Ca)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ca)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(id(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ca).catch(Ca)}fetchInfiniteQuery(t){return t.behavior=pU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ca).catch(Ca)}ensureInfiniteQueryData(t){return t.behavior=pU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return I1.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(Xh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{A0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Xh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{A0(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=nR(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===rR&&(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()}},PG=M.createContext(void 0),mn=t=>{const e=M.useContext(PG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},aoe=({client:t,children:e})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),o.jsx(PG.Provider,{value:t,children:e})),jG=M.createContext(!1),soe=()=>M.useContext(jG);jG.Provider;function ooe(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var loe=M.createContext(ooe()),coe=()=>M.useContext(loe),uoe=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},doe=t=>{M.useEffect(()=>{t.clearReset()},[t])},hoe=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||EG(n,[t.error,r])),foe=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))}},moe=(t,e)=>t.isLoading&&t.isFetching&&!e,poe=(t,e)=>t?.suspense&&e.isPending,xU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function goe(t,e,n){const r=soe(),i=coe(),a=mn(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",foe(s),uoe(s,i),doe(i);const l=!a.getQueryCache().get(s.queryHash),[c]=M.useState(()=>new e(a,s)),u=c.getOptimisticResult(s),d=!r&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(f=>{const g=d?c.subscribe(yi.batchCalls(f)):Ca;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setOptions(s)},[s,c]),poe(s,u))throw xU(s,c,i);if(hoe({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&&!Kh&&moe(u,r)&&(l?xU(s,c,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(Ca).finally(()=>{c.updateResult()}),s.notifyOnChangeProps?u:c.trackResult(u)}function gt(t,e){return goe(t,Yse)}function vt(t,e){const n=mn(),[r]=M.useState(()=>new noe(n,t));M.useEffect(()=>{r.setOptions(t)},[r,t]);const i=M.useSyncExternalStore(M.useCallback(s=>r.subscribe(yi.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((s,l)=>{r.mutate(s,l).catch(Ca)},[r]);if(i.error&&EG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const xoe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),boe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),bU=t=>{const e=boe(t);return e.charAt(0).toUpperCase()+e.slice(1)},RG=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),yoe=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var voe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const _oe=M.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:s,...l},c)=>M.createElement("svg",{ref:c,...voe,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:RG("lucide",i),...!a&&!yoe(l)&&{"aria-hidden":"true"},...l},[...s.map(([u,d])=>M.createElement(u,d)),...Array.isArray(a)?a:[a]]));const qe=(t,e)=>{const n=M.forwardRef(({className:r,...i},a)=>M.createElement(_oe,{ref:a,iconNode:e,className:RG(`lucide-${xoe(bU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=bU(t),n};const woe=[["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"}]],oo=qe("archive",woe);const Soe=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],N0=qe("arrow-down",Soe);const Moe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Eoe=qe("arrow-left",Moe);const Toe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Wk=qe("arrow-right",Toe);const Aoe=[["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"}]],Noe=qe("arrow-up-down",Aoe);const Coe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],vp=qe("arrow-up",Coe);const koe=[["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"}]],jh=qe("bell",koe);const Poe=[["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"}]],joe=qe("bold",Poe);const Roe=[["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"}]],Doe=qe("book",Roe);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 Ioe=[["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"}]],_p=qe("box",Ioe);const Foe=[["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"}]],Uoe=qe("cable",Foe);const zoe=[["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"}]],Boe=qe("calendar-days",zoe);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"}]],Qr=qe("calendar",Hoe);const $oe=[["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"}]],C0=qe("camera",$oe);const Voe=[["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"}]],Goe=qe("chart-column",Voe);const Woe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],xl=qe("check",Woe);const qoe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Cl=qe("chevron-down",qoe);const Koe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xc=qe("chevron-right",Koe);const Xoe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Yh=qe("chevron-left",Xoe);const Yoe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Mb=qe("chevron-up",Yoe);const Zoe=[["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"}]],mo=qe("circle-alert",Zoe);const Qoe=[["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"}]],VT=qe("circle-arrow-up",Qoe);const Joe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Cr=qe("circle-check-big",Joe);const ele=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],sR=qe("circle-check",ele);const tle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],nle=qe("circle-dot",tle);const rle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],ile=qe("circle-stop",rle);const ale=[["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"}]],Pa=qe("circle-x",ale);const sle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],yU=qe("circle",sle);const ole=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rr=qe("clock",ole);const lle=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],XS=qe("cloud",lle);const cle=[["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"}]],ule=qe("code-xml",cle);const dle=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],DG=qe("code",dle);const hle=[["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"}]],fle=qe("coffee",hle);const mle=[["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"}]],ple=qe("cog",mle);const gle=[["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"}]],xle=qe("compass",gle);const ble=[["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"}]],md=qe("copy",ble);const yle=[["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"}]],Tv=qe("cpu",yle);const vle=[["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"}]],wp=qe("database",vle);const _le=[["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"}]],qk=qe("dollar-sign",_le);const wle=[["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"}]],is=qe("download",wle);const Sle=[["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"}]],oR=qe("droplet",Sle);const Mle=[["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"}]],lR=qe("droplets",Mle);const Ele=[["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"}]],cR=qe("ellipsis-vertical",Ele);const Tle=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],GT=qe("equal",Tle);const Ale=[["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"}]],ba=qe("external-link",Ale);const Nle=[["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"}]],YS=qe("eye-off",Nle);const Cle=[["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"}]],Zh=qe("eye",Cle);const kle=[["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"}]],Ple=qe("fan",kle);const jle=[["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"}]],OG=qe("file-box",jle);const Rle=[["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"}]],Kk=qe("file-code",Rle);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:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ole=qe("file-exclamation-point",Dle);const Lle=[["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"}]],F1=qe("file-spreadsheet",Lle);const Ile=[["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"}]],Es=qe("file-text",Ile);const Fle=[["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"}]],uR=qe("file",Fle);const Ule=[["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"}]],Rh=qe("film",Ule);const zle=[["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"}]],Ble=qe("flame",zle);const Hle=[["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"}]],Uo=qe("folder-kanban",Hle);const $le=[["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"}]],Vle=qe("folder-open",$le);const Gle=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Wle=qe("folder-tree",Gle);const qle=[["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"}]],LG=qe("folder",qle);const Kle=[["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"}]],dR=qe("funnel",Kle);const Xle=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ZS=qe("gauge",Xle);const Yle=[["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"}]],Zle=qe("gift",Yle);const Qle=[["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"}]],op=qe("git-compare",Qle);const Jle=[["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"}]],vU=qe("github",Jle);const ece=[["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"}]],k0=qe("globe",ece);const tce=[["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"}]],P0=qe("grip-vertical",tce);const nce=[["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"}]],hR=qe("hard-drive",nce);const rce=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],ice=qe("heart",rce);const ace=[["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"}]],U1=qe("history",ace);const sce=[["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"}]],oce=qe("house",sce);const lce=[["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"}]],Eb=qe("image",lce);const cce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Sp=qe("info",cce);const uce=[["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"}]],dce=qe("italic",uce);const hce=[["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"}]],ep=qe("key",hce);const fce=[["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"}]],Xk=qe("keyboard",fce);const mce=[["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"}]],pd=qe("layers",mce);const pce=[["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"}]],QS=qe("layout-grid",pce);const gce=[["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"}]],xce=qe("layout-list",gce);const bce=[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],yce=qe("link-2-off",bce);const vce=[["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"}]],Yk=qe("link-2",vce);const _ce=[["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"}]],Tb=qe("link",_ce);const wce=[["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"}]],IG=qe("list-ordered",wce);const Sce=[["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"}]],Zk=qe("list-todo",Sce);const Mce=[["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"}]],fR=qe("list",Mce);const Ece=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],xt=qe("loader-circle",Ece);const Tce=[["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"}]],_U=qe("log-in",Tce);const Ace=[["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"}]],Nce=qe("log-out",Ace);const Cce=[["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"}]],kce=qe("mail",Cce);const Pce=[["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"}]],jce=qe("map",Pce);const Rce=[["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"}]],Dce=qe("maximize-2",Rce);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 Ice=[["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"}]],Fce=qe("memory-stick",Ice);const Uce=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],zce=qe("menu",Uce);const Bce=[["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"}]],Hce=qe("minimize-2",Bce);const $ce=[["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"}]],Vce=qe("minimize",$ce);const Gce=[["path",{d:"M5 12h14",key:"1ays0h"}]],Qk=qe("minus",Gce);const Wce=[["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"}]],z1=qe("moon",Wce);const qce=[["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"}]],Jk=qe("music",qce);const Kce=[["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"}]],Fc=qe("package",Kce);const Xce=[["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"}]],mR=qe("palette",Xce);const Yce=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Zce=qe("paperclip",Yce);const Qce=[["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"}]],FG=qe("pause",Qce);const Jce=[["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"}]],Qh=qe("pen-line",Jce);const eue=[["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"}]],pR=qe("pen",eue);const tue=[["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"}]],Uc=qe("pencil",tue);const nue=[["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"}]],rue=qe("phone",nue);const iue=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Mp=qe("play",iue);const aue=[["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"}]],lo=qe("plug",aue);const sue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],sr=qe("plus",sue);const oue=[["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"}]],JS=qe("power-off",oue);const lue=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],kl=qe("power",lue);const cue=[["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"}]],Vi=qe("printer",cue);const uue=[["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"}]],due=qe("qr-code",uue);const hue=[["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"}]],_a=qe("refresh-cw",hue);const fue=[["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"}]],ig=qe("rotate-ccw",fue);const mue=[["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"}]],pue=qe("ruler",mue);const gue=[["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"}]],Ts=qe("save",gue);const xue=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]],bue=qe("scan-search",xue);const yue=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],vue=qe("scissors",yue);const _ue=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],bl=qe("search",_ue);const wue=[["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"}]],gR=qe("send",wue);const Sue=[["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"}]],dh=qe("server",Sue);const Mue=[["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"}]],eM=qe("settings-2",Mue);const Eue=[["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"}]],xR=qe("settings",Eue);const Tue=[["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"}]],Aue=qe("shield",Tue);const Nue=[["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"}]],UG=qe("shopping-cart",Nue);const Cue=[["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"}]],kue=qe("signal",Cue);const Pue=[["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"}]],jue=qe("skip-back",Pue);const Rue=[["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"}]],B1=qe("skip-forward",Rue);const Due=[["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"}]],wU=qe("sliders-vertical",Due);const Oue=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],j0=qe("sparkles",Oue);const Lue=[["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"}]],Jh=qe("square-check-big",Lue);const Iue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ep=qe("square",Iue);const Fue=[["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"}]],Tp=qe("star",Fue);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"}]],zG=qe("sticky-note",Uue);const zue=[["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"}]],SU=qe("sun",zue);const Bue=[["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"}]],Ap=qe("tag",Bue);const Hue=[["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"}]],BG=qe("target",Hue);const $ue=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],HG=qe("terminal",$ue);const Vue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Gue=qe("text-align-center",Vue);const Wue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],que=qe("text-align-end",Wue);const Kue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Xue=qe("text-align-start",Kue);const Yue=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],tM=qe("thermometer",Yue);const Zue=[["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",Zue);const Que=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],En=qe("trash-2",Que);const Jue=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],$G=qe("trending-down",Jue);const ede=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],VG=qe("trending-up",ede);const tde=[["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"}]],Gn=qe("triangle-alert",tde);const nde=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],rde=qe("underline",nde);const ide=[["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"}]],GG=qe("unlink",ide);const ade=[["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"}]],oa=qe("upload",ade);const sde=[["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"}]],e3=qe("user",sde);const ode=[["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"}]],lde=qe("users",ode);const cde=[["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"}]],WG=qe("video",cde);const ude=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],dde=qe("volume-2",ude);const hde=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],fde=qe("volume-x",hde);const mde=[["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"}]],Ab=qe("wifi-off",mde);const pde=[["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"}]],bR=qe("wifi",pde);const gde=[["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"}]],xde=qe("wind",gde);const bde=[["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"}]],gd=qe("wrench",bde);const yde=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gt=qe("x",yde);const vde=[["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"}]],_de=qe("zoom-in",vde);const wde=[["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"}]],ef=qe("zap",wde);const Sde=[["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"}]],Mde=qe("zoom-out",Sde),Rn="/api/v1";async function Be(t,e={}){const n=await fetch(`${Rn}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const i=(await n.json().catch(()=>({}))).detail,a=typeof i=="string"?i:i?JSON.stringify(i):`HTTP ${n.status}`;throw new Error(a)}return await n.json()}const Se={getPrinters:()=>Be("/printers/"),getPrinter:t=>Be(`/printers/${t}`),createPrinter:t=>Be("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Be(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Be(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Be(`/printers/${t}/status`),refreshPrinterStatus:t=>Be(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Be(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Be(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>Be(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Be(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Be(`/printers/${t}/logging`),clearMQTTLogs:t=>Be(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Be(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Rn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Be(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Be(`/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)),Be(`/archives/?${i}`)},getArchive:t=>Be(`/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)),Be(`/archives/search?${n}`)},rebuildSearchIndex:()=>Be("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Be(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Be(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Be(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Be("/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)),Be(`/archives/analysis/failures?${e}`)},compareArchives:t=>Be(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Be(`/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(`${Rn}/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(`${Rn}/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=>Be(`/archives/${t}/duplicates`),backfillContentHashes:()=>Be("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Rn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${Rn}/archives/${t}/download`,getArchiveGcode:t=>`${Rn}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${Rn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Be(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Be(`/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(`${Rn}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getTimelapseInfo:t=>Be(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Be(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i=await fetch(`${Rn}/archives/${t}/timelapse/process`,{method:"POST",body:r});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${Rn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Rn}/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)=>Be(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Rn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Rn}/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(`${Rn}/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=>Be(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Rn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Be(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Be(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Be(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Rn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Rn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchiveFilamentRequirements:t=>Be(`/archives/${t}/filament-requirements`),reprintArchive:(t,e)=>Be(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${Rn}/archives/upload?printer_id=${e}`:`${Rn}/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?`${Rn}/archives/upload-bulk?printer_id=${e}`:`${Rn}/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:()=>Be("/settings/"),updateSettings:t=>Be("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>Be("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.projects!==void 0&&e.set("include_projects",String(t.projects)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)));const n=`${Rn}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n),i=r.headers.get("Content-Disposition");let a="bambuddy-backup.json";if(i){const l=i.match(/filename=([^;]+)/);l&&(a=l[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${Rn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Be("/settings/check-ffmpeg"),getCloudStatus:()=>Be("/cloud/status"),cloudLogin:(t,e,n="global")=>Be("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Be("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Be("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Be("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Be(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Be(`/cloud/settings/${t}`),createCloudSetting:t=>Be("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Be(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Be(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Be("/cloud/devices"),getCloudFields:t=>Be(`/cloud/fields/${t}`),getAllCloudFields:()=>Be("/cloud/fields"),getFilamentInfo:t=>Be("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Be("/smart-plugs/"),getSmartPlug:t=>Be(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Be(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Be("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Be(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Be(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Be(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Be(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Be("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${Rn}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>Be("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${Rn}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>Be("/smart-plugs/discover/devices"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Be(`/queue/?${n}`)},getQueueItem:t=>Be(`/queue/${t}`),addToQueue:t=>Be("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Be(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Be(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Be("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Be(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Be(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Be(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Be(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Be(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Be(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Be(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Be(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Be(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Be(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Be(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Be(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Be(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>Be("/filaments/"),getFilament:t=>Be(`/filaments/${t}`),getFilamentsByType:t=>Be(`/filaments/by-type/${t}`),getNotificationProviders:()=>Be("/notifications/"),getNotificationProvider:t=>Be(`/notifications/${t}`),createNotificationProvider:t=>Be("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Be(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Be(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Be(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Be("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Be("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Be("/notification-templates"),getNotificationTemplate:t=>Be(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Be(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Be(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Be("/notification-templates/variables"),previewTemplate:t=>Be("/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)),Be(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Be(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Be(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Be("/spoolman/status"),connectSpoolman:()=>Be("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Be("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Be(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Be("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Be("/spoolman/spools"),getSpoolmanFilaments:()=>Be("/spoolman/filaments"),getVersion:()=>Be("/updates/version"),checkForUpdates:()=>Be("/updates/check"),applyUpdate:()=>Be("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Be("/updates/status"),getMaintenanceTypes:()=>Be("/maintenance/types"),createMaintenanceType:t=>Be("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Be(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Be(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Be("/maintenance/overview"),getPrinterMaintenance:t=>Be(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Be(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Be(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Be(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Be("/maintenance/summary"),setPrinterHours:(t,e)=>Be(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Be(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Be(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${Rn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Rn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Be(`/printers/${t}/camera/test`),getExternalLinks:()=>Be("/external-links/"),getExternalLink:t=>Be(`/external-links/${t}`),createExternalLink:t=>Be("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Be(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Be(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Be("/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(`${Rn}/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=>Be(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${Rn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Be(`/projects/?${e}`)},getProject:t=>Be(`/projects/${t}`),createProject:t=>Be("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Be(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Be(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Be(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Be(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Be(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Be(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Rn}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${Rn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Be(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Be(`/projects/${t}/bom`),createBOMItem:(t,e)=>Be(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Be(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Be(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Be("/projects/templates/"),createTemplateFromProject:t=>Be(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Be(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Be(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>Be("/api-keys/"),createAPIKey:t=>Be("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Be(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Be(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Be(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Be("/system/info")},Jo={getInfo:()=>Be("/discovery/info"),getStatus:()=>Be("/discovery/status"),startDiscovery:(t=10)=>Be(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Be("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Be("/discovery/printers"),startSubnetScan:(t,e=1)=>Be("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Be("/discovery/scan/status"),stopSubnetScan:()=>Be("/discovery/scan/stop",{method:"POST"})},t3={getSettings:()=>Be("/settings/virtual-printer"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),Be(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},xx={list:()=>Be("/pending-uploads/"),getCount:()=>Be("/pending-uploads/count"),get:t=>Be(`/pending-uploads/${t}`),archive:(t,e)=>Be(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Be(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Be("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Be("/pending-uploads/discard-all",{method:"DELETE"})},qG=M.createContext(void 0);function Ede({children:t}){const[e,n]=M.useState(()=>{const N=localStorage.getItem("theme-mode"),F=localStorage.getItem("theme");return N||F||"dark"}),[r,i]=M.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,s]=M.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=M.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=M.useState(()=>localStorage.getItem("light-style")||"classic"),[f,g]=M.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=M.useState(()=>localStorage.getItem("light-accent")||"green");M.useEffect(()=>{Se.getSettings().then(N=>{N.dark_style&&(i(N.dark_style),localStorage.setItem("dark-style",N.dark_style)),N.dark_background&&(s(N.dark_background),localStorage.setItem("dark-background",N.dark_background)),N.dark_accent&&(c(N.dark_accent),localStorage.setItem("dark-accent",N.dark_accent)),N.light_style&&(d(N.light_style),localStorage.setItem("light-style",N.light_style)),N.light_background&&(g(N.light_background),localStorage.setItem("light-background",N.light_background)),N.light_accent&&(x(N.light_accent),localStorage.setItem("light-accent",N.light_accent))}).catch(()=>{})},[]),M.useEffect(()=>{const N=document.documentElement;N.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(N.classList.add("dark"),N.classList.add(`style-${r}`),N.classList.add(`bg-${a}`),N.classList.add(`accent-${l}`)):(N.classList.add(`style-${u}`),N.classList.add(`bg-${f}`),N.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const v=()=>n(N=>N==="dark"?"light":"dark"),y=N=>n(N),b=N=>{i(N),localStorage.setItem("dark-style",N),Se.updateSettings({dark_style:N}).catch(()=>{})},E=N=>{s(N),localStorage.setItem("dark-background",N),Se.updateSettings({dark_background:N}).catch(()=>{})},w=N=>{c(N),localStorage.setItem("dark-accent",N),Se.updateSettings({dark_accent:N}).catch(()=>{})},T=N=>{d(N),localStorage.setItem("light-style",N),Se.updateSettings({light_style:N}).catch(()=>{})},A=N=>{g(N),localStorage.setItem("light-background",N),Se.updateSettings({light_background:N}).catch(()=>{})},C=N=>{x(N),localStorage.setItem("light-accent",N),Se.updateSettings({light_accent:N}).catch(()=>{})};return o.jsx(qG.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:v,setMode:y,setDarkStyle:b,setDarkBackground:E,setDarkAccent:w,setLightStyle:T,setLightBackground:A,setLightAccent:C},children:t})}function ag(){const t=M.useContext(qG);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function wt({children:t,className:e="",onClick:n,onContextMenu:r}){return o.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,children:t})}function Ii({children:t,className:e=""}){return o.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Et({children:t,className:e=""}){return o.jsx("div",{className:`p-6 ${e}`,children:t})}function Tde(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 MU({children:t}){return o.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 Ade({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=eg(),i=Tde(n,e,r);return M.useEffect(()=>{const a=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:o.jsx(wt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:o.jsxs(Et,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Xk,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),o.jsx("div",{className:"space-y-2",children:a.items.map(s=>o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[s.description,s.isExternal&&o.jsx(ba,{className:"w-3 h-3 text-bambu-gray"})]}),o.jsx("div",{className:"flex gap-1",children:s.keys.map(l=>o.jsx(MU,{children:l},l))})]},s.description))})]},a.category))}),o.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:o.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",o.jsx(MU,{children:"Esc"})," or click outside to close"]})})]})})})}function ke({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"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return o.jsx("button",{className:`${a} ${s[t]} ${l[e]} ${n}`,...i,children:r})}function kr({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:s}){M.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 o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:o.jsx(wt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:o.jsxs(Et,{className:"p-6",children:[o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:o.jsx(Gn,{className:"w-6 h-6"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),o.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),o.jsxs("div",{className:"flex gap-3 mt-6",children:[o.jsx(ke,{variant:"secondary",onClick:s,className:"flex-1",children:r}),o.jsx(ke,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}function Nde({plug:t}){const e=mn(),[n,r]=M.useState(null),{data:i,isLoading:a}=gt({queryKey:["smart-plug-status",t.id],queryFn:()=>Se.getSmartPlugStatus(t.id),refetchInterval:1e4}),s=vt({mutationFn:f=>Se.controlSmartPlug(t.id,f),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=i?.reachable??!1,u=s.isPending,d=()=>{n&&(s.mutate(n),r(null))};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:`p-1.5 rounded ${c?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:o.jsx(lo,{className:`w-4 h-4 ${c?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),o.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?o.jsx(xt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?o.jsxs(o.Fragment,{children:[o.jsx(bR,{className:"w-3 h-3 text-bambu-green"}),o.jsx("span",{className:l?"text-bambu-green":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),o.jsx(ef,{className:"w-3 h-3 text-yellow-400"}),o.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ab,{className:"w-3 h-3 text-red-400"}),o.jsx("span",{className:"text-red-400",children:"Offline"})]})})]})]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx("button",{onClick:()=>r("on"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:u?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(kl,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>r("off"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${!l&&c?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:u?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(JS,{className:"w-4 h-4"})})]})]}),n&&o.jsx(kr,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:d,onCancel:()=>r(null)})]})}function EU({onClose:t}){const{data:e,isLoading:n}=gt({queryKey:["smart-plugs"],queryFn:Se.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return o.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[o.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:o.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[o.jsx(lo,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),o.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?o.jsxs("div",{className:"text-center py-6 px-4",children:[o.jsx(lo,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):o.jsx("div",{className:"space-y-1",children:r.map(i=>o.jsx(Nde,{plug:i},i.id))})})]})}const KG=[{name:"globe",icon:k0},{name:"link",icon:Tb},{name:"external-link",icon:ba},{name:"book",icon:Doe},{name:"file-text",icon:Es},{name:"home",icon:oce},{name:"star",icon:Tp},{name:"heart",icon:ice},{name:"bookmark",icon:Loe},{name:"shopping-cart",icon:UG},{name:"music",icon:Jk},{name:"video",icon:WG},{name:"image",icon:Eb},{name:"camera",icon:C0},{name:"map",icon:jce},{name:"compass",icon:xle},{name:"coffee",icon:fle},{name:"gift",icon:Zle},{name:"wrench",icon:gd},{name:"zap",icon:ef},{name:"cloud",icon:XS},{name:"database",icon:wp},{name:"folder",icon:LG},{name:"mail",icon:kce},{name:"phone",icon:rue},{name:"user",icon:e3},{name:"users",icon:lde},{name:"server",icon:dh},{name:"terminal",icon:HG},{name:"code",icon:DG}];function nM(t){return KG.find(n=>n.name===t)?.icon||Tb}function Cde({value:t,onChange:e}){const[n,r]=M.useState(!1),i=nM(t);return o.jsxs("div",{className:"relative",children:[o.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:[o.jsx(i,{className:"w-5 h-5"}),o.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),o.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:o.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:KG.map(({name:a,icon:s})=>o.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:o.jsx(s,{className:"w-5 h-5"})},a))})})]})]})}const TU=768;function XG(){const[t,e]=M.useState(()=>typeof window<"u"?window.innerWidth<TU:!1);return M.useEffect(()=>{const n=window.matchMedia(`(max-width: ${TU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const R0=[{id:"printers",to:"/",icon:Vi,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:oo,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Qr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Goe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:XS,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:gd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Uo,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:xR,labelKey:"nav.settings"}];function kde(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return R0.map(e=>e.id)}return R0.map(e=>e.id)}function Pde(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function WT(t){return t.startsWith("ext-")}function YG(){return localStorage.getItem("defaultView")||"/"}function jde(t){localStorage.setItem("defaultView",t)}function Rde(){const t=wb(),e=Nd(),{mode:n,toggleMode:r}=ag(),{t:i}=eg(),a=XG(),[s,l]=M.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=M.useState(!1),[d,f]=M.useState(!1),[g,p]=M.useState(!1),[x,v]=M.useState(kde),[y,b]=M.useState(null),[E,w]=M.useState(null),T=M.useRef(!1),[A,C]=M.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:N}=gt({queryKey:["version"],queryFn:Se.getVersion,staleTime:1/0}),{data:F}=gt({queryKey:["settings"],queryFn:Se.getSettings,staleTime:300*1e3}),{data:k}=gt({queryKey:["updateCheck"],queryFn:Se.checkForUpdates,enabled:F?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:R}=gt({queryKey:["external-links"],queryFn:Se.getExternalLinks}),{data:I}=gt({queryKey:["smart-plugs"],queryFn:Se.getSmartPlugs,staleTime:30*1e3}),L=I?.some(te=>te.show_in_switchbar)??!1,q=new Map(R0.map(te=>[te.id,te])),j=new Map((R||[]).map(te=>[`ext-${te.id}`,te])),V=(()=>{const te=[],he=new Set;for(const oe of x)(q.has(oe)||j.has(oe))&&(te.push(oe),he.add(oe));for(const oe of R0)he.has(oe.id)||(te.push(oe.id),he.add(oe.id));for(const oe of R||[]){const xe=`ext-${oe.id}`;he.has(xe)||(te.push(xe),he.add(xe))}return te})(),K=(te,he)=>{b(he),te.dataTransfer.effectAllowed="move",te.dataTransfer.setData("text/plain",he)},W=(te,he)=>{te.preventDefault(),te.dataTransfer.dropEffect="move",w(he)},J=()=>{w(null)},ee=(te,he)=>{if(te.preventDefault(),y===null||y===he){b(null),w(null);return}const oe=[...V],xe=oe.indexOf(y),Te=oe.indexOf(he);if(xe===-1||Te===-1){b(null),w(null);return}oe.splice(xe,1),oe.splice(Te,0,y),v(oe),Pde(oe),b(null),w(null)},Z=()=>{b(null),w(null)},B=k?.update_available&&k.latest_version&&k.latest_version!==A,G=()=>{k?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",k.latest_version),C(k.latest_version))};M.useEffect(()=>{if(!T.current&&e.pathname==="/"){const te=YG();te!=="/"&&(T.current=!0,t(te,{replace:!0}))}},[e.pathname,t]),M.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]),M.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const Q=M.useCallback(te=>{const he=te.target;if(!(he.tagName==="INPUT"||he.tagName==="TEXTAREA"||he.isContentEditable)&&!te.metaKey&&!te.ctrlKey&&!te.altKey){const oe=parseInt(te.key);if(oe>=1&&oe<=V.length&&oe<=9){const xe=V[oe-1];if(te.preventDefault(),WT(xe)){const Te=xe.replace("ext-","");t(`/external/${Te}`)}else{const Te=q.get(xe);Te&&t(Te.to)}return}switch(te.key){case"?":te.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,V,q]);return M.useEffect(()=>(document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)),[Q]),o.jsxs("div",{className:"flex min-h-screen",children:[a&&o.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:[o.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:o.jsx(zce,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&c&&o.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),o.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:[o.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||s?"p-4":"p-2"}`,children:o.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"})}),o.jsx("nav",{className:"flex-1 p-2",children:o.jsx("ul",{className:"space-y-2",children:V.map(te=>{if(WT(te)){const oe=j.get(te);if(!oe)return null;const xe=oe.custom_icon?null:nM(oe.icon);return o.jsx("li",{draggable:!0,onDragStart:Te=>K(Te,te),onDragOver:Te=>W(Te,te),onDragLeave:J,onDrop:Te=>ee(Te,te),onDragEnd:Z,className:`relative ${y===te?"opacity-50":""} ${E===te&&y!==te?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:o.jsxs($x,{to:`/external/${oe.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?oe.name:void 0,children:[s&&!a&&o.jsx(P0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),oe.custom_icon?o.jsx("img",{src:`/api/v1/external-links/${oe.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):xe&&o.jsx(xe,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&o.jsx("span",{children:oe.name})]})},te)}else{const oe=q.get(te);if(!oe)return null;const{to:xe,icon:Te,labelKey:me}=oe;return o.jsx("li",{draggable:!0,onDragStart:ce=>K(ce,te),onDragOver:ce=>W(ce,te),onDragLeave:J,onDrop:ce=>ee(ce,te),onDragEnd:Z,className:`relative ${y===te?"opacity-50":""} ${E===te&&y!==te?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:o.jsxs($x,{to:xe,className:({isActive:ce})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ce?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?i(me):void 0,children:[s&&!a&&o.jsx(P0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),o.jsx(Te,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&o.jsx("span",{children:i(me)})]})},te)}})})}),!a&&o.jsx("button",{onClick:()=>l(!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?o.jsx(Yh,{className:"w-5 h-5"}):o.jsx(Xc,{className:"w-5 h-5"})}),o.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||s?o.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[o.jsxs("div",{className:"flex items-center justify-center gap-1",children:[L&&o.jsxs("div",{className:"relative",children:[o.jsx("button",{onMouseEnter:()=>p(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${g?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:o.jsx(lo,{className:"w-5 h-5"})}),g&&o.jsx(EU,{onClose:()=>p(!1)})]}),o.jsx($x,{to:"/system",className:({isActive:te})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${te?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:o.jsx(Sp,{className:"w-5 h-5"})}),o.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:o.jsx(vU,{className:"w-5 h-5"})}),o.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:o.jsx(Xk,{className:"w-5 h-5"})}),o.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"?o.jsx(SU,{className:"w-5 h-5"}):o.jsx(z1,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",N?.version||"..."]}),k?.update_available&&o.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:k.latest_version}),children:[o.jsx(VT,{className:"w-4 h-4"}),o.jsx("span",{children:i("nav.update")})]})]})]}):o.jsxs("div",{className:"flex flex-col items-center gap-1",children:[k?.update_available&&o.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:k.latest_version}),children:o.jsx(VT,{className:"w-5 h-5"})}),L&&o.jsxs("div",{className:"relative",children:[o.jsx("button",{onMouseEnter:()=>p(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${g?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:o.jsx(lo,{className:"w-5 h-5"})}),g&&o.jsx(EU,{onClose:()=>p(!1)})]}),o.jsx($x,{to:"/system",className:({isActive:te})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${te?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:o.jsx(Sp,{className:"w-5 h-5"})}),o.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:o.jsx(vU,{className:"w-5 h-5"})}),o.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:o.jsx(Xk,{className:"w-5 h-5"})}),o.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"?o.jsx(SU,{className:"w-5 h-5"}):o.jsx(z1,{className:"w-5 h-5"})})]})})]}),o.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":s?"ml-64":"ml-16"}`,children:[B&&o.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx(VT,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{children:i("nav.updateAvailableBanner",{version:k?.latest_version,defaultValue:`Version ${k?.latest_version} is available!`})}),o.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),o.jsx("button",{onClick:G,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:o.jsx(Gt,{className:"w-4 h-4"})})]}),o.jsx(tse,{})]}),d&&o.jsx(Ade,{onClose:()=>f(!1),sidebarItems:V.map(te=>{if(WT(te)){const he=j.get(te);return he?{type:"external",label:he.name}:null}else{const he=q.get(te);return he?{type:"nav",label:he.labelKey,labelKey:he.labelKey}:null}}).filter(Boolean)})]})}const ZG=M.createContext(void 0);function Sr(){const t=M.useContext(ZG);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Dde={success:o.jsx(Cr,{className:"w-5 h-5 text-green-400"}),error:o.jsx(Pa,{className:"w-5 h-5 text-red-400"}),warning:o.jsx(mo,{className:"w-5 h-5 text-yellow-400"}),info:o.jsx(Sp,{className:"w-5 h-5 text-blue-400"}),loading:o.jsx(xt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Ode={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 Lde({children:t}){const[e,n]=M.useState([]),r=M.useCallback((s,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:s,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=M.useCallback((s,l,c="info")=>{n(u=>u.find(f=>f.id===s)?u.map(f=>f.id===s?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:s,message:l,type:c,persistent:!0}])},[]),a=M.useCallback(s=>{n(l=>l.filter(c=>c.id!==s))},[]);return o.jsxs(ZG.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,o.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>o.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Ode[s.type]}`,children:[Dde[s.type],o.jsx("span",{className:"text-white text-sm",children:s.message}),o.jsx("button",{onClick:()=>a(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-4 h-4"})})]},s.id))})]})}function Ide(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 AU(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 Fde(t,e){if(e)return LG;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return OG;case"gcode":return Es;case"mp4":case"avi":return Rh;case"png":case"jpg":case"jpeg":return Eb;default:return uR}}function Ude({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Sr(),i=mn(),[a,s]=M.useState("/"),[l,c]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(null);M.useEffect(()=>{const N=F=>{F.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const{data:p,isLoading:x,refetch:v}=gt({queryKey:["printerFiles",t,a],queryFn:()=>Se.getPrinterFiles(t,a)}),{data:y}=gt({queryKey:["printerStorage",t],queryFn:()=>Se.getPrinterStorage(t),staleTime:3e4}),b=vt({mutationFn:N=>Se.deletePrinterFile(t,N),onSuccess:(N,F)=>{r(`Deleted: ${F.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:N=>{r(`Delete failed: ${N.message}`,"error")}}),E=N=>{s(N),c(null)},w=()=>{if(a==="/")return;const N=a.split("/").filter(Boolean);N.pop(),s(N.length?"/"+N.join("/"):"/"),c(null)},T=N=>{window.open(Se.getPrinterFileDownloadUrl(t,N),"_blank")},A=N=>{g(N)},C=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[o.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:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(hR,{className:"w-5 h-5 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[y&&(y.used_bytes!=null||y.free_bytes!=null)&&o.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[y.used_bytes!=null&&o.jsxs("span",{children:["Used: ",AU(y.used_bytes)]}),y.used_bytes!=null&&y.free_bytes!=null&&o.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),y.free_bytes!=null&&o.jsxs("span",{children:["Free: ",AU(y.free_bytes)]})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[C.map(N=>o.jsx("button",{onClick:()=>{E(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)),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"relative",children:[o.jsx(bl,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.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"})]}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:x,children:o.jsx(_a,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[o.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:o.jsx(Yh,{className:"w-4 h-4"})}),o.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p?.files?.length?o.jsx("div",{className:"space-y-1",children:[...p.files].filter(N=>!u||N.name.toLowerCase().includes(u.toLowerCase())).sort((N,F)=>N.is_directory&&!F.is_directory?-1:!N.is_directory&&F.is_directory?1:N.name.localeCompare(F.name)).map(N=>{const F=Fde(N.name,N.is_directory),k=l===N.path;return o.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${k?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{N.is_directory?E(N.path):c(k?null:N.path)},children:[o.jsx(F,{className:`w-5 h-5 flex-shrink-0 ${N.is_directory?"text-bambu-green":"text-bambu-gray"}`}),o.jsx("span",{className:"flex-1 text-white truncate",children:N.name}),!N.is_directory&&o.jsx("span",{className:"text-sm text-bambu-gray",children:Ide(N.size)}),N.is_directory&&o.jsx(Yh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[o.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${p?.files?.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${p?.files?.length||0} items`:`${p?.files?.length||0} items`}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{variant:"secondary",disabled:!l,onClick:()=>l&&T(l),children:[o.jsx(is,{className:"w-4 h-4"}),"Download"]}),o.jsxs(ke,{variant:"secondary",disabled:!l||b.isPending,onClick:()=>l&&A(l),className:"text-red-400 hover:text-red-300",children:[b.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&o.jsx(kr,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{b.mutate(f),g(null)},onCancel:()=>g(null)})]})}function zde({printerId:t,printerName:e,onClose:n}){const r=mn(),[i,a]=M.useState(!0),[s,l]=M.useState(new Set),[c,u]=M.useState(""),[d,f]=M.useState("all"),g=M.useRef(null),{data:p,isLoading:x,refetch:v}=gt({queryKey:["mqtt-logs",t],queryFn:()=>Se.getMQTTLogs(t),refetchInterval:1e3}),y=vt({mutationFn:()=>Se.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=vt({mutationFn:()=>Se.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=vt({mutationFn:()=>Se.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});M.useEffect(()=>{const k=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]),M.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[p?.logs,i]);const w=k=>{l(R=>{const I=new Set(R);return I.has(k)?I.delete(k):I.add(k),I})},T=k=>new Date(k).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(k,R)=>{if(k==null)return"<empty>";const I=typeof k=="string"?JSON.parse(k):k,L=JSON.stringify(I,null,R?2:0);return!R&&L.length>100?L.substring(0,100)+"...":L},C=p?.logging_enabled??!1,N=p?.logs??[],F=M.useMemo(()=>N.filter(k=>{if(d!=="all"&&k.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),I=k.topic.toLowerCase().includes(R),q=JSON.stringify(k.payload).toLowerCase().includes(R);return I||q}return!0}),[N,c,d]);return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[C?o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[o.jsx(Ep,{className:"w-4 h-4"}),"Stop"]}):o.jsxs(ke,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[o.jsx(Mp,{className:"w-4 h-4"}),"Start Logging"]}),o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||N.length===0,children:[o.jsx(En,{className:"w-4 h-4"}),"Clear"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:x,children:o.jsx(_a,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),o.jsx("div",{className:"flex-1"}),o.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:i,onChange:k=>a(k.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),o.jsxs("span",{className:"text-sm text-bambu-gray",children:[F.length,"/",N.length]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(bl,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:k=>u(k.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&o.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:o.jsx(Gt,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[o.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"}),o.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:[o.jsx(N0,{className:"w-3 h-3"}),"In"]}),o.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:[o.jsx(vp,{className:"w-3 h-3"}),"Out"]})]})]})]}),o.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:N.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[o.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!C&&o.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):F.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[o.jsx("p",{className:"mb-2",children:"No messages match your filter"}),o.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):o.jsx("div",{className:"space-y-1",children:F.map((k,R)=>{const I=s.has(R),L=k.direction==="in";return o.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${I?"bg-bambu-dark-secondary":""}`,onClick:()=>w(R),children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"text-bambu-gray shrink-0",children:T(k.timestamp)}),o.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?o.jsx(N0,{className:"w-3 h-3"}):o.jsx(vp,{className:"w-3 h-3"})}),o.jsx("span",{className:"text-purple-400 shrink-0",children:k.topic})]}),I?o.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:A(k.payload,!0)}):o.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(k.payload,!1)})]},R)})})}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[o.jsx("div",{className:"text-sm text-bambu-gray",children:C?o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):o.jsx("span",{children:"Logging stopped"})}),o.jsx(ke,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const n3={"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 Bde(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Gn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Gn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:mo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Sp}}}function r3(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 Hde(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=r3(e.attr,n);return n3[r]!==void 0})}function $de(){return"https://wiki.bambulab.com/en/hms/home"}function Vde({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=r3(i.attr,a);return n3[s]!==void 0});return M.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Gn,{className:"w-5 h-5 text-orange-400"}),o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),o.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(mo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{children:"No errors"})]}):o.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:s,color:l,bgColor:c,Icon:u}=Bde(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=r3(i.attr,d),g=n3[f],p=$de(),x=f.replace("_","-");return o.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",x,"]"]}),o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:s})]}),o.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g}),o.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[o.jsx(ba,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),o.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:o.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function Gde(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 Wde({printerId:t}){const{data:e}=gt({queryKey:["queue",t,"pending"],queryFn:()=>Se.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:o.jsx(_c,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx(Qr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),o.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[o.jsx(rr,{className:"w-3 h-3"}),Gde(n?.scheduled_time||null)]}),r>1&&o.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),o.jsx(Xc,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function QG(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=QG(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Cn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=QG(t))&&(r&&(r+=" "),r+=e);return r}var qde=["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=qde;return e.includes(t)}var Kde=["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"],Xde=new Set(Kde);function JG(t){return typeof t!="string"?!1:Xde.has(t)}function eW(t){return typeof t=="string"&&t.startsWith("data-")}function Oa(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(JG(n)||eW(n))&&(e[n]=t[n]);return e}function tf(t){if(t==null)return null;if(M.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Oa(e)}return typeof t=="object"&&!Array.isArray(t)?Oa(t):null}function la(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(JG(n)||eW(n)||yR(n))&&(e[n]=t[n]);return e}function Yde(t){return t==null?null:M.isValidElement(t)?la(t.props):typeof t=="object"&&!Array.isArray(t)?la(t):null}var Zde=["children","width","height","viewBox","className","style","title","desc"];function i3(){return i3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i3.apply(null,arguments)}function Qde(t,e){if(t==null)return{};var n,r,i=Jde(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 Jde(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 vR=M.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:l,title:c,desc:u}=t,d=Qde(t,Zde),f=a||{width:r,height:i,x:0,y:0},g=Cn("recharts-surface",s);return M.createElement("svg",i3({},la(d),{className:g,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),M.createElement("title",null,c),M.createElement("desc",null,u),n)}),ehe=["children","className"];function a3(){return a3=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},a3.apply(null,arguments)}function the(t,e){if(t==null)return{};var n,r,i=nhe(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 nhe(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 jr=M.forwardRef((t,e)=>{var{children:n,className:r}=t,i=the(t,ehe),a=Cn("recharts-layer",r);return M.createElement("g",a3({className:a},la(i),{ref:e}),n)}),tW=M.createContext(null),rhe=()=>M.useContext(tW);function ur(t){return function(){return t}}const nW=Math.cos,H1=Math.sin,Wo=Math.sqrt,$1=Math.PI,rM=2*$1,s3=Math.PI,o3=2*s3,hh=1e-6,ihe=o3-hh;function rW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function ahe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return rW;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 she{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?rW:ahe(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,l=this._y1,c=r-e,u=i-n,d=s-e,f=l-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>hh)if(!(Math.abs(f*c-u*d)>hh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-s,x=i-l,v=c*c+u*u,y=p*p+x*x,b=Math.sqrt(v),E=Math.sqrt(g),w=a*Math.tan((s3-Math.acos((v+g-y)/(2*b*E)))/2),T=w/E,A=w/b;Math.abs(T-1)>hh&&this._append`L${e+T*d},${n+T*f}`,this._append`A${a},${a},0,0,${+(f*p>d*x)},${this._x1=e+A*c},${this._y1=n+A*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 l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,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)>hh||Math.abs(this._y1-d)>hh)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%o3+o3),g>ihe?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>hh&&this._append`A${r},${r},0,${+(g>=s3)},${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 _R(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 she(e)}function wR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function iW(t){this._context=t}iW.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 iM(t){return new iW(t)}function aW(t){return t[0]}function sW(t){return t[1]}function oW(t,e){var n=ur(!0),r=null,i=iM,a=null,s=_R(l);t=typeof t=="function"?t:t===void 0?aW:ur(t),e=typeof e=="function"?e:e===void 0?sW:ur(e);function l(c){var u,d=(c=wR(c)).length,f,g=!1,p;for(r==null&&(a=i(p=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(p)return a=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:ur(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:ur(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:ur(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function Av(t,e,n){var r=null,i=ur(!0),a=null,s=iM,l=null,c=_R(u);t=typeof t=="function"?t:t===void 0?aW:ur(+t),e=typeof e=="function"?e:ur(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?sW:ur(+n);function u(f){var g,p,x,v=(f=wR(f)).length,y,b=!1,E,w=new Array(v),T=new Array(v);for(a==null&&(l=s(E=c())),g=0;g<=v;++g){if(!(g<v&&i(y=f[g],g,f))===b)if(b=!b)p=g,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=g-1;x>=p;--x)l.point(w[x],T[x]);l.lineEnd(),l.areaEnd()}b&&(w[g]=+t(y,g,f),T[g]=+e(y,g,f),l.point(r?+r(y,g,f):w[g],n?+n(y,g,f):T[g]))}if(E)return l=null,E+""||null}function d(){return oW().defined(i).curve(s).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:ur(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:ur(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:ur(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:ur(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:ur(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:ur(+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:ur(!!f),u):i},u.curve=function(f){return arguments.length?(s=f,a!=null&&(l=s(a)),u):s},u.context=function(f){return arguments.length?(f==null?a=l=null:l=s(a=f),u):a},u}class lW{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 ohe(t){return new lW(t,!0)}function lhe(t){return new lW(t,!1)}const SR={draw(t,e){const n=Wo(e/$1);t.moveTo(n,0),t.arc(0,0,n,0,rM)}},che={draw(t,e){const n=Wo(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()}},cW=Wo(1/3),uhe=cW*2,dhe={draw(t,e){const n=Wo(e/uhe),r=n*cW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},hhe={draw(t,e){const n=Wo(e),r=-n/2;t.rect(r,r,n,n)}},fhe=.8908130915292852,uW=H1($1/10)/H1(7*$1/10),mhe=H1(rM/10)*uW,phe=-nW(rM/10)*uW,ghe={draw(t,e){const n=Wo(e*fhe),r=mhe*n,i=phe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=rM*a/5,l=nW(s),c=H1(s);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},qT=Wo(3),xhe={draw(t,e){const n=-Wo(e/(qT*3));t.moveTo(0,n*2),t.lineTo(-qT*n,-n),t.lineTo(qT*n,-n),t.closePath()}},Hs=-.5,$s=Wo(3)/2,l3=1/Wo(12),bhe=(l3/2+1)*3,yhe={draw(t,e){const n=Wo(e/bhe),r=n/2,i=n*l3,a=r,s=n*l3+n,l=-a,c=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(l,c),t.lineTo(Hs*r-$s*i,$s*r+Hs*i),t.lineTo(Hs*a-$s*s,$s*a+Hs*s),t.lineTo(Hs*l-$s*c,$s*l+Hs*c),t.lineTo(Hs*r+$s*i,Hs*i-$s*r),t.lineTo(Hs*a+$s*s,Hs*s-$s*a),t.lineTo(Hs*l+$s*c,Hs*c-$s*l),t.closePath()}};function vhe(t,e){let n=null,r=_R(i);t=typeof t=="function"?t:ur(t||SR),e=typeof e=="function"?e:ur(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:ur(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:ur(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function V1(){}function G1(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 dW(t){this._context=t}dW.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:G1(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:G1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function _he(t){return new dW(t)}function hW(t){this._context=t}hW.prototype={areaStart:V1,areaEnd:V1,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:G1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function whe(t){return new hW(t)}function fW(t){this._context=t}fW.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:G1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function She(t){return new fW(t)}function mW(t){this._context=t}mW.prototype={areaStart:V1,areaEnd:V1,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 Mhe(t){return new mW(t)}function NU(t){return t<0?-1:1}function CU(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),l=(a*i+s*r)/(r+i);return(NU(a)+NU(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(l))||0}function kU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function KT(t,e,n){var r=t._x0,i=t._y0,a=t._x1,s=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,s-l*n,a,s)}function W1(t){this._context=t}W1.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:KT(this,this._t0,kU(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,KT(this,kU(this,n=CU(this,t,e)),n);break;default:KT(this,this._t0,n=CU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function pW(t){this._context=new gW(t)}(pW.prototype=Object.create(W1.prototype)).point=function(t,e){W1.prototype.point.call(this,e,t)};function gW(t){this._context=t}gW.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 Ehe(t){return new W1(t)}function The(t){return new pW(t)}function xW(t){this._context=t}xW.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=PU(t),i=PU(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 PU(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 Ahe(t){return new xW(t)}function aM(t,e){this._context=t,this._t=e}aM.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 Nhe(t){return new aM(t,.5)}function Che(t){return new aM(t,0)}function khe(t){return new aM(t,1)}function Np(t,e){if((s=t.length)>1)for(var n=1,r,i,a=t[e[0]],s,l=a.length;n<s;++n)for(i=a,a=t[e[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function c3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Phe(t,e){return t[e]}function jhe(t){const e=[];return e.key=t,e}function Rhe(){var t=ur([]),e=c3,n=Np,r=Phe;function i(a){var s=Array.from(t.apply(this,arguments),jhe),l,c=s.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(s[l][u]=[0,+r(f,s[l].key,u,a)]).data=f;for(l=0,d=wR(e(s));l<c;++l)s[d[l]].index=l;return n(s,d),s}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:ur(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:ur(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?c3:typeof a=="function"?a:ur(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Np,i):n},i}function Dhe(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}Np(t,e)}}function Ohe(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,l=0;s<i;++s)l+=t[s][n][1]||0;r[n][1]+=r[n][0]=-l/2}Np(t,e)}}function Lhe(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 l=0,c=0,u=0;l<s;++l){for(var d=t[e[l]],f=d[r][1]||0,g=d[r-1][1]||0,p=(f-g)/2,x=0;x<l;++x){var v=t[e[x]],y=v[r][1]||0,b=v[r-1][1]||0;p+=y-b}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Np(t,e)}}var XT={},YT={},jU;function Ihe(){return jU||(jU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(YT)),YT}var ZT={},RU;function bW(){return RU||(RU=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})(ZT)),ZT}var QT={},DU;function MR(){return DU||(DU=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})(QT)),QT}var JT={},eA={},OU;function Fhe(){return OU||(OU=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})(eA)),eA}var LU;function ER(){return LU||(LU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fhe(),n=MR();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 l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<s;){const f=i[l];u?f==="\\"&&l+1<s?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(JT)),JT}var IU;function TR(){return IU||(IU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ihe(),n=bW(),r=MR(),i=ER();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return s(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function s(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(XT)),XT}var tA,FU;function Uhe(){return FU||(FU=1,tA=TR().get),tA}var zhe=Uhe();const nf=bo(zhe);var Bi=t=>t===0?0:t>0?1:-1,as=t=>typeof t=="number"&&t!=+t,zc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,jt=t=>(typeof t=="number"||t instanceof Number)&&!as(t),po=t=>jt(t)||typeof t=="string",Bhe=0,D0=t=>{var e=++Bhe;return"".concat(t||"").concat(e)},va=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(!jt(e)&&typeof e!="string")return r;var a;if(zc(e)){if(n==null)return r;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return as(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},yW=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 Un(t,e,n){return jt(t)&&jt(e)?t+n*(e-t):e}function vW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):nf(r,e))===n)}var xr=t=>t===null||typeof t>"u",Nb=t=>xr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Hhe(t){return t!=null}function Cb(){}var $he=["type","size","sizeType"];function u3(){return u3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},u3.apply(null,arguments)}function UU(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 zU(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UU(Object(n),!0).forEach(function(r){Vhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vhe(t,e,n){return(e=Ghe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ghe(t){var e=Whe(t,"string");return typeof e=="symbol"?e:e+""}function Whe(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 qhe(t,e){if(t==null)return{};var n,r,i=Khe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Khe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var _W={symbolCircle:SR,symbolCross:che,symbolDiamond:dhe,symbolSquare:hhe,symbolStar:ghe,symbolTriangle:xhe,symbolWye:yhe},Xhe=Math.PI/180,Yhe=t=>{var e="symbol".concat(Nb(t));return _W[e]||SR},Zhe=(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*Xhe;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}},Qhe=(t,e)=>{_W["symbol".concat(Nb(t))]=e},AR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=qhe(t,$he),a=zU(zU({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var l=()=>{var g=Yhe(s),p=vhe().type(g).size(Zhe(n,r,s)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=la(a);return jt(u)&&jt(d)&&jt(n)?M.createElement("path",u3({},f,{className:Cn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};AR.registerSymbol=Qhe;var wW=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,NR=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(M.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},Jhe=(t,e,n)=>r=>(t(e,n,r),null),kb=(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]=Jhe(a,e,n))}),r};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 efe(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){tfe(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 tfe(t,e,n){return(e=nfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nfe(t){var e=rfe(t,"string");return typeof e=="symbol"?e:e+""}function rfe(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 Rr(t,e){var n=efe({},t),r=e,i=Object.keys(e),a=i.reduce((s,l)=>(s[l]===void 0&&r[l]!==void 0&&(s[l]=r[l]),s),n);return a}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 HU(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 ife(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HU(Object(n),!0).forEach(function(r){afe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function afe(t,e,n){return(e=sfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sfe(t){var e=ofe(t,"string");return typeof e=="symbol"?e:e+""}function ofe(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 Ks=32,lfe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function cfe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Ks/2,a=Ks/6,s=Ks/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return M.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Ks,y2:i,className:"recharts-legend-icon"})}if(c==="line")return M.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(s,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
- H`).concat(Ks,"M").concat(2*s,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return M.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(Ks/8,"h").concat(Ks,"v").concat(Ks*3/4,"h").concat(-Ks,"z"),className:"recharts-legend-icon"});if(M.isValidElement(e.legendIcon)){var d=ife({},e);return delete d.legendIcon,M.cloneElement(e.legendIcon,d)}return M.createElement(AR,{fill:l,cx:i,cy:i,size:Ks,sizeType:"diameter",type:c})}function ufe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,l={x:0,y:0,width:Ks,height:Ks},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,p=Cn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,v=g?g(d.value,d,f):d.value;return M.createElement("li",q1({className:p,style:c,key:"legend-item-".concat(f)},kb(t,d,f)),M.createElement(vR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(v," legend icon")},M.createElement(cfe,{data:d,iconType:s,inactiveColor:a})),M.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v))})}var dfe=t=>{var e=Rr(t,lfe),{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 M.createElement("ul",{className:"recharts-default-legend",style:a},M.createElement(ufe,q1({},e,{payload:n})))},nA={},rA={},$U;function hfe(){return $U||($U=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],l=r(s);i.has(l)||i.set(l,s)}return Array.from(i.values())}t.uniqBy=e})(rA)),rA}var iA={},VU;function SW(){return VU||(VU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(iA)),iA}var aA={},sA={},oA={},GU;function ffe(){return GU||(GU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(oA)),oA}var WU;function CR(){return WU||(WU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ffe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(sA)),sA}var lA={},qU;function mfe(){return qU||(qU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(lA)),lA}var KU;function pfe(){return KU||(KU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CR(),n=mfe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(aA)),aA}var cA={},uA={},XU;function gfe(){return XU||(XU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=TR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(uA)),uA}var dA={},hA={},fA={},mA={},YU;function MW(){return YU||(YU=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})(mA)),mA}var pA={},ZU;function EW(){return ZU||(ZU=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})(pA)),pA}var gA={},QU;function TW(){return QU||(QU=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})(gA)),gA}var JU;function xfe(){return JU||(JU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MW(),n=EW(),r=TW();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function p(x,v,y,b,E,w){const T=g(x,v,y,b,E,w);return T!==void 0?!!T:a(x,v,p,w)},new Map)}function a(d,f,g,p){if(f===d)return!0;switch(typeof f){case"object":return s(d,f,g,p);case"function":return Object.keys(f).length>0?a(d,{...f},g,p):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function s(d,f,g,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,g,p);if(f instanceof Map)return l(d,f,g,p);if(f instanceof Set)return u(d,f,g,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let v=0;v<x.length;v++){const y=x[v];if(!n.isPrimitive(d)&&!(y in d)||f[y]===void 0&&d[y]!==void 0||f[y]===null&&d[y]!==null||!g(d[y],f[y],y,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,g,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,v]of f.entries()){const y=d.get(x);if(g(y,v,x,d,f,p)===!1)return!1}return!0}function c(d,f,g,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let v=0;v<f.length;v++){const y=f[v];let b=!1;for(let E=0;E<d.length;E++){if(x.has(E))continue;const w=d[E];let T=!1;if(g(w,y,v,d,f,p)&&(T=!0),T){x.add(E),b=!0;break}}if(!b)return!1}return!0}function u(d,f,g,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],g,p):!1}t.isMatchWith=i,t.isSetMatch=u})(fA)),fA}var ez;function AW(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xfe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(hA)),hA}var xA={},bA={},yA={},tz;function bfe(){return tz||(tz=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})(yA)),yA}var vA={},nz;function NW(){return nz||(nz=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})(vA)),vA}var _A={},rz;function CW(){return rz||(rz=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]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",p="[object Object]",x="[object Error]",v="[object DataView]",y="[object Uint8Array]",b="[object Uint8ClampedArray]",E="[object Uint16Array]",w="[object Uint32Array]",T="[object BigUint64Array]",A="[object Int8Array]",C="[object Int16Array]",N="[object Int32Array]",F="[object BigInt64Array]",k="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=F,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=v,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=k,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=N,t.int8ArrayTag=A,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=E,t.uint32ArrayTag=w,t.uint8ArrayTag=y,t.uint8ClampedArrayTag=b})(_A)),_A}var wA={},iz;function yfe(){return iz||(iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(wA)),wA}var az;function kW(){return az||(az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bfe(),n=NW(),r=CW(),i=EW(),a=yfe();function s(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,g,p=new Map,x=void 0){const v=x?.(d,f,g,p);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const y=new Array(d.length);p.set(d,y);for(let b=0;b<d.length;b++)y[b]=l(d[b],b,g,p,x);return Object.hasOwn(d,"index")&&(y.index=d.index),Object.hasOwn(d,"input")&&(y.input=d.input),y}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const y=new RegExp(d.source,d.flags);return y.lastIndex=d.lastIndex,y}if(d instanceof Map){const y=new Map;p.set(d,y);for(const[b,E]of d)y.set(b,l(E,b,g,p,x));return y}if(d instanceof Set){const y=new Set;p.set(d,y);for(const b of d)y.add(l(b,void 0,g,p,x));return y}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const y=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,y);for(let b=0;b<d.length;b++)y[b]=l(d[b],b,g,p,x);return y}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const y=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,y),c(y,d,g,p,x),y}if(typeof File<"u"&&d instanceof File){const y=new File([d],d.name,{type:d.type});return p.set(d,y),c(y,d,g,p,x),y}if(typeof Blob<"u"&&d instanceof Blob){const y=new Blob([d],{type:d.type});return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof Error){const y=new d.constructor;return p.set(d,y),y.message=d.message,y.name=d.name,y.stack=d.stack,y.cause=d.cause,c(y,d,g,p,x),y}if(d instanceof Boolean){const y=new Boolean(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof Number){const y=new Number(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof String){const y=new String(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(typeof d=="object"&&u(d)){const y=Object.create(Object.getPrototypeOf(d));return p.set(d,y),c(y,d,g,p,x),y}return d}function c(d,f,g=d,p,x){const v=[...Object.keys(f),...e.getSymbols(f)];for(let y=0;y<v.length;y++){const b=v[y],E=Object.getOwnPropertyDescriptor(d,b);(E==null||E.writable)&&(d[b]=l(f[b],b,g,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=s,t.cloneDeepWithImpl=l,t.copyProperties=c})(bA)),bA}var sz;function vfe(){return sz||(sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(xA)),xA}var oz;function _fe(){return oz||(oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=AW(),n=vfe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(dA)),dA}var SA={},MA={},EA={},lz;function wfe(){return lz||(lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kW(),n=CW();function r(i,a){return e.cloneDeepWith(i,(s,l,c,u)=>{const d=a?.(s,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(EA)),EA}var cz;function Sfe(){return cz||(cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wfe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(MA)),MA}var TA={},AA={},uz;function PW(){return uz||(uz=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})(AA)),AA}var NA={},dz;function Mfe(){return dz||(dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=NW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(NA)),NA}var hz;function Efe(){return hz||(hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bW(),n=PW(),r=Mfe(),i=ER();function a(s,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&s?.[l]==null?c=i.toPath(l):c=[l],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})(TA)),TA}var fz;function Tfe(){return fz||(fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=AW(),n=MR(),r=Sfe(),i=TR(),a=Efe();function s(l,c){switch(typeof l){case"object":{Object.is(l?.valueOf(),-0)&&(l="-0");break}case"number":{l=n.toKey(l);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,l);return d===void 0?a.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=s})(SA)),SA}var mz;function Afe(){return mz||(mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=SW(),n=gfe(),r=_fe(),i=Tfe();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})(cA)),cA}var pz;function Nfe(){return pz||(pz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hfe(),n=SW(),r=pfe(),i=Afe();function a(s,l=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(l)):[]}t.uniqBy=a})(nA)),nA}var CA,gz;function Cfe(){return gz||(gz=1,CA=Nfe().uniqBy),CA}var kfe=Cfe();const xz=bo(kfe);function jW(t,e,n){return e===!0?xz(t,n):typeof e=="function"?xz(t,e):t}var kA={exports:{}},PA={};var bz;function Pfe(){if(bz)return PA;bz=1;var t=Jp(),e=nG();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,l=t.useMemo,c=t.useDebugValue;return PA.useSyncExternalStoreWithSelector=function(u,d,f,g,p){var x=a(null);if(x.current===null){var v={hasValue:!1,value:null};x.current=v}else v=x.current;x=l(function(){function b(C){if(!E){if(E=!0,w=C,C=g(C),p!==void 0&&v.hasValue){var N=v.value;if(p(N,C))return T=N}return T=C}if(N=T,r(w,C))return N;var F=g(C);return p!==void 0&&p(N,F)?(w=C,N):(w=C,T=F)}var E=!1,w,T,A=f===void 0?null:f;return[function(){return b(d())},A===null?void 0:function(){return b(A())}]},[d,f,g,p]);var y=i(u,x[0],x[1]);return s(function(){v.hasValue=!0,v.value=y},[y]),c(y),y},PA}var yz;function jfe(){return yz||(yz=1,kA.exports=Pfe()),kA.exports}var RW=jfe(),kR=M.createContext(null),Rfe=t=>t,cr=()=>{var t=M.useContext(kR);return t?t.store.dispatch:Rfe},u1=()=>{},Dfe=()=>u1,Ofe=(t,e)=>t===e;function kt(t){var e=M.useContext(kR);return RW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Dfe,e?e.store.getState:u1,e?e.store.getState:u1,e?t:u1,Ofe)}function Lfe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Ife(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function Ffe(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 vz=t=>Array.isArray(t)?t:[t];function Ufe(t){const e=Array.isArray(t[0])?t[0]:t;return Ffe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function zfe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Bfe=class{constructor(t){this.value=t}deref(){return this.value}},Hfe=typeof WeakRef<"u"?WeakRef:Bfe,$fe=0,_z=1;function Nv(){return{s:$fe,v:void 0,o:null,p:null}}function DW(t,e={}){let n=Nv();const{resultEqualityCheck:r}=e;let i,a=0;function s(){let l=n;const{length:c}=arguments;for(let f=0,g=c;f<g;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const v=x.get(p);v===void 0?(l=Nv(),x.set(p,l)):l=v}else{let x=l.p;x===null&&(l.p=x=new Map);const v=x.get(p);v===void 0?(l=Nv(),x.set(p,l)):l=v}}const u=l;let d;if(l.s===_z)d=l.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new Hfe(d):d}return u.s=_z,u.v=d,d}return s.clearCache=()=>{n=Nv(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function Vfe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,s=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Lfe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:p=DW,argsMemoizeOptions:x=[]}=d,v=vz(g),y=vz(x),b=Ufe(i),E=f(function(){return a++,u.apply(null,arguments)},...v),w=p(function(){s++;const A=zfe(b,arguments);return l=E.apply(null,A),l},...y);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:b,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var Ze=Vfe(DW),Gfe=Object.assign((t,e=Ze)=>{Ife(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,l,c)=>(s[n[c]]=l,s),{}))},{withTypes:()=>Gfe}),jA={},RA={},DA={},wz;function Wfe(){return wz||(wz=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),l=e(i);if(s===l&&s===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-s:s-l}return 0};t.compareValues=n})(DA)),DA}var OA={},LA={},Sz;function OW(){return Sz||(Sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(LA)),LA}var Mz;function qfe(){return Mz||(Mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OW(),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})(OA)),OA}var Ez;function Kfe(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wfe(),n=qfe(),r=ER();function i(a,s,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,x)=>{let v=p;for(let y=0;y<x.length&&v!=null;++y)v=v[x[y]];return v},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=s.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let v=0;v<f.length;v++){const y=e.compareValues(p.criteria[v],x.criteria[v],l[v]);if(y!==0)return y}return 0}).map(p=>p.original)}t.orderBy=i})(RA)),RA}var IA={},Tz;function Xfe(){return Tz||(Tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),s=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?s(d,c+1):i.push(d)}};return s(n,0),i}t.flatten=e})(IA)),IA}var FA={},Az;function LW(){return Az||(Az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PW(),n=CR(),r=MW(),i=TW();function a(s,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],s):!1}t.isIterateeCall=a})(FA)),FA}var Nz;function Yfe(){return Nz||(Nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kfe(),n=Xfe(),r=LW();function i(a,...s){const l=s.length;return l>1&&r.isIterateeCall(a,s[0],s[1])?s=[]:l>2&&r.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=i})(jA)),jA}var UA,Cz;function Zfe(){return Cz||(Cz=1,UA=Yfe().sortBy),UA}var Qfe=Zfe();const sM=bo(Qfe);var IW=t=>t.legend.settings,Jfe=t=>t.legend.size,eme=t=>t.legend.payload,tme=Ze([eme,IW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?sM(r,n):r});function nme(){return kt(tme)}var Cv=1;function FW(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=M.useState({height:0,left:0,top:0,width:0}),r=M.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)>Cv||Math.abs(s.left-e.left)>Cv||Math.abs(s.top-e.top)>Cv||Math.abs(s.width-e.width)>Cv)&&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 ea(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 rme=typeof Symbol=="function"&&Symbol.observable||"@@observable",kz=rme,zA=()=>Math.random().toString(36).substring(7).split("").join("."),ime={INIT:`@@redux/INIT${zA()}`,REPLACE:`@@redux/REPLACE${zA()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${zA()}`},K1=ime;function PR(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 UW(t,e,n){if(typeof t!="function")throw new Error(ea(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ea(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ea(1));return n(UW)(t,e)}let r=t,i=e,a=new Map,s=a,l=0,c=!1;function u(){s===a&&(s=new Map,a.forEach((y,b)=>{s.set(b,y)}))}function d(){if(c)throw new Error(ea(3));return i}function f(y){if(typeof y!="function")throw new Error(ea(4));if(c)throw new Error(ea(5));let b=!0;u();const E=l++;return s.set(E,y),function(){if(b){if(c)throw new Error(ea(6));b=!1,u(),s.delete(E),a=null}}}function g(y){if(!PR(y))throw new Error(ea(7));if(typeof y.type>"u")throw new Error(ea(8));if(typeof y.type!="string")throw new Error(ea(17));if(c)throw new Error(ea(9));try{c=!0,i=r(i,y)}finally{c=!1}return(a=s).forEach(E=>{E()}),y}function p(y){if(typeof y!="function")throw new Error(ea(10));r=y,g({type:K1.REPLACE})}function x(){const y=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(ea(11));function E(){const T=b;T.next&&T.next(d())}return E(),{unsubscribe:y(E)}},[kz](){return this}}}return g({type:K1.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:p,[kz]:x}}function ame(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:K1.INIT})>"u")throw new Error(ea(12));if(typeof n(void 0,{type:K1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ea(13))})}function zW(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{ame(n)}catch(a){i=a}return function(s={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],p=s[f],x=g(p,l);if(typeof x>"u")throw l&&l.type,new Error(ea(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(s).length,c?u:s}}function X1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function sme(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ea(15))};const s={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(s));return a=X1(...l)(i.dispatch),{...i,dispatch:a}}}function BW(t){return PR(t)&&"type"in t&&typeof t.type=="string"}var HW=Symbol.for("immer-nothing"),Pz=Symbol.for("immer-draftable"),La=Symbol.for("immer-state");function Po(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var As=Object,Cp=As.getPrototypeOf,Y1="constructor",oM="prototype",d3="configurable",Z1="enumerable",d1="writable",O0="value",Bc=t=>!!t&&!!t[La];function $o(t){return t?$W(t)||lM(t)||!!t[Pz]||!!t[Y1]?.[Pz]||cM(t)||uM(t):!1}var ome=As[oM][Y1].toString(),jz=new WeakMap;function $W(t){if(!t||!jR(t))return!1;const e=Cp(t);if(e===null||e===As[oM])return!0;const n=As.hasOwnProperty.call(e,Y1)&&e[Y1];if(n===Object)return!0;if(!Km(n))return!1;let r=jz.get(n);return r===void 0&&(r=Function.toString.call(n),jz.set(n,r)),r===ome}function Pb(t,e,n=!0){jb(t)===0?(n?Reflect.ownKeys(t):As.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function jb(t){const e=t[La];return e?e.type_:lM(t)?1:cM(t)?2:uM(t)?3:0}var Rz=(t,e,n=jb(t))=>n===2?t.has(e):As[oM].hasOwnProperty.call(t,e),h3=(t,e,n=jb(t))=>n===2?t.get(e):t[e],Q1=(t,e,n,r=jb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function lme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var lM=Array.isArray,cM=t=>t instanceof Map,uM=t=>t instanceof Set,jR=t=>typeof t=="object",Km=t=>typeof t=="function",BA=t=>typeof t=="boolean",xc=t=>t.copy_||t.base_,RR=t=>t.modified_?t.copy_:t.base_;function f3(t,e){if(cM(t))return new Map(t);if(uM(t))return new Set(t);if(lM(t))return Array[oM].slice.call(t);const n=$W(t);if(e===!0||e==="class_only"&&!n){const r=As.getOwnPropertyDescriptors(t);delete r[La];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],l=r[s];l[d1]===!1&&(l[d1]=!0,l[d3]=!0),(l.get||l.set)&&(r[s]={[d3]:!0,[d1]:!0,[Z1]:l[Z1],[O0]:t[s]})}return As.create(Cp(t),r)}else{const r=Cp(t);if(r!==null&&n)return{...t};const i=As.create(r);return As.assign(i,t)}}function DR(t,e=!1){return dM(t)||Bc(t)||!$o(t)||(jb(t)>1&&As.defineProperties(t,{set:kv,add:kv,clear:kv,delete:kv}),As.freeze(t),e&&Pb(t,(n,r)=>{DR(r,!0)},!1)),t}function cme(){Po(2)}var kv={[O0]:cme};function dM(t){return t===null||!jR(t)?!0:As.isFrozen(t)}var J1="MapSet",m3="Patches",VW={};function kp(t){const e=VW[t];return e||Po(0,t),e}var ume=t=>!!VW[t],L0,GW=()=>L0,dme=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:ume(J1)?kp(J1):void 0});function Dz(t,e){e&&(t.patchPlugin_=kp(m3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function p3(t){g3(t),t.drafts_.forEach(hme),t.drafts_=null}function g3(t){t===L0&&(L0=t.parent_)}var Oz=t=>L0=dme(L0,t);function hme(t){const e=t[La];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];if(t!==void 0&&t!==n){n[La].modified_&&(p3(e),Po(4)),$o(t)&&(t=Iz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[La].base_,t,e)}else t=Iz(e,n);return fme(e,t,!0),p3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==HW?t:void 0}function Iz(t,e){if(dM(e))return e;const n=e[La];if(!n)return OR(e,t.handledSet_,t);if(!hM(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);KW(n,t)}return n.copy_}function fme(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&DR(e,n)}function WW(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var hM=(t,e)=>t.scope_===e,mme=[];function qW(t,e,n,r){const i=xc(t),a=t.type_;if(r!==void 0&&h3(i,r,a)===e){Q1(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Pb(i,(c,u)=>{if(Bc(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const s=t.draftLocations_.get(e)??mme;for(const l of s)Q1(i,l,n,a)}function pme(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!hM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=RR(a);qW(t,a.draft_??a,s,n),KW(a,i)})}function KW(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 gme(t,e,n){const{scope_:r}=t;if(Bc(n)){const i=n[La];hM(i,r)&&i.callbacks_.push(function(){h1(t);const s=RR(i);qW(t,n,s,e)})}else $o(n)&&t.callbacks_.push(function(){const a=xc(t);h3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&OR(h3(t.copy_,e,t.type_),r.handledSet_,r)})}function OR(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Bc(t)||e.has(t)||!$o(t)||dM(t)||(e.add(t),Pb(t,(r,i)=>{if(Bc(i)){const a=i[La];if(hM(a,n)){const s=RR(a);Q1(t,r,s,t.type_),WW(a)}}else $o(i)&&OR(i,e,n)})),t}function xme(t,e){const n=lM(t),r={type_:n?1:0,scope_:e?e.scope_:GW(),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=LR;n&&(i=[r],a=I0);const{revoke:s,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=s,[l,r]}var LR={get(t,e){if(e===La)return t;const n=xc(t);if(!Rz(n,e,t.type_))return bme(t,n,e);const r=n[e];if(t.finalized_||!$o(r))return r;if(r===HA(t.base_,e)){h1(t);const i=t.type_===1?+e:e,a=b3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in xc(t)},ownKeys(t){return Reflect.ownKeys(xc(t))},set(t,e,n){const r=XW(xc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=HA(xc(t),e),a=i?.[La];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(lme(n,i)&&(n!==void 0||Rz(t.base_,e,t.type_)))return!0;h1(t),x3(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),gme(t,e,n)),!0},deleteProperty(t,e){return h1(t),HA(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),x3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=xc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[d1]:!0,[d3]:t.type_!==1||e!=="length",[Z1]:r[Z1],[O0]:n[e]}},defineProperty(){Po(11)},getPrototypeOf(t){return Cp(t.base_)},setPrototypeOf(){Po(12)}},I0={};Pb(LR,(t,e)=>{I0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});I0.deleteProperty=function(t,e){return I0.set.call(this,t,e,void 0)};I0.set=function(t,e,n){return LR.set.call(this,t[0],e,n,t[0])};function HA(t,e){const n=t[La];return(n?xc(n):t)[e]}function bme(t,e,n){const r=XW(e,n);return r?O0 in r?r[O0]:r.get?.call(t.draft_):void 0}function XW(t,e){if(!(e in t))return;let n=Cp(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Cp(n)}}function x3(t){t.modified_||(t.modified_=!0,t.parent_&&x3(t.parent_))}function h1(t){t.copy_||(t.assigned_=new Map,t.copy_=f3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var yme=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Km(n)&&!Km(r)){const s=r;r=n;const l=this;return function(u=s,...d){return l.produce(u,f=>r.call(this,f,...d))}}Km(r)||Po(6),i!==void 0&&!Km(i)&&Po(7);let a;if($o(n)){const s=Oz(this),l=b3(s,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?p3(s):g3(s)}return Dz(s,i),Lz(a,s)}else if(!n||!jR(n)){if(a=r(n),a===void 0&&(a=n),a===HW&&(a=void 0),this.autoFreeze_&&DR(a,!0),i){const s=[],l=[];kp(m3).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:l}),i(s,l)}return a}else Po(1,n)},this.produceWithPatches=(n,r)=>{if(Km(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},BA(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),BA(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),BA(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){$o(e)||Po(8),Bc(e)&&(e=zo(e));const n=Oz(this),r=b3(n,e,void 0);return r[La].isManual_=!0,g3(n),r}finishDraft(e,n){const r=e&&e[La];(!r||!r.isManual_)&&Po(9);const{scope_:i}=r;return Dz(i,n),Lz(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=kp(m3).applyPatches_;return Bc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function b3(t,e,n,r){const[i,a]=cM(e)?kp(J1).proxyMap_(e,n):uM(e)?kp(J1).proxySet_(e,n):xme(e,n);return(n?.scope_??GW()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?pme(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function zo(t){return Bc(t)||Po(10,t),YW(t)}function YW(t){if(!$o(t)||dM(t))return t;const e=t[La];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=f3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=f3(t,!0);return Pb(n,(i,a)=>{Q1(n,i,YW(a))},r),e&&(e.finalized_=!1),n}var vme=new yme,ZW=vme.produce;function QW(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var _me=QW(),wme=QW,Sme=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?X1:X1.apply(null,arguments)};function go(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Ns(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=>BW(r)&&r.type===t,n}var JW=class Vx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Vx.prototype)}static get[Symbol.species](){return Vx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Vx(...e[0].concat(this)):new Vx(...e.concat(this))}};function Fz(t){return $o(t)?ZW(t,()=>{}):t}function Pv(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Mme(t){return typeof t=="boolean"}var Eme=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new JW;return n&&(Mme(n)?s.push(_me):s.push(wme(n.extraArgument))),s},eq="RTK_autoBatch",vr=()=>t=>({payload:t,meta:{[eq]:!0}}),Uz=t=>e=>{setTimeout(e,t)},tq=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,s=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Uz(10):t.type==="callback"?t.queueNotification:Uz(t.timeout),u=()=>{s=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return l.add(d),()=>{g(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[eq],a=!i,a&&(s||(s=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Tme=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new JW(t);return r&&i.push(tq(typeof r=="object"?r:void 0)),i};function Ame(t){const e=Eme(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(PR(n))l=zW(n);else throw new Error(Ns(1));let c;typeof r=="function"?c=r(e):c=e();let u=X1;i&&(u=Sme({trace:!1,...typeof i=="object"&&i}));const d=sme(...c),f=Tme(d);let g=typeof s=="function"?s(f):f();const p=u(...g);return UW(l,a,p)}function nq(t){const e={},n=[];let r;const i={addCase(a,s){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Ns(28));if(l in e)throw new Error(Ns(29));return e[l]=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 Nme(t){return typeof t=="function"}function Cme(t,e){let[n,r,i]=nq(e),a;if(Nme(t))a=()=>Fz(t());else{const l=Fz(t);a=()=>l}function s(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Bc(d)){const p=f(d,c);return p===void 0?d:p}else{if($o(d))return ZW(d,g=>f(g,c));{const g=f(d,c);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},l)}return s.getInitialState=a,s}var kme="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Pme=(t=21)=>{let e="",n=t;for(;n--;)e+=kme[Math.random()*64|0];return e},jme=Symbol.for("rtk-slice-createasyncthunk");function Rme(t,e){return`${t}/${e}`}function Dme({creators:t}={}){const e=t?.asyncThunk?.[jme];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Ns(11));const s=(typeof r.reducers=="function"?r.reducers(Lme()):r.reducers)||{},l=Object.keys(s),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,T){const A=typeof w=="string"?w:w.type;if(!A)throw new Error(Ns(12));if(A in c.sliceCaseReducersByType)throw new Error(Ns(13));return c.sliceCaseReducersByType[A]=T,u},addMatcher(w,T){return c.sliceMatchers.push({matcher:w,reducer:T}),u},exposeAction(w,T){return c.actionCreators[w]=T,u},exposeCaseReducer(w,T){return c.sliceCaseReducersByName[w]=T,u}};l.forEach(w=>{const T=s[w],A={reducerName:w,type:Rme(i,w),createNotation:typeof r.reducers=="function"};Fme(T)?zme(A,T,u,e):Ime(A,T,u)});function d(){const[w={},T=[],A=void 0]=typeof r.extraReducers=="function"?nq(r.extraReducers):[r.extraReducers],C={...w,...c.sliceCaseReducersByType};return Cme(r.initialState,N=>{for(let F in C)N.addCase(F,C[F]);for(let F of c.sliceMatchers)N.addMatcher(F.matcher,F.reducer);for(let F of T)N.addMatcher(F.matcher,F.reducer);A&&N.addDefaultCase(A)})}const f=w=>w,g=new Map,p=new WeakMap;let x;function v(w,T){return x||(x=d()),x(w,T)}function y(){return x||(x=d()),x.getInitialState()}function b(w,T=!1){function A(N){let F=N[w];return typeof F>"u"&&T&&(F=Pv(p,A,y)),F}function C(N=f){const F=Pv(g,T,()=>new WeakMap);return Pv(F,N,()=>{const k={};for(const[R,I]of Object.entries(r.selectors??{}))k[R]=Ome(I,N,()=>Pv(p,N,y),T);return k})}return{reducerPath:w,getSelectors:C,get selectors(){return C(A)},selectSlice:A}}const E={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:y,...b(a),injectInto(w,{reducerPath:T,...A}={}){const C=T??a;return w.inject({reducerPath:C,reducer:v},A),{...E,...b(C,!0)}}};return E}}function Ome(t,e,n,r){function i(a,...s){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...s)}return i.unwrapped=t,i}var ss=Dme();function Lme(){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 Ime({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!Ume(r))throw new Error(Ns(17));a=r.reducer,s=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?go(t,s):go(t))}function Fme(t){return t._reducerDefinitionType==="asyncThunk"}function Ume(t){return t._reducerDefinitionType==="reducerWithPrepare"}function zme({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Ns(18));const{payloadCreator:a,fulfilled:s,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),s&&r.addCase(f.fulfilled,s),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:s||jv,pending:l||jv,rejected:c||jv,settled:u||jv})}function jv(){}var Bme="task",rq="listener",iq="completed",IR="cancelled",Hme=`task-${IR}`,$me=`task-${iq}`,y3=`${rq}-${IR}`,Vme=`${rq}-${iq}`,fM=class{constructor(t){this.code=t,this.message=`${Bme} ${IR} (reason: ${t})`}name="TaskAbortError";message},FR=(t,e)=>{if(typeof t!="function")throw new TypeError(Ns(32))},ew=()=>{},aq=(t,e=ew)=>(t.catch(e),t),sq=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Dh=(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))},Oh=t=>{if(t.aborted){const{reason:e}=t;throw new fM(e)}};function oq(t,e){let n=ew;return new Promise((r,i)=>{const a=()=>i(new fM(t.reason));if(t.aborted){a();return}n=sq(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=ew})}var Gme=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof fM?"cancelled":"rejected",error:n}}finally{e?.()}},tw=t=>e=>aq(oq(t,e).then(n=>(Oh(t),n))),lq=t=>{const e=tw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:lp}=Object,zz={},mM="listenerMiddleware",Wme=(t,e)=>{const n=r=>sq(t,()=>Dh(r,t.reason));return(r,i)=>{FR(r);const a=new AbortController;n(a);const s=Gme(async()=>{Oh(t),Oh(a.signal);const l=await r({pause:tw(a.signal),delay:lq(a.signal),signal:a.signal});return Oh(a.signal),l},()=>Dh(a,$me));return i?.autoJoin&&e.push(s.catch(ew)),{result:tw(t)(s),cancel(){Dh(a,Hme)}}}},qme=(t,e)=>{const n=async(r,i)=>{Oh(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),c([f,g.getState(),g.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await oq(e,Promise.race(l));return Oh(e),c}finally{a()}};return(r,i)=>aq(n(r,i))},cq=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=go(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Ns(21));return FR(a),{predicate:i,type:e,effect:a}},uq=lp(t=>{const{type:e,predicate:n,effect:r}=cq(t);return{id:Pme(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Ns(22))}}},{withTypes:()=>uq}),Bz=(t,e)=>{const{type:n,effect:r,predicate:i}=cq(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},v3=t=>{t.pending.forEach(e=>{Dh(e,y3)})},Kme=(t,e)=>()=>{for(const n of e.keys())v3(n);t.clear()},Hz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},dq=lp(go(`${mM}/add`),{withTypes:()=>dq}),Xme=go(`${mM}/removeAll`),hq=lp(go(`${mM}/remove`),{withTypes:()=>hq}),Yme=(...t)=>{console.error(`${mM}/error`,...t)},Rb=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:a,onError:s=Yme}=t;FR(s);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&v3(p)}),c=p=>{const x=Bz(e,p)??uq(p);return l(x)};lp(c,{withTypes:()=>c});const u=p=>{const x=Bz(e,p);return x&&(x.unsubscribe(),p.cancelActive&&v3(x)),!!x};lp(u,{withTypes:()=>u});const d=async(p,x,v,y)=>{const b=new AbortController,E=qme(c,b.signal),w=[];try{p.pending.add(b),r(p),await Promise.resolve(p.effect(x,lp({},v,{getOriginalState:y,condition:(T,A)=>E(T,A).then(Boolean),take:E,delay:lq(b.signal),pause:tw(b.signal),extra:a,signal:b.signal,fork:Wme(b.signal,w),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((T,A,C)=>{T!==b&&(Dh(T,y3),C.delete(T))})},cancel:()=>{Dh(b,y3),p.pending.delete(b)},throwIfCancelled:()=>{Oh(b.signal)}})))}catch(T){T instanceof fM||Hz(s,T,{raisedBy:"effect"})}finally{await Promise.all(w),Dh(b,Vme),i(p),p.pending.delete(b)}},f=Kme(e,n);return{middleware:p=>x=>v=>{if(!BW(v))return x(v);if(dq.match(v))return c(v.payload);if(Xme.match(v)){f();return}if(hq.match(v))return u(v.payload);let y=p.getState();const b=()=>{if(y===zz)throw new Error(Ns(23));return y};let E;try{if(E=x(v),e.size>0){const w=p.getState(),T=Array.from(e.values());for(const A of T){let C=!1;try{C=A.predicate(v,w,y)}catch(N){C=!1,Hz(s,N,{raisedBy:"predicate"})}C&&d(A,v,p,b)}}}finally{y=zz}return E},startListening:c,stopListening:u,clearListeners:f}};function Ns(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 Zme={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},fq=ss({name:"chartLayout",initialState:Zme,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:Qme,setLayout:Jme,setChartSize:epe,setScale:tpe}=fq.actions,npe=fq.reducer;function mq(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}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 tp(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){rpe(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 rpe(t,e,n){return(e=ipe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ipe(t){var e=ape(t,"string");return typeof e=="symbol"?e:e+""}function ape(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 Wn(t,e,n){return xr(t)||xr(e)?n:po(e)?nf(t,e,n):typeof e=="function"?e(t):n}var spe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:s,layout:l}=e;if((l==="vertical"||l==="horizontal"&&s==="middle")&&a!=="center"&&jt(t[a]))return tp(tp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&s!=="middle"&&jt(t[s]))return tp(tp({},t),{},{[s]:t[s]+(i||0)})}return t},Pl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",pq=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,s=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||s.push(e),a||s.push(n),s},gq=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:s,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:p}=t;if(!s)return null;var x=l==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,v=i==="category"&&s.bandwidth?s.bandwidth()/x:0;if(v=p==="angleAxis"&&a&&a.length>=2?Bi(a[0]-a[1])*2*v:v,f||g){var y=(f||g||[]).map((b,E)=>{var w=r?r.indexOf(b):b;return{coordinate:s(w)+v,value:b,offset:v,index:E}});return y.filter(b=>!as(b.coordinate))}return c&&u?u.map((b,E)=>({coordinate:s(b)+v,value:b,index:E,offset:v})):s.ticks&&d!=null?s.ticks(d).map((b,E)=>({coordinate:s(b)+v,value:b,offset:v,index:E})):s.domain().map((b,E)=>({coordinate:s(b)+v,value:r?r[b]:b,index:E,offset:v}))},Vz=1e-4,ope=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]),l=t(e[n-1]);(s<i||s>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},lpe=(t,e)=>{if(!e||e.length!==2||!jt(e[0])||!jt(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(!jt(t[0])||t[0]<n)&&(i[0]=n),(!jt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},cpe=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 l=as(t[s][n][1])?t[s][n][0]:t[s][n][1];l>=0?(t[s][n][0]=i,t[s][n][1]=i+l,i=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+l,a=t[s][n][1])}},upe=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=as(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)}},dpe={sign:cpe,expand:Dhe,none:Np,silhouette:Ohe,wiggle:Lhe,positive:upe},hpe=(t,e,n)=>{var r=dpe[n],i=Rhe().keys(e).value((a,s)=>Number(Wn(a,s,0))).order(c3).offset(r);return i(t)};function xq(t){return t==null?void 0:String(t)}function nw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!xr(i[e.dataKey])){var l=vW(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Wn(i,xr(s)?e.dataKey:s);return xr(c)?null:e.scale(c)}var Gz=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 l=Wn(a,e.dataKey,e.scale.domain()[s]);return xr(l)?null:e.scale(l)-i/2+r},fpe=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]},mpe=t=>{var e=t.flat(2).filter(jt);return[Math.min(...e),Math.max(...e)]},ppe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],gpe=(t,e,n)=>{if(t!=null)return ppe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,l=s.reduce((c,u)=>{var d=mq(u,e,n),f=mpe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},Wz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,qz=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,xd=(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=sM(e,d=>d.coordinate),a=1/0,s=1,l=i.length;s<l;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 Kz(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return tp(tp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Cd(t,e){if(t)return String(t);if(typeof e=="string")return e}var xpe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},bpe=(t,e)=>e==="centric"?t.angle:t.radius,Yc=t=>t.layout.width,Zc=t=>t.layout.height,ype=t=>t.layout.scale,bq=t=>t.layout.margin,pM=Ze(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),gM=Ze(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),yq="data-recharts-item-index",vq="data-recharts-item-data-key",Db=60;function Xz(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?Xz(Object(n),!0).forEach(function(r){vpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Xz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vpe(t,e,n){return(e=_pe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _pe(t){var e=wpe(t,"string");return typeof e=="symbol"?e:e+""}function wpe(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 Spe=t=>t.brush.height;function Mpe(t){var e=gM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Db;return n+i}return n},0)}function Epe(t){var e=gM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Db;return n+i}return n},0)}function Tpe(t){var e=pM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Ape(t){var e=pM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Mi=Ze([Yc,Zc,bq,Spe,Mpe,Epe,Tpe,Ape,IW,Jfe],(t,e,n,r,i,a,s,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+l},g=Rv(Rv({},f),d),p=g.bottom;g.bottom+=r,g=spe(g,c,u);var x=t-g.left-g.right,v=e-g.top-g.bottom;return Rv(Rv({brushBottom:p},g),{},{width:Math.max(x,0),height:Math.max(v,0)})}),Npe=Ze(Mi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),UR=Ze(Yc,Zc,(t,e)=>({x:0,y:0,width:t,height:e})),Cpe=M.createContext(null),Ei=()=>M.useContext(Cpe)!=null,xM=t=>t.brush,bM=Ze([xM,Mi,bq],(t,e,n)=>({height:t.height,x:jt(t.x)?t.x:e.left,y:jt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:jt(t.width)?t.width:e.width})),$A={},VA={},GA={},Yz;function kpe(){return Yz||(Yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let s,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(s,l),s=void 0,l=null)},f=()=>{u&&d(),v()};let g=null;const p=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},v=()=>{x(),s=void 0,l=null},y=()=>{d()},b=function(...E){if(i?.aborted)return;s=this,l=E;const w=g==null;p(),c&&w&&d()};return b.schedule=p,b.cancel=v,b.flush=y,i?.addEventListener("abort",v,{once:!0}),b}t.debounce=e})(GA)),GA}var Zz;function Ppe(){return Zz||(Zz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kpe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);s&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...v){d=r.apply(this,v),f=null},i,{edges:u}),p=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,v),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,v),d)},x=()=>(g.flush(),d);return p.cancel=g.cancel,p.flush=x,p}t.debounce=n})(VA)),VA}var Qz;function jpe(){return Qz||(Qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ppe();function n(r,i=0,a={}){const{leading:s=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:s,maxWait:i,trailing:l})}t.throttle=n})($A)),$A}var WA,Jz;function Rpe(){return Jz||(Jz=1,WA=jpe().throttle),WA}var Dpe=Rpe();const Ope=bo(Dpe);var rw=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++]))}},_q=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,l=zc(r)?t:Number(r),c=zc(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),s&&c!=null&&c>s&&(c=s)),{calculatedWidth:l,calculatedHeight:c}},Lpe={width:0,height:0,overflow:"visible"},Ipe={width:0,overflowX:"visible"},Fpe={height:0,overflowY:"visible"},Upe={},zpe=t=>{var{width:e,height:n}=t,r=zc(e),i=zc(n);return r&&i?Lpe:r?Ipe:i?Fpe:Upe};function Bpe(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 qn(t){return Number.isFinite(t)}function yl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function _3(){return _3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_3.apply(null,arguments)}function 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){Hpe(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 Hpe(t,e,n){return(e=$pe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $pe(t){var e=Vpe(t,"string");return typeof e=="symbol"?e:e+""}function Vpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var wq=M.createContext({width:-1,height:-1});function Gpe(t){return yl(t.width)&&yl(t.height)}function Sq(t){var{children:e,width:n,height:r}=t,i=M.useMemo(()=>({width:n,height:r}),[n,r]);return Gpe(i)?M.createElement(wq.Provider,{value:i},e):null}var zR=()=>M.useContext(wq),Wpe=M.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:s=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:g,onResize:p,style:x={}}=t,v=M.useRef(null),y=M.useRef();y.current=p,M.useImperativeHandle(e,()=>v.current);var[b,E]=M.useState({containerWidth:r.width,containerHeight:r.height}),w=M.useCallback((F,k)=>{E(R=>{var I=Math.round(F),L=Math.round(k);return R.containerWidth===I&&R.containerHeight===L?R:{containerWidth:I,containerHeight:L}})},[]);M.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return Cb;var F=L=>{var q,{width:j,height:V}=L[0].contentRect;w(j,V),(q=y.current)===null||q===void 0||q.call(y,j,V)};d>0&&(F=Ope(F,d,{trailing:!0,leading:!1}));var k=new ResizeObserver(F),{width:R,height:I}=v.current.getBoundingClientRect();return w(R,I),k.observe(v.current),()=>{k.disconnect()}},[w,d]);var{containerWidth:T,containerHeight:A}=b;rw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:N}=_q(T,A,{width:i,height:a,aspect:n,maxHeight:c});return rw(C!=null&&C>0||N!=null&&N>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,C,N,i,a,s,l,n),M.createElement("div",{id:f?"".concat(f):void 0,className:Cn("recharts-responsive-container",g),style:tB(tB({},x),{},{width:i,height:a,minWidth:s,minHeight:l,maxHeight:c}),ref:v},M.createElement("div",{style:zpe({width:i,height:a})},M.createElement(Sq,{width:C,height:N},u)))}),f1=M.forwardRef((t,e)=>{var n=zR();if(yl(n.width)&&yl(n.height))return t.children;var{width:r,height:i}=Bpe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=_q(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return jt(a)&&jt(s)?M.createElement(Sq,{width:a,height:s},t.children):M.createElement(Wpe,_3({},t,{width:r,height:i,ref:e}))});function Mq(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 Ob=()=>{var t,e=Ei(),n=kt(Npe),r=kt(bM),i=(t=kt(xM))===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}},qpe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Eq=()=>{var t;return(t=kt(Mi))!==null&&t!==void 0?t:qpe},BR=()=>kt(Yc),HR=()=>kt(Zc),Kpe=()=>kt(t=>t.layout.margin),vn=t=>t.layout.layoutType,vf=()=>kt(vn),Xpe=()=>{var t=vf();if(t==="horizontal"||t==="vertical")return t},Ype=()=>{var t=vf();return t!==void 0},yM=t=>{var e=cr(),n=Ei(),{width:r,height:i}=t,a=zR(),s=r,l=i;return a&&(s=a.width>0?a.width:r,l=a.height>0?a.height:i),M.useEffect(()=>{!n&&yl(s)&&yl(l)&&e(epe({width:s,height:l}))},[e,n,s,l]),null},Tq=Symbol.for("immer-nothing"),nB=Symbol.for("immer-draftable"),js=Symbol.for("immer-state");function jo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var F0=Object.getPrototypeOf;function Pp(t){return!!t&&!!t[js]}function rf(t){return t?Aq(t)||Array.isArray(t)||!!t[nB]||!!t.constructor?.[nB]||Lb(t)||_M(t):!1}var Zpe=Object.prototype.constructor.toString(),rB=new WeakMap;function Aq(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=rB.get(n);return r===void 0&&(r=Function.toString.call(n),rB.set(n,r)),r===Zpe}function iw(t,e,n=!0){vM(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 vM(t){const e=t[js];return e?e.type_:Array.isArray(t)?1:Lb(t)?2:_M(t)?3:0}function w3(t,e){return vM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Nq(t,e,n){const r=vM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Qpe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Lb(t){return t instanceof Map}function _M(t){return t instanceof Set}function fh(t){return t.copy_||t.base_}function S3(t,e){if(Lb(t))return new Map(t);if(_M(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Aq(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[js];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],l=r[s];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[s]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[s]})}return Object.create(F0(t),r)}else{const r=F0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function $R(t,e=!1){return wM(t)||Pp(t)||!rf(t)||(vM(t)>1&&Object.defineProperties(t,{set:Dv,add:Dv,clear:Dv,delete:Dv}),Object.freeze(t),e&&Object.values(t).forEach(n=>$R(n,!0))),t}function Jpe(){jo(2)}var Dv={value:Jpe};function wM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var ege={};function af(t){const e=ege[t];return e||jo(0,t),e}var U0;function Cq(){return U0}function tge(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function iB(t,e){e&&(af("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function M3(t){E3(t),t.drafts_.forEach(nge),t.drafts_=null}function E3(t){t===U0&&(U0=t.parent_)}function aB(t){return U0=tge(U0,t)}function nge(t){const e=t[js];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function sB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[js].modified_&&(M3(e),jo(4)),rf(t)&&(t=aw(e,t),e.parent_||sw(e,t)),e.patches_&&af("Patches").generateReplacementPatches_(n[js].base_,t,e.patches_,e.inversePatches_)):t=aw(e,n,[]),M3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Tq?t:void 0}function aw(t,e,n){if(wM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[js];if(!i)return iw(e,(a,s)=>oB(t,i,e,a,s,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return sw(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let s=a,l=!1;i.type_===3&&(s=new Set(a),a.clear(),l=!0),iw(s,(c,u)=>oB(t,i,a,c,u,n,l),r),sw(t,a,!1),n&&t.patches_&&af("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function oB(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const l=wM(i);if(!(l&&!s)){if(Pp(i)){const c=a&&e&&e.type_!==3&&!w3(e.assigned_,r)?a.concat(r):void 0,u=aw(t,i,c);if(Nq(n,r,u),Pp(u))t.canAutoFreeze_=!1;else return}else s&&n.add(i);if(rf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;aw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Lb(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&sw(t,i)}}}function sw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&$R(e,n)}function rge(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Cq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=VR;n&&(i=[r],a=z0);const{revoke:s,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=s,l}var VR={get(t,e){if(e===js)return t;const n=fh(t);if(!w3(n,e))return ige(t,n,e);const r=n[e];return t.finalized_||!rf(r)?r:r===qA(t.base_,e)?(KA(t),t.copy_[e]=A3(r,t)):r},has(t,e){return e in fh(t)},ownKeys(t){return Reflect.ownKeys(fh(t))},set(t,e,n){const r=kq(fh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=qA(fh(t),e),a=i?.[js];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Qpe(n,i)&&(n!==void 0||w3(t.base_,e)))return!0;KA(t),T3(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 qA(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,KA(t),T3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=fh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){jo(11)},getPrototypeOf(t){return F0(t.base_)},setPrototypeOf(){jo(12)}},z0={};iw(VR,(t,e)=>{z0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});z0.deleteProperty=function(t,e){return z0.set.call(this,t,e,void 0)};z0.set=function(t,e,n){return VR.set.call(this,t[0],e,n,t[0])};function qA(t,e){const n=t[js];return(n?fh(n):t)[e]}function ige(t,e,n){const r=kq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function kq(t,e){if(!(e in t))return;let n=F0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=F0(n)}}function T3(t){t.modified_||(t.modified_=!0,t.parent_&&T3(t.parent_))}function KA(t){t.copy_||(t.copy_=S3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var age=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"&&jo(6),r!==void 0&&typeof r!="function"&&jo(7);let i;if(rf(e)){const a=aB(this),s=A3(e,void 0);let l=!0;try{i=n(s),l=!1}finally{l?M3(a):E3(a)}return iB(a,r),sB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===Tq&&(i=void 0),this.autoFreeze_&&$R(i,!0),r){const a=[],s=[];af("Patches").generateReplacementPatches_(e,i,a,s),r(a,s)}return i}else jo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...l)=>this.produceWithPatches(s,c=>e(c,...l));let r,i;return[this.produce(e,n,(s,l)=>{r=s,i=l}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){rf(t)||jo(8),Pp(t)&&(t=sge(t));const e=aB(this),n=A3(t,void 0);return n[js].isManual_=!0,E3(e),n}finishDraft(t,e){const n=t&&t[js];(!n||!n.isManual_)&&jo(9);const{scope_:r}=n;return iB(r,e),sB(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=af("Patches").applyPatches_;return Pp(t)?r(t,e):this.produce(t,i=>r(i,e))}};function A3(t,e){const n=Lb(t)?af("MapSet").proxyMap_(t,e):_M(t)?af("MapSet").proxySet_(t,e):rge(t,e);return(e?e.scope_:Cq()).drafts_.push(n),n}function sge(t){return Pp(t)||jo(10,t),Pq(t)}function Pq(t){if(!rf(t)||wM(t))return t;const e=t[js];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=S3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=S3(t,!0);return iw(n,(i,a)=>{Nq(n,i,Pq(a))},r),e&&(e.finalized_=!1),n}var oge=new age;oge.produce;var lge={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},jq=ss({name:"legend",initialState:lge,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:vr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=zo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:vr()},removeLegendPayload:{reducer(t,e){var n=zo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:vr()}}}),{setLegendSize:lB,setLegendSettings:cge,addLegendPayload:Rq,replaceLegendPayload:Dq,removeLegendPayload:Oq}=jq.actions,uge=jq.reducer,dge=["contextPayload"];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 cB(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 jp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cB(Object(n),!0).forEach(function(r){hge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hge(t,e,n){return(e=fge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fge(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)}function pge(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}function xge(t){return t.value}function bge(t){var{contextPayload:e}=t,n=pge(t,dge),r=jW(e,t.payloadUniqBy,xge),i=jp(jp({},n),{},{payload:r});return M.isValidElement(t.content)?M.cloneElement(t.content,i):typeof t.content=="function"?M.createElement(t.content,i):M.createElement(dfe,i)}function yge(t,e,n,r,i,a){var{layout:s,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&s==="vertical"?u={left:((r||0)-a.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),jp(jp({},u),d)}function vge(t){var e=cr();return M.useEffect(()=>{e(cge(t))},[e,t]),null}function _ge(t){var e=cr();return M.useEffect(()=>(e(lB(t)),()=>{e(lB({width:0,height:0}))}),[e,t]),null}function wge(t,e,n,r){return t==="vertical"&&jt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Sge={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function GR(t){var e=Rr(t,Sge),n=nme(),r=rhe(),i=Kpe(),{width:a,height:s,wrapperStyle:l,portal:c}=e,[u,d]=FW([n]),f=BR(),g=HR();if(f==null||g==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=wge(e.layout,s,a,p),v=c?l:jp(jp({position:"absolute",width:x?.width||a||"auto",height:x?.height||s||"auto"},yge(l,e,i,f,g,u)),l),y=c??r;if(y==null||n==null)return null;var b=M.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},M.createElement(vge,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&M.createElement(_ge,{width:u.width,height:u.height}),M.createElement(bge,N3({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return wc.createPortal(b,y)}GR.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 uB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uB(Object(n),!0).forEach(function(r){Mge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Mge(t,e,n){return(e=Ege(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ege(t){var e=Tge(t,"string");return typeof e=="symbol"?e:e+""}function Tge(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 Age(t){return Array.isArray(t)&&po(t[0])&&po(t[1])?t.join(" ~ "):t}var Nge=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:s,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,p=()=>{if(a&&a.length){var A={padding:0,margin:0},C=(l?sM(a,l):a).map((N,F)=>{if(N.type==="none")return null;var k=N.formatter||s||Age,{value:R,name:I}=N,L=R,q=I;if(k){var j=k(R,I,N,F,a);if(Array.isArray(j))[L,q]=j;else if(j!=null)L=j;else return null}var V=XA({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},r);return M.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(F),style:V},po(q)?M.createElement("span",{className:"recharts-tooltip-item-name"},q):null,po(q)?M.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,M.createElement("span",{className:"recharts-tooltip-item-value"},L),M.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return M.createElement("ul",{className:"recharts-tooltip-item-list",style:A},C)}return null},x=XA({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),v=XA({margin:0},i),y=!xr(d),b=y?d:"",E=Cn("recharts-default-tooltip",c),w=Cn("recharts-tooltip-label",u);y&&f&&a!==void 0&&a!==null&&(b=f(d,a));var T=g?{role:"status","aria-live":"assertive"}:{};return M.createElement("div",C3({className:E,style:x},T),M.createElement("p",{className:w,style:v},M.isValidElement(b)?b:"".concat(b)),p())},bx="recharts-tooltip-wrapper",Cge={visibility:"hidden"};function kge(t){var{coordinate:e,translateX:n,translateY:r}=t;return Cn(bx,{["".concat(bx,"-right")]:jt(n)&&e&&jt(e.x)&&n>=e.x,["".concat(bx,"-left")]:jt(n)&&e&&jt(e.x)&&n<e.x,["".concat(bx,"-bottom")]:jt(r)&&e&&jt(e.y)&&r>=e.y,["".concat(bx,"-top")]:jt(r)&&e&&jt(e.y)&&r<e.y})}function dB(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&jt(a[r]))return a[r];var d=n[r]-l-(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 p=d,x=g;return p<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var v=f+l,y=g+u;return v>y?Math.max(d,g):Math.max(f,g)}function Pge(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 jge(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:s,useTranslate3d:l,viewBox:c}=t,u,d,f;return s.height>0&&s.width>0&&n?(d=dB({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:c,viewBoxDimension:c.width}),f=dB({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:c,viewBoxDimension:c.height}),u=Pge({translateX:d,translateY:f,useTranslate3d:l})):u=Cge,{cssProperties:u,cssClasses:kge({translateX:d,translateY:f,coordinate:n})}}function hB(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 Ov(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hB(Object(n),!0).forEach(function(r){k3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function k3(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=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)}class Oge extends M.PureComponent{constructor(){super(...arguments),k3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),k3(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:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:p,wrapperStyle:x,lastBoundingBox:v,innerRef:y,hasPortalFromProps:b}=this.props,{cssClasses:E,cssProperties:w}=jge({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:g,viewBox:p}),T=b?{}:Ov(Ov({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),A=Ov(Ov({},T),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return M.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:A,ref:y},a)}}var Lq=()=>{var t;return(t=kt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function P3(){return P3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P3.apply(null,arguments)}function fB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function mB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fB(Object(n),!0).forEach(function(r){Lge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lge(t,e,n){return(e=Ige(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ige(t){var e=Fge(t,"string");return typeof e=="symbol"?e:e+""}function Fge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var pB={curveBasisClosed:whe,curveBasisOpen:She,curveBasis:_he,curveBumpX:ohe,curveBumpY:lhe,curveLinearClosed:Mhe,curveLinear:iM,curveMonotoneX:Ehe,curveMonotoneY:The,curveNatural:Ahe,curveStep:Nhe,curveStepAfter:khe,curveStepBefore:Che},ow=t=>qn(t.x)&&qn(t.y),gB=t=>t.base!=null&&ow(t.base)&&ow(t),yx=t=>t.x,vx=t=>t.y,Uge=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Nb(t));return(n==="curveMonotone"||n==="curveBump")&&e?pB["".concat(n).concat(e==="vertical"?"Y":"X")]:pB[n]||iM},zge=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=Uge(e,i),l=a?n.filter(ow):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>mB(mB({},p),{},{base:r[x]}));i==="vertical"?c=Av().y(vx).x1(yx).x0(p=>p.base.x):c=Av().x(yx).y1(vx).y0(p=>p.base.y);var d=c.defined(gB).curve(s),f=a?u.filter(gB):u;return d(f)}i==="vertical"&&jt(r)?c=Av().y(vx).x1(yx).x0(r):jt(r)?c=Av().x(yx).y1(vx).y0(r):c=oW().x(yx).y(vx);var g=c.defined(ow).curve(s);return g(l)},cp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?zge(t):r;return M.createElement("path",P3({},Oa(t),NR(t),{className:Cn("recharts-curve",e),d:a===null?void 0:a,ref:i}))},Bge=["x","y","top","left","width","height","className"];function j3(){return j3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},j3.apply(null,arguments)}function xB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Hge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xB(Object(n),!0).forEach(function(r){$ge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $ge(t,e,n){return(e=Vge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vge(t){var e=Gge(t,"string");return typeof e=="symbol"?e:e+""}function Gge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Wge(t,e){if(t==null)return{};var n,r,i=qge(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function qge(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Kge=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Xge=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:l}=t,c=Wge(t,Bge),u=Hge({x:e,y:n,top:r,left:i,width:a,height:s},c);return!jt(e)||!jt(n)||!jt(a)||!jt(s)||!jt(r)||!jt(i)?null:M.createElement("path",j3({},la(u),{className:Cn("recharts-cross",l),d:Kge(e,n,a,s,r,i)}))};function Yge(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 bB(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 yB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bB(Object(n),!0).forEach(function(r){Zge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zge(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=Jge(t,"string");return typeof e=="symbol"?e:e+""}function Jge(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 exe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),Iq=(t,e,n)=>t.map(r=>"".concat(exe(r)," ").concat(e,"ms ").concat(n)).join(","),txe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),B0=(t,e)=>Object.keys(e).reduce((n,r)=>yB(yB({},n),{},{[r]:t(r,e[r])}),{});function vB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vB(Object(n),!0).forEach(function(r){nxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nxe(t,e,n){return(e=rxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rxe(t){var e=ixe(t,"string");return typeof e=="symbol"?e:e+""}function ixe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var lw=(t,e,n)=>t+(e-t)*n,R3=t=>{var{from:e,to:n}=t;return e!==n},Fq=(t,e,n)=>{var r=B0((i,a)=>{if(R3(a)){var[s,l]=t(a.from,a.to,a.velocity);return xi(xi({},a),{},{from:s,velocity:l})}return a},e);return n<1?B0((i,a)=>R3(a)?xi(xi({},a),{},{velocity:lw(a.velocity,r[i].velocity,n),from:lw(a.from,r[i].from,n)}):a,e):Fq(t,r,n-1)};function axe(t,e,n,r,i,a){var s,l=r.reduce((g,p)=>xi(xi({},g),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>B0((g,p)=>p.from,l),u=()=>!Object.values(l).filter(R3).length,d=null,f=g=>{s||(s=g);var p=g-s,x=p/n.dt;l=Fq(n,l,x),i(xi(xi(xi({},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 sxe(t,e,n,r,i,a,s){var l=null,c=i.reduce((f,g)=>xi(xi({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,p=B0((v,y)=>lw(...y,n(g)),c);if(a(xi(xi(xi({},t),e),p)),g<1)l=s.setTimeout(d);else{var x=B0((v,y)=>lw(...y,n(1)),c);a(xi(xi(xi({},t),e),x))}};return()=>(l=s.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const oxe=(t,e,n,r,i,a)=>{var s=txe(t,e);return n==null?()=>(i(xi(xi({},t),e)),()=>{}):n.isStepper===!0?axe(t,e,n,s,i,a):sxe(t,e,n,r,s,i,a)};var cw=1e-4,Uq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],zq=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),_B=(t,e)=>n=>{var r=Uq(t,e);return zq(r,n)},lxe=(t,e)=>n=>{var r=Uq(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return zq(i,n)},cxe=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(l=>parseFloat(l));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},uxe=(t,e,n,r)=>{var i=_B(t,n),a=_B(e,r),s=lxe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var p=i(f)-d,x=s(f);if(Math.abs(p-d)<cw||x<cw)return a(f);f=l(f-p/x)}return a(f)};return c.isStepper=!1,c},wB=function(){return uxe(...cxe(...arguments))},dxe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(s,l,c)=>{var u=-(s-l)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+s;return Math.abs(g-l)<cw&&Math.abs(f)<cw?[l,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},hxe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return wB(t);case"spring":return dxe();default:if(t.split("(")[0]==="cubic-bezier")return wB(t)}return typeof t=="function"?t:null};function fxe(t){var e,n=()=>null,r=!1,i=null,a=s=>{if(!r){if(Array.isArray(s)){if(!s.length)return;var l=s,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof 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 mxe{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 pxe(){return fxe(new mxe)}var gxe=M.createContext(pxe);function xxe(t,e){var n=M.useContext(gxe);return M.useMemo(()=>e??n(t),[t,e,n])}var bxe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),sg={devToolsEnabled:!1,isSsr:bxe()},yxe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},SB={t:0},YA={t:1};function og(t){var e=Rr(t,yxe),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!sg.isSsr:n,f=xxe(e.animationId,e.animationManager),[g,p]=M.useState(d?SB:YA),x=M.useRef(null);return M.useEffect(()=>{d||p(YA)},[d]),M.useEffect(()=>{if(!d||!r)return Cb;var v=oxe(SB,YA,hxe(a),i,p,f.getTimeoutController()),y=()=>{x.current=v()};return f.start([c,s,y,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,s,c,l,f]),u(g.t)}function lg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=M.useRef(D0(e)),r=M.useRef(t);return r.current!==t&&(n.current=D0(e),r.current=t),n.current}var vxe=["radius"],_xe=["radius"];function MB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function EB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MB(Object(n),!0).forEach(function(r){wxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wxe(t,e,n){return(e=Sxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sxe(t){var e=Mxe(t,"string");return typeof e=="symbol"?e:e+""}function Mxe(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 uw(){return uw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},uw.apply(null,arguments)}function TB(t,e){if(t==null)return{};var n,r,i=Exe(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 Exe(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 AB=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),s=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+s*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+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,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-s*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var p=Math.min(a,i);u="M ".concat(t,",").concat(e+s*p,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+l*p,",").concat(e,`
- L `).concat(t+n-l*p,",").concat(e,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+s*p,`
- L `).concat(t+n,",").concat(e+r-s*p,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-l*p,",").concat(e+r,`
- L `).concat(t+l*p,",").concat(e+r,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t,",").concat(e+r-s*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},NB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Bq=t=>{var e=Rr(t,NB),n=M.useRef(null),[r,i]=M.useState(-1);M.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var W=n.current.getTotalLength();W&&i(W)}catch{}},[]);var{x:a,y:s,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:v}=e,y=M.useRef(l),b=M.useRef(c),E=M.useRef(a),w=M.useRef(s),T=M.useMemo(()=>({x:a,y:s,width:l,height:c,radius:u}),[a,s,l,c,u]),A=lg(T,"rectangle-");if(a!==+a||s!==+s||l!==+l||c!==+c||l===0||c===0)return null;var C=Cn("recharts-rectangle",d);if(!v){var N=la(e),{radius:F}=N,k=TB(N,vxe);return M.createElement("path",uw({},k,{radius:typeof u=="number"?u:void 0,className:C,d:AB(a,s,l,c,u)}))}var R=y.current,I=b.current,L=E.current,q=w.current,j="0px ".concat(r===-1?1:r,"px"),V="".concat(r,"px 0px"),K=Iq(["strokeDasharray"],g,typeof f=="string"?f:NB.animationEasing);return M.createElement(og,{animationId:A,key:A,canBegin:r>0,duration:g,easing:f,isActive:v,begin:p},W=>{var J=Un(R,l,W),ee=Un(I,c,W),Z=Un(L,a,W),B=Un(q,s,W);n.current&&(y.current=J,b.current=ee,E.current=Z,w.current=B);var G;x?W>0?G={transition:K,strokeDasharray:V}:G={strokeDasharray:j}:G={strokeDasharray:V};var Q=la(e),{radius:te}=Q,he=TB(Q,_xe);return M.createElement("path",uw({},he,{radius:typeof u=="number"?u:void 0,className:C,d:AB(Z,B,J,ee,u),ref:n,style:EB(EB({},G),e.style)}))})};function CB(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 kB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CB(Object(n),!0).forEach(function(r){Txe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Txe(t,e,n){return(e=Axe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Axe(t){var e=Nxe(t,"string");return typeof e=="symbol"?e:e+""}function Nxe(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 dw=Math.PI/180,Cxe=t=>t*180/Math.PI,ci=(t,e,n,r)=>({x:t+Math.cos(-dw*r)*n,y:e+Math.sin(-dw*r)*n}),Hq=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},kxe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Pxe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=kxe({x:n,y:r},{x:i,y:a});if(s<=0)return{radius:s,angle:0};var l=(n-i)/s,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:s,angle:Cxe(c),angleInRadian:c}},jxe=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}},Rxe=(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},Dxe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Pxe({x:n,y:r},e),{innerRadius:s,outerRadius:l}=e;if(i<s||i>l||i===0)return null;var{startAngle:c,endAngle:u}=jxe(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?kB(kB({},e),{},{radius:i,angle:Rxe(d,e)}):null};function $q(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=ci(e,n,r,i),l=ci(e,n,r,a);return{points:[s,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}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)}var Oxe=(t,e)=>{var n=Bi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Lv=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:s,cornerRadius:l,cornerIsExternal:c}=t,u=l*(s?1:-1)+r,d=Math.asin(l/u)/dw,f=c?i:i+a*d,g=ci(e,n,u,f),p=ci(e,n,r,f),x=c?i-a*d:i,v=ci(e,n,u*Math.cos(d*dw),x);return{center:g,circleTangency:p,lineTangency:v,theta:d}},Vq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,l=Oxe(a,s),c=a+l,u=ci(e,n,i,a),d=ci(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var g=ci(e,n,r,a),p=ci(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
- `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Lxe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Bi(u-c),{circleTangency:f,lineTangency:g,theta:p}=Lv({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:v,theta:y}=Lv({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),b=l?Math.abs(c-u):Math.abs(c-u)-p-y;if(b<0)return s?"M ".concat(g.x,",").concat(g.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):Vq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var E="M ".concat(g.x,",").concat(g.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(b>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
- `);if(r>0){var{circleTangency:w,lineTangency:T,theta:A}=Lv({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:N,theta:F}=Lv({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),k=l?Math.abs(c-u):Math.abs(c-u)-A-F;if(k<0&&a===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(N.x,",").concat(N.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(k>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},Ixe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Gq=t=>{var e=Rr(t,Ixe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:s,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var g=Cn("recharts-sector",f),p=a-i,x=va(s,p,0,!0),v;return x>0&&Math.abs(u-d)<360?v=Lxe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):v=Vq({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),M.createElement("path",D3({},la(e),{className:g,d:v}))};function Fxe(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(wW(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:l}=e,c=ci(r,i,a,l),u=ci(r,i,s,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return $q(e)}}var ZA={},QA={},JA={},PB;function Uxe(){return PB||(PB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(JA)),JA}var jB;function zxe(){return jB||(jB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uxe();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})(QA)),QA}var RB;function Bxe(){return RB||(RB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LW(),n=zxe();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 l=Math.max(Math.ceil((a-i)/(s||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=s;return c}t.range=r})(ZA)),ZA}var eN,DB;function Hxe(){return DB||(DB=1,eN=Bxe().range),eN}var $xe=Hxe();const Wq=bo($xe);function ad(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Vxe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function WR(t){let e,n,r;t.length!==2?(e=ad,n=(l,c)=>ad(t(l),c),r=(l,c)=>t(l)-c):(e=t===ad||t===Vxe?t:Gxe,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function s(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:s,right:a}}function Gxe(){return 0}function qq(t){return t===null?NaN:+t}function*Wxe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const qxe=WR(ad),Ib=qxe.right;WR(qq).center;class OB extends Map{constructor(e,n=Yxe){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(LB(this,e))}has(e){return super.has(LB(this,e))}set(e,n){return super.set(Kxe(this,e),n)}delete(e){return super.delete(Xxe(this,e))}}function LB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Kxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Xxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Yxe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Zxe(t=ad){if(t===ad)return Kq;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 Kq(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const Qxe=Math.sqrt(50),Jxe=Math.sqrt(10),e0e=Math.sqrt(2);function hw(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>=Qxe?10:a>=Jxe?5:a>=e0e?2:1;let l,c,u;return i<0?(u=Math.pow(10,-i)/s,l=Math.round(t*u),c=Math.round(e*u),l/u<t&&++l,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*s,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=n&&n<2?hw(t,e,n*2):[l,c,u]}function O3(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?hw(e,t,n):hw(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(s<0)for(let u=0;u<l;++u)c[u]=(a-u)/-s;else for(let u=0;u<l;++u)c[u]=(a-u)*s;else if(s<0)for(let u=0;u<l;++u)c[u]=(i+u)/-s;else for(let u=0;u<l;++u)c[u]=(i+u)*s;return c}function L3(t,e,n){return e=+e,t=+t,n=+n,hw(t,e,n)[2]}function I3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?L3(e,t,n):L3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function IB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}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 Xq(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?Kq:Zxe(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+g)),x=Math.min(r,Math.floor(e+(c-u)*f/c+g));Xq(t,e,p,x,i)}const a=t[e];let s=n,l=r;for(_x(t,n,e),i(t[r],a)>0&&_x(t,n,r);s<l;){for(_x(t,s,l),++s,--l;i(t[s],a)<0;)++s;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?_x(t,n,l):(++l,_x(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function _x(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function t0e(t,e,n){if(t=Float64Array.from(Wxe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return FB(t);if(e>=1)return IB(t);var r,i=(r-1)*e,a=Math.floor(i),s=IB(Xq(t,a).subarray(0,a+1)),l=FB(t.subarray(a+1));return s+(l-s)*(i-a)}}function n0e(t,e,n=qq){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),l=+n(t[a+1],a+1,t);return s+(l-s)*(i-a)}}function r0e(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 yo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Qc(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 F3=Symbol("implicit");function qR(){var t=new OB,e=[],n=[],r=F3;function i(a){let s=t.get(a);if(s===void 0){if(r!==F3)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 OB;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 qR(e,n).unknown(r)},yo.apply(i,arguments),i}function KR(){var t=qR().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,s,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,p=i<r,x=p?i:r,v=p?r:i;a=(v-x)/Math.max(1,g-c+u*2),l&&(a=Math.floor(a)),x+=(v-x-a*(g-c))*d,s=a*(1-c),l&&(x=Math.round(x),s=Math.round(s));var y=r0e(g).map(function(b){return x+a*b});return n(p?y.reverse():y)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(g){return arguments.length?(l=!!g,f()):l},t.padding=function(g){return arguments.length?(c=Math.min(1,u=+g),f()):c},t.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),f()):c},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return KR(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},yo.apply(f(),arguments)}function Yq(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return Yq(e())},t}function i0e(){return Yq(KR.apply(null,arguments).paddingInner(1))}function XR(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Zq(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Fb(){}var H0=.7,fw=1/H0,up="\\s*([+-]?\\d+)\\s*",$0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ml="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",a0e=/^#([0-9a-f]{3,8})$/,s0e=new RegExp(`^rgb\\(${up},${up},${up}\\)$`),o0e=new RegExp(`^rgb\\(${ml},${ml},${ml}\\)$`),l0e=new RegExp(`^rgba\\(${up},${up},${up},${$0}\\)$`),c0e=new RegExp(`^rgba\\(${ml},${ml},${ml},${$0}\\)$`),u0e=new RegExp(`^hsl\\(${$0},${ml},${ml}\\)$`),d0e=new RegExp(`^hsla\\(${$0},${ml},${ml},${$0}\\)$`),UB={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};XR(Fb,V0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:zB,formatHex:zB,formatHex8:h0e,formatHsl:f0e,formatRgb:BB,toString:BB});function zB(){return this.rgb().formatHex()}function h0e(){return this.rgb().formatHex8()}function f0e(){return Qq(this).formatHsl()}function BB(){return this.rgb().formatRgb()}function V0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=a0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?HB(e):n===3?new Ja(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Iv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Iv(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=s0e.exec(t))?new Ja(e[1],e[2],e[3],1):(e=o0e.exec(t))?new Ja(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=l0e.exec(t))?Iv(e[1],e[2],e[3],e[4]):(e=c0e.exec(t))?Iv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=u0e.exec(t))?GB(e[1],e[2]/100,e[3]/100,1):(e=d0e.exec(t))?GB(e[1],e[2]/100,e[3]/100,e[4]):UB.hasOwnProperty(t)?HB(UB[t]):t==="transparent"?new Ja(NaN,NaN,NaN,0):null}function HB(t){return new Ja(t>>16&255,t>>8&255,t&255,1)}function Iv(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ja(t,e,n,r)}function m0e(t){return t instanceof Fb||(t=V0(t)),t?(t=t.rgb(),new Ja(t.r,t.g,t.b,t.opacity)):new Ja}function U3(t,e,n,r){return arguments.length===1?m0e(t):new Ja(t,e,n,r??1)}function Ja(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}XR(Ja,U3,Zq(Fb,{brighter(t){return t=t==null?fw:Math.pow(fw,t),new Ja(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?H0:Math.pow(H0,t),new Ja(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ja(Lh(this.r),Lh(this.g),Lh(this.b),mw(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:$B,formatHex:$B,formatHex8:p0e,formatRgb:VB,toString:VB}));function $B(){return`#${Mh(this.r)}${Mh(this.g)}${Mh(this.b)}`}function p0e(){return`#${Mh(this.r)}${Mh(this.g)}${Mh(this.b)}${Mh((isNaN(this.opacity)?1:this.opacity)*255)}`}function VB(){const t=mw(this.opacity);return`${t===1?"rgb(":"rgba("}${Lh(this.r)}, ${Lh(this.g)}, ${Lh(this.b)}${t===1?")":`, ${t})`}`}function mw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Lh(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Mh(t){return t=Lh(t),(t<16?"0":"")+t.toString(16)}function GB(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ro(t,e,n,r)}function Qq(t){if(t instanceof Ro)return new Ro(t.h,t.s,t.l,t.opacity);if(t instanceof Fb||(t=V0(t)),!t)return new Ro;if(t instanceof Ro)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,l=a-i,c=(a+i)/2;return l?(e===a?s=(n-r)/l+(n<r)*6:n===a?s=(r-e)/l+2:s=(e-n)/l+4,l/=c<.5?a+i:2-a-i,s*=60):l=c>0&&c<1?0:s,new Ro(s,l,c,t.opacity)}function g0e(t,e,n,r){return arguments.length===1?Qq(t):new Ro(t,e,n,r??1)}function Ro(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}XR(Ro,g0e,Zq(Fb,{brighter(t){return t=t==null?fw:Math.pow(fw,t),new Ro(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?H0:Math.pow(H0,t),new Ro(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 Ja(tN(t>=240?t-240:t+120,i,r),tN(t,i,r),tN(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ro(WB(this.h),Fv(this.s),Fv(this.l),mw(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=mw(this.opacity);return`${t===1?"hsl(":"hsla("}${WB(this.h)}, ${Fv(this.s)*100}%, ${Fv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function WB(t){return t=(t||0)%360,t<0?t+360:t}function Fv(t){return Math.max(0,Math.min(1,t||0))}function tN(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 YR=t=>()=>t;function x0e(t,e){return function(n){return t+n*e}}function b0e(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function y0e(t){return(t=+t)==1?Jq:function(e,n){return n-e?b0e(e,n,t):YR(isNaN(e)?n:e)}}function Jq(t,e){var n=e-t;return n?x0e(t,n):YR(isNaN(t)?e:t)}const qB=(function t(e){var n=y0e(e);function r(i,a){var s=n((i=U3(i)).r,(a=U3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=Jq(i.opacity,a.opacity);return function(d){return i.r=s(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function v0e(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 _0e(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function w0e(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]=cg(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(l){for(s=0;s<r;++s)a[s]=i[s](l);return a}}function S0e(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function pw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function M0e(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]=cg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var z3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,nN=new RegExp(z3.source,"g");function E0e(t){return function(){return t}}function T0e(t){return function(e){return t(e)+""}}function A0e(t,e){var n=z3.lastIndex=nN.lastIndex=0,r,i,a,s=-1,l=[],c=[];for(t=t+"",e=e+"";(r=z3.exec(t))&&(i=nN.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[s]?l[s]+=a:l[++s]=a),(r=r[0])===(i=i[0])?l[s]?l[s]+=i:l[++s]=i:(l[++s]=null,c.push({i:s,x:pw(r,i)})),n=nN.lastIndex;return n<e.length&&(a=e.slice(n),l[s]?l[s]+=a:l[++s]=a),l.length<2?c[0]?T0e(c[0].x):E0e(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function cg(t,e){var n=typeof e,r;return e==null||n==="boolean"?YR(e):(n==="number"?pw:n==="string"?(r=V0(e))?(e=r,qB):A0e:e instanceof V0?qB:e instanceof Date?S0e:_0e(e)?v0e:Array.isArray(e)?w0e:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?M0e:pw)(t,e)}function ZR(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function N0e(t,e){e===void 0&&(e=t,t=cg);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 l=Math.max(0,Math.min(r-1,Math.floor(s*=r)));return a[l](s-l)}}function C0e(t){return function(){return t}}function gw(t){return+t}var KB=[0,1];function ja(t){return t}function B3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:C0e(isNaN(e)?NaN:.5)}function k0e(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function P0e(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=B3(i,r),a=n(s,a)):(r=B3(r,i),a=n(a,s)),function(l){return a(r(l))}}function j0e(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]=B3(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(l){var c=Ib(t,l,1,r)-1;return a[c](i[c](l))}}function Ub(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function SM(){var t=KB,e=KB,n=cg,r,i,a,s=ja,l,c,u;function d(){var g=Math.min(t.length,e.length);return s!==ja&&(s=k0e(t[0],t[g-1])),l=g>2?j0e:P0e,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?a:(c||(c=l(t.map(r),e,n)))(r(s(g)))}return f.invert=function(g){return s(i((u||(u=l(e,t.map(r),pw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,gw),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=ZR,d()},f.clamp=function(g){return arguments.length?(s=g?!0:ja,d()):s!==ja},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(a=g,f):a},function(g,p){return r=g,i=p,d()}}function QR(){return SM()(ja,ja)}function R0e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function xw(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 Rp(t){return t=xw(Math.abs(t)),t?t[1]:NaN}function D0e(t,e){return function(n,r){for(var i=n.length,a=[],s=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),a.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[s=(s+1)%t.length];return a.reverse().join(e)}}function O0e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var L0e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function G0(t){if(!(e=L0e.exec(t)))throw new Error("invalid format: "+t);var e;return new JR({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]})}G0.prototype=JR.prototype;function JR(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+""}JR.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 I0e(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 eK;function F0e(t,e){var n=xw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(eK=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")+xw(t,Math.max(0,e+a-1))[0]}function XB(t,e){var n=xw(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 YB={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:R0e,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)=>XB(t*100,e),r:XB,s:F0e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function ZB(t){return t}var QB=Array.prototype.map,JB=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function U0e(t){var e=t.grouping===void 0||t.thousands===void 0?ZB:D0e(QB.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?ZB:O0e(QB.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=G0(f);var g=f.fill,p=f.align,x=f.sign,v=f.symbol,y=f.zero,b=f.width,E=f.comma,w=f.precision,T=f.trim,A=f.type;A==="n"?(E=!0,A="g"):YB[A]||(w===void 0&&(w=12),T=!0,A="g"),(y||g==="0"&&p==="=")&&(y=!0,g="0",p="=");var C=v==="$"?n:v==="#"&&/[boxX]/.test(A)?"0"+A.toLowerCase():"",N=v==="$"?r:/[%p]/.test(A)?s:"",F=YB[A],k=/[defgprs%]/.test(A);w=w===void 0?6:/[gprs]/.test(A)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function R(I){var L=C,q=N,j,V,K;if(A==="c")q=F(I)+q,I="";else{I=+I;var W=I<0||1/I<0;if(I=isNaN(I)?c:F(Math.abs(I),w),T&&(I=I0e(I)),W&&+I==0&&x!=="+"&&(W=!1),L=(W?x==="("?x:l:x==="-"||x==="("?"":x)+L,q=(A==="s"?JB[8+eK/3]:"")+q+(W&&x==="("?")":""),k){for(j=-1,V=I.length;++j<V;)if(K=I.charCodeAt(j),48>K||K>57){q=(K===46?i+I.slice(j+1):I.slice(j))+q,I=I.slice(0,j);break}}}E&&!y&&(I=e(I,1/0));var J=L.length+I.length+q.length,ee=J<b?new Array(b-J+1).join(g):"";switch(E&&y&&(I=e(ee+I,ee.length?b-q.length:1/0),ee=""),p){case"<":I=L+I+q+ee;break;case"=":I=L+ee+I+q;break;case"^":I=ee.slice(0,J=ee.length>>1)+L+I+q+ee.slice(J);break;default:I=ee+L+I+q;break}return a(I)}return R.toString=function(){return f+""},R}function d(f,g){var p=u((f=G0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Rp(g)/3)))*3,v=Math.pow(10,-x),y=JB[8+x/3];return function(b){return p(v*b)+y}}return{format:u,formatPrefix:d}}var Uv,eD,tK;z0e({thousands:",",grouping:[3],currency:["$",""]});function z0e(t){return Uv=U0e(t),eD=Uv.format,tK=Uv.formatPrefix,Uv}function B0e(t){return Math.max(0,-Rp(Math.abs(t)))}function H0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Rp(e)/3)))*3-Rp(Math.abs(t)))}function $0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Rp(e)-Rp(t))+1}function nK(t,e,n,r){var i=I3(t,e,n),a;switch(r=G0(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=H0e(i,s))&&(r.precision=a),tK(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=$0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=B0e(i))&&(r.precision=a-(r.type==="%")*2);break}}return eD(r)}function kd(t){var e=t.domain;return t.ticks=function(n){var r=e();return O3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return nK(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],l=r[a],c,u,d=10;for(l<s&&(u=s,s=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=L3(s,l,n),u===c)return r[i]=s,r[a]=l,e(r);if(u>0)s=Math.floor(s/u)*u,l=Math.ceil(l/u)*u;else if(u<0)s=Math.ceil(s*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function rK(){var t=QR();return t.copy=function(){return Ub(t,rK())},yo.apply(t,arguments),kd(t)}function iK(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,gw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return iK(t).unknown(e)},t=arguments.length?Array.from(t,gw):[0,1],kd(n)}function aK(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 e8(t){return Math.log(t)}function t8(t){return Math.exp(t)}function V0e(t){return-Math.log(-t)}function G0e(t){return-Math.exp(-t)}function W0e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function q0e(t){return t===10?W0e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function K0e(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 n8(t){return(e,n)=>-t(-e,n)}function tD(t){const e=t(e8,t8),n=e.domain;let r=10,i,a;function s(){return i=K0e(r),a=q0e(r),n()[0]<0?(i=n8(i),a=n8(a),t(V0e,G0e)):t(e8,t8),e}return e.base=function(l){return arguments.length?(r=+l,s()):r},e.domain=function(l){return arguments.length?(n(l),s()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),p=i(d),x,v;const y=l==null?10:+l;let b=[];if(!(r%1)&&p-g<y){if(g=Math.floor(g),p=Math.ceil(p),u>0){for(;g<=p;++g)for(x=1;x<r;++x)if(v=g<0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}}else for(;g<=p;++g)for(x=r-1;x>=1;--x)if(v=g>0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}b.length*2<y&&(b=O3(u,d,y))}else b=O3(g,p,Math.min(p-g,y)).map(a);return f?b.reverse():b},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=G0(c)).precision==null&&(c.trim=!0),c=eD(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(aK(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function sK(){const t=tD(SM()).domain([1,10]);return t.copy=()=>Ub(t,sK()).base(t.base()),yo.apply(t,arguments),t}function r8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function i8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function nD(t){var e=1,n=t(r8(e),i8(e));return n.constant=function(r){return arguments.length?t(r8(e=+r),i8(e)):e},kd(n)}function oK(){var t=nD(SM());return t.copy=function(){return Ub(t,oK()).constant(t.constant())},yo.apply(t,arguments)}function a8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function X0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Y0e(t){return t<0?-t*t:t*t}function rD(t){var e=t(ja,ja),n=1;function r(){return n===1?t(ja,ja):n===.5?t(X0e,Y0e):t(a8(n),a8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},kd(e)}function iD(){var t=rD(SM());return t.copy=function(){return Ub(t,iD()).exponent(t.exponent())},yo.apply(t,arguments),t}function Z0e(){return iD.apply(null,arguments).exponent(.5)}function s8(t){return Math.sign(t)*t*t}function Q0e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function lK(){var t=QR(),e=[0,1],n=!1,r;function i(a){var s=Q0e(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(s8(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,gw)).map(s8)),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 lK(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},yo.apply(i,arguments),kd(i)}function cK(){var t=[],e=[],n=[],r;function i(){var s=0,l=Math.max(1,e.length);for(n=new Array(l-1);++s<l;)n[s-1]=n0e(t,s/l);return a}function a(s){return s==null||isNaN(s=+s)?r:e[Ib(n,s)]}return a.invertExtent=function(s){var l=e.indexOf(s);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let l of s)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(ad),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 cK().domain(t).range(e).unknown(r)},yo.apply(a,arguments)}function uK(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function s(c){return c!=null&&c<=c?i[Ib(r,c,0,n)]:a}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return s}return s.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},s.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):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 uK().domain([t,e]).range(i).unknown(a)},yo.apply(kd(s),arguments)}function dK(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Ib(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 dK().domain(t).range(e).unknown(n)},yo.apply(i,arguments)}const rN=new Date,iN=new Date;function Ti(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),l=i.ceil(a);return a-s<l-a?s:l},i.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<s)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<s);return c},i.filter=a=>Ti(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,l)=>{if(s>=s)if(l<0)for(;++l<=0;)for(;e(s,-1),!a(s););else for(;--l>=0;)for(;e(s,1),!a(s););}),n&&(i.count=(a,s)=>(rN.setTime(+a),iN.setTime(+s),t(rN),t(iN),Math.floor(n(rN,iN))),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 bw=Ti(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);bw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ti(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):bw);bw.range;const Sc=1e3,ao=Sc*60,Mc=ao*60,Hc=Mc*24,aD=Hc*7,o8=Hc*30,aN=Hc*365,Eh=Ti(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Sc)},(t,e)=>(e-t)/Sc,t=>t.getUTCSeconds());Eh.range;const sD=Ti(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Sc)},(t,e)=>{t.setTime(+t+e*ao)},(t,e)=>(e-t)/ao,t=>t.getMinutes());sD.range;const oD=Ti(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*ao)},(t,e)=>(e-t)/ao,t=>t.getUTCMinutes());oD.range;const lD=Ti(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Sc-t.getMinutes()*ao)},(t,e)=>{t.setTime(+t+e*Mc)},(t,e)=>(e-t)/Mc,t=>t.getHours());lD.range;const cD=Ti(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Mc)},(t,e)=>(e-t)/Mc,t=>t.getUTCHours());cD.range;const zb=Ti(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ao)/Hc,t=>t.getDate()-1);zb.range;const MM=Ti(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Hc,t=>t.getUTCDate()-1);MM.range;const hK=Ti(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Hc,t=>Math.floor(t/Hc));hK.range;function _f(t){return Ti(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())*ao)/aD)}const EM=_f(0),yw=_f(1),J0e=_f(2),ebe=_f(3),Dp=_f(4),tbe=_f(5),nbe=_f(6);EM.range;yw.range;J0e.range;ebe.range;Dp.range;tbe.range;nbe.range;function wf(t){return Ti(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)/aD)}const TM=wf(0),vw=wf(1),rbe=wf(2),ibe=wf(3),Op=wf(4),abe=wf(5),sbe=wf(6);TM.range;vw.range;rbe.range;ibe.range;Op.range;abe.range;sbe.range;const uD=Ti(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());uD.range;const dD=Ti(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());dD.range;const $c=Ti(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());$c.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ti(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)});$c.range;const Vc=Ti(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());Vc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ti(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)});Vc.range;function fK(t,e,n,r,i,a){const s=[[Eh,1,Sc],[Eh,5,5*Sc],[Eh,15,15*Sc],[Eh,30,30*Sc],[a,1,ao],[a,5,5*ao],[a,15,15*ao],[a,30,30*ao],[i,1,Mc],[i,3,3*Mc],[i,6,6*Mc],[i,12,12*Mc],[r,1,Hc],[r,2,2*Hc],[n,1,aD],[e,1,o8],[e,3,3*o8],[t,1,aN]];function l(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return g?x.reverse():x}function c(u,d,f){const g=Math.abs(d-u)/f,p=WR(([,,y])=>y).right(s,g);if(p===s.length)return t.every(I3(u/aN,d/aN,f));if(p===0)return bw.every(Math.max(I3(u,d,f),1));const[x,v]=s[g/s[p-1][2]<s[p][2]/g?p-1:p];return x.every(v)}return[l,c]}const[obe,lbe]=fK(Vc,dD,TM,hK,cD,oD),[cbe,ube]=fK($c,uD,EM,zb,lD,sD);function sN(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 oN(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 wx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function dbe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,s=t.shortDays,l=t.months,c=t.shortMonths,u=Sx(i),d=Mx(i),f=Sx(a),g=Mx(a),p=Sx(s),x=Mx(s),v=Sx(l),y=Mx(l),b=Sx(c),E=Mx(c),w={a:W,A:J,b:ee,B:Z,c:null,d:f8,e:f8,f:Dbe,g:Vbe,G:Wbe,H:Pbe,I:jbe,j:Rbe,L:mK,m:Obe,M:Lbe,p:B,q:G,Q:g8,s:x8,S:Ibe,u:Fbe,U:Ube,V:zbe,w:Bbe,W:Hbe,x:null,X:null,y:$be,Y:Gbe,Z:qbe,"%":p8},T={a:Q,A:te,b:he,B:oe,c:null,d:m8,e:m8,f:Zbe,g:oye,G:cye,H:Kbe,I:Xbe,j:Ybe,L:gK,m:Qbe,M:Jbe,p:xe,q:Te,Q:g8,s:x8,S:eye,u:tye,U:nye,V:rye,w:iye,W:aye,x:null,X:null,y:sye,Y:lye,Z:uye,"%":p8},A={a:R,A:I,b:L,B:q,c:j,d:d8,e:d8,f:Abe,g:u8,G:c8,H:h8,I:h8,j:Sbe,L:Tbe,m:wbe,M:Mbe,p:k,q:_be,Q:Cbe,s:kbe,S:Ebe,u:gbe,U:xbe,V:bbe,w:pbe,W:ybe,x:V,X:K,y:u8,Y:c8,Z:vbe,"%":Nbe};w.x=C(n,w),w.X=C(r,w),w.c=C(e,w),T.x=C(n,T),T.X=C(r,T),T.c=C(e,T);function C(me,ce){return function(Ce){var fe=[],Ie=-1,z=0,H=me.length,re,$,Y;for(Ce instanceof Date||(Ce=new Date(+Ce));++Ie<H;)me.charCodeAt(Ie)===37&&(fe.push(me.slice(z,Ie)),($=l8[re=me.charAt(++Ie)])!=null?re=me.charAt(++Ie):$=re==="e"?" ":"0",(Y=ce[re])&&(re=Y(Ce,$)),fe.push(re),z=Ie+1);return fe.push(me.slice(z,Ie)),fe.join("")}}function N(me,ce){return function(Ce){var fe=wx(1900,void 0,1),Ie=F(fe,me,Ce+="",0),z,H;if(Ie!=Ce.length)return null;if("Q"in fe)return new Date(fe.Q);if("s"in fe)return new Date(fe.s*1e3+("L"in fe?fe.L:0));if(ce&&!("Z"in fe)&&(fe.Z=0),"p"in fe&&(fe.H=fe.H%12+fe.p*12),fe.m===void 0&&(fe.m="q"in fe?fe.q:0),"V"in fe){if(fe.V<1||fe.V>53)return null;"w"in fe||(fe.w=1),"Z"in fe?(z=oN(wx(fe.y,0,1)),H=z.getUTCDay(),z=H>4||H===0?vw.ceil(z):vw(z),z=MM.offset(z,(fe.V-1)*7),fe.y=z.getUTCFullYear(),fe.m=z.getUTCMonth(),fe.d=z.getUTCDate()+(fe.w+6)%7):(z=sN(wx(fe.y,0,1)),H=z.getDay(),z=H>4||H===0?yw.ceil(z):yw(z),z=zb.offset(z,(fe.V-1)*7),fe.y=z.getFullYear(),fe.m=z.getMonth(),fe.d=z.getDate()+(fe.w+6)%7)}else("W"in fe||"U"in fe)&&("w"in fe||(fe.w="u"in fe?fe.u%7:"W"in fe?1:0),H="Z"in fe?oN(wx(fe.y,0,1)).getUTCDay():sN(wx(fe.y,0,1)).getDay(),fe.m=0,fe.d="W"in fe?(fe.w+6)%7+fe.W*7-(H+5)%7:fe.w+fe.U*7-(H+6)%7);return"Z"in fe?(fe.H+=fe.Z/100|0,fe.M+=fe.Z%100,oN(fe)):sN(fe)}}function F(me,ce,Ce,fe){for(var Ie=0,z=ce.length,H=Ce.length,re,$;Ie<z;){if(fe>=H)return-1;if(re=ce.charCodeAt(Ie++),re===37){if(re=ce.charAt(Ie++),$=A[re in l8?ce.charAt(Ie++):re],!$||(fe=$(me,Ce,fe))<0)return-1}else if(re!=Ce.charCodeAt(fe++))return-1}return fe}function k(me,ce,Ce){var fe=u.exec(ce.slice(Ce));return fe?(me.p=d.get(fe[0].toLowerCase()),Ce+fe[0].length):-1}function R(me,ce,Ce){var fe=p.exec(ce.slice(Ce));return fe?(me.w=x.get(fe[0].toLowerCase()),Ce+fe[0].length):-1}function I(me,ce,Ce){var fe=f.exec(ce.slice(Ce));return fe?(me.w=g.get(fe[0].toLowerCase()),Ce+fe[0].length):-1}function L(me,ce,Ce){var fe=b.exec(ce.slice(Ce));return fe?(me.m=E.get(fe[0].toLowerCase()),Ce+fe[0].length):-1}function q(me,ce,Ce){var fe=v.exec(ce.slice(Ce));return fe?(me.m=y.get(fe[0].toLowerCase()),Ce+fe[0].length):-1}function j(me,ce,Ce){return F(me,e,ce,Ce)}function V(me,ce,Ce){return F(me,n,ce,Ce)}function K(me,ce,Ce){return F(me,r,ce,Ce)}function W(me){return s[me.getDay()]}function J(me){return a[me.getDay()]}function ee(me){return c[me.getMonth()]}function Z(me){return l[me.getMonth()]}function B(me){return i[+(me.getHours()>=12)]}function G(me){return 1+~~(me.getMonth()/3)}function Q(me){return s[me.getUTCDay()]}function te(me){return a[me.getUTCDay()]}function he(me){return c[me.getUTCMonth()]}function oe(me){return l[me.getUTCMonth()]}function xe(me){return i[+(me.getUTCHours()>=12)]}function Te(me){return 1+~~(me.getUTCMonth()/3)}return{format:function(me){var ce=C(me+="",w);return ce.toString=function(){return me},ce},parse:function(me){var ce=N(me+="",!1);return ce.toString=function(){return me},ce},utcFormat:function(me){var ce=C(me+="",T);return ce.toString=function(){return me},ce},utcParse:function(me){var ce=N(me+="",!0);return ce.toString=function(){return me},ce}}}var l8={"-":"",_:" ",0:"0"},Gi=/^\s*\d+/,hbe=/^%/,fbe=/[\\^$*+?|[\]().{}]/g;function On(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 mbe(t){return t.replace(fbe,"\\$&")}function Sx(t){return new RegExp("^(?:"+t.map(mbe).join("|")+")","i")}function Mx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function pbe(t,e,n){var r=Gi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function gbe(t,e,n){var r=Gi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function xbe(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function bbe(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function ybe(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function c8(t,e,n){var r=Gi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function u8(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function vbe(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 _be(t,e,n){var r=Gi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function wbe(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function d8(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Sbe(t,e,n){var r=Gi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function h8(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Mbe(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Ebe(t,e,n){var r=Gi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Tbe(t,e,n){var r=Gi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Abe(t,e,n){var r=Gi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Nbe(t,e,n){var r=hbe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Cbe(t,e,n){var r=Gi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function kbe(t,e,n){var r=Gi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function f8(t,e){return On(t.getDate(),e,2)}function Pbe(t,e){return On(t.getHours(),e,2)}function jbe(t,e){return On(t.getHours()%12||12,e,2)}function Rbe(t,e){return On(1+zb.count($c(t),t),e,3)}function mK(t,e){return On(t.getMilliseconds(),e,3)}function Dbe(t,e){return mK(t,e)+"000"}function Obe(t,e){return On(t.getMonth()+1,e,2)}function Lbe(t,e){return On(t.getMinutes(),e,2)}function Ibe(t,e){return On(t.getSeconds(),e,2)}function Fbe(t){var e=t.getDay();return e===0?7:e}function Ube(t,e){return On(EM.count($c(t)-1,t),e,2)}function pK(t){var e=t.getDay();return e>=4||e===0?Dp(t):Dp.ceil(t)}function zbe(t,e){return t=pK(t),On(Dp.count($c(t),t)+($c(t).getDay()===4),e,2)}function Bbe(t){return t.getDay()}function Hbe(t,e){return On(yw.count($c(t)-1,t),e,2)}function $be(t,e){return On(t.getFullYear()%100,e,2)}function Vbe(t,e){return t=pK(t),On(t.getFullYear()%100,e,2)}function Gbe(t,e){return On(t.getFullYear()%1e4,e,4)}function Wbe(t,e){var n=t.getDay();return t=n>=4||n===0?Dp(t):Dp.ceil(t),On(t.getFullYear()%1e4,e,4)}function qbe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+On(e/60|0,"0",2)+On(e%60,"0",2)}function m8(t,e){return On(t.getUTCDate(),e,2)}function Kbe(t,e){return On(t.getUTCHours(),e,2)}function Xbe(t,e){return On(t.getUTCHours()%12||12,e,2)}function Ybe(t,e){return On(1+MM.count(Vc(t),t),e,3)}function gK(t,e){return On(t.getUTCMilliseconds(),e,3)}function Zbe(t,e){return gK(t,e)+"000"}function Qbe(t,e){return On(t.getUTCMonth()+1,e,2)}function Jbe(t,e){return On(t.getUTCMinutes(),e,2)}function eye(t,e){return On(t.getUTCSeconds(),e,2)}function tye(t){var e=t.getUTCDay();return e===0?7:e}function nye(t,e){return On(TM.count(Vc(t)-1,t),e,2)}function xK(t){var e=t.getUTCDay();return e>=4||e===0?Op(t):Op.ceil(t)}function rye(t,e){return t=xK(t),On(Op.count(Vc(t),t)+(Vc(t).getUTCDay()===4),e,2)}function iye(t){return t.getUTCDay()}function aye(t,e){return On(vw.count(Vc(t)-1,t),e,2)}function sye(t,e){return On(t.getUTCFullYear()%100,e,2)}function oye(t,e){return t=xK(t),On(t.getUTCFullYear()%100,e,2)}function lye(t,e){return On(t.getUTCFullYear()%1e4,e,4)}function cye(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Op(t):Op.ceil(t),On(t.getUTCFullYear()%1e4,e,4)}function uye(){return"+0000"}function p8(){return"%"}function g8(t){return+t}function x8(t){return Math.floor(+t/1e3)}var sm,bK,yK;dye({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 dye(t){return sm=dbe(t),bK=sm.format,sm.parse,yK=sm.utcFormat,sm.utcParse,sm}function hye(t){return new Date(t)}function fye(t){return t instanceof Date?+t:+new Date(+t)}function hD(t,e,n,r,i,a,s,l,c,u){var d=QR(),f=d.invert,g=d.domain,p=u(".%L"),x=u(":%S"),v=u("%I:%M"),y=u("%I %p"),b=u("%a %d"),E=u("%b %d"),w=u("%B"),T=u("%Y");function A(C){return(c(C)<C?p:l(C)<C?x:s(C)<C?v:a(C)<C?y:r(C)<C?i(C)<C?b:E:n(C)<C?w:T)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?g(Array.from(C,fye)):g().map(hye)},d.ticks=function(C){var N=g();return t(N[0],N[N.length-1],C??10)},d.tickFormat=function(C,N){return N==null?A:u(N)},d.nice=function(C){var N=g();return(!C||typeof C.range!="function")&&(C=e(N[0],N[N.length-1],C??10)),C?g(aK(N,C)):d},d.copy=function(){return Ub(d,hD(t,e,n,r,i,a,s,l,c,u))},d}function mye(){return yo.apply(hD(cbe,ube,$c,uD,EM,zb,lD,sD,Eh,bK).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function pye(){return yo.apply(hD(obe,lbe,Vc,dD,TM,MM,cD,oD,Eh,yK).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function AM(){var t=0,e=1,n,r,i,a,s=ja,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:s(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(s=f,u):s};function d(f){return function(g){var p,x;return arguments.length?([p,x]=g,s=f(p,x),u):[s(0),s(1)]}}return u.range=d(cg),u.rangeRound=d(ZR),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 Pd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function vK(){var t=kd(AM()(ja));return t.copy=function(){return Pd(t,vK())},Qc.apply(t,arguments)}function _K(){var t=tD(AM()).domain([1,10]);return t.copy=function(){return Pd(t,_K()).base(t.base())},Qc.apply(t,arguments)}function wK(){var t=nD(AM());return t.copy=function(){return Pd(t,wK()).constant(t.constant())},Qc.apply(t,arguments)}function fD(){var t=rD(AM());return t.copy=function(){return Pd(t,fD()).exponent(t.exponent())},Qc.apply(t,arguments)}function gye(){return fD.apply(null,arguments).exponent(.5)}function SK(){var t=[],e=ja;function n(r){if(r!=null&&!isNaN(r=+r))return e((Ib(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(ad),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)=>t0e(t,a/r))},n.copy=function(){return SK(e).domain(t)},Qc.apply(n,arguments)}function NM(){var t=0,e=.5,n=1,r=1,i,a,s,l,c,u=ja,d,f=!1,g;function p(v){return isNaN(v=+v)?g:(v=.5+((v=+d(v))-a)*(r*v<r*a?l:c),u(f?Math.max(0,Math.min(1,v)):v))}p.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),a=d(e=+e),s=d(n=+n),l=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,p):[t,e,n]},p.clamp=function(v){return arguments.length?(f=!!v,p):f},p.interpolator=function(v){return arguments.length?(u=v,p):u};function x(v){return function(y){var b,E,w;return arguments.length?([b,E,w]=y,u=N0e(v,[b,E,w]),p):[u(0),u(.5),u(1)]}}return p.range=x(cg),p.rangeRound=x(ZR),p.unknown=function(v){return arguments.length?(g=v,p):g},function(v){return d=v,i=v(t),a=v(e),s=v(n),l=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,p}}function MK(){var t=kd(NM()(ja));return t.copy=function(){return Pd(t,MK())},Qc.apply(t,arguments)}function EK(){var t=tD(NM()).domain([.1,1,10]);return t.copy=function(){return Pd(t,EK()).base(t.base())},Qc.apply(t,arguments)}function TK(){var t=nD(NM());return t.copy=function(){return Pd(t,TK()).constant(t.constant())},Qc.apply(t,arguments)}function mD(){var t=rD(NM());return t.copy=function(){return Pd(t,mD()).exponent(t.exponent())},Qc.apply(t,arguments)}function xye(){return mD.apply(null,arguments).exponent(.5)}const Gx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:KR,scaleDiverging:MK,scaleDivergingLog:EK,scaleDivergingPow:mD,scaleDivergingSqrt:xye,scaleDivergingSymlog:TK,scaleIdentity:iK,scaleImplicit:F3,scaleLinear:rK,scaleLog:sK,scaleOrdinal:qR,scalePoint:i0e,scalePow:iD,scaleQuantile:cK,scaleQuantize:uK,scaleRadial:lK,scaleSequential:vK,scaleSequentialLog:_K,scaleSequentialPow:fD,scaleSequentialQuantile:SK,scaleSequentialSqrt:gye,scaleSequentialSymlog:wK,scaleSqrt:Z0e,scaleSymlog:oK,scaleThreshold:dK,scaleTime:mye,scaleUtc:pye,tickFormat:nK},Symbol.toStringTag,{value:"Module"}));var jd=t=>t.chartData,pD=Ze([jd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Bb=(t,e,n,r)=>r?pD(t):jd(t);function bd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(qn(e)&&qn(n))return!0}return!1}function b8(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function AK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(qn(n))i=n;else if(typeof n=="function")return;if(qn(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(bd(s))return s}}function bye(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(bd(r))return b8(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,s,l;if(i==="auto")e!=null&&(s=Math.min(...e));else if(jt(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&&(l=Math.max(...e));else if(jt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&qz.test(a)){var d=qz.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var g=[s,l];if(bd(g))return e==null?g:b8(g,e,n)}}}var ug=1e9,yye={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},xD,wr=!0,xo="[DecimalError] ",Ih=xo+"Invalid argument: ",gD=xo+"Exponent out of range: ",dg=Math.floor,mh=Math.pow,vye=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ss,Fi=1e7,gr=7,NK=9007199254740991,_w=dg(NK/gr),Rt={};Rt.absoluteValue=Rt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Rt.comparedTo=Rt.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};Rt.decimalPlaces=Rt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*gr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Rt.dividedBy=Rt.div=function(t){return kc(this,new this.constructor(t))};Rt.dividedToIntegerBy=Rt.idiv=function(t){var e=this,n=e.constructor;return lr(kc(e,new n(t),0,1),n.precision)};Rt.equals=Rt.eq=function(t){return!this.cmp(t)};Rt.exponent=function(){return di(this)};Rt.greaterThan=Rt.gt=function(t){return this.cmp(t)>0};Rt.greaterThanOrEqualTo=Rt.gte=function(t){return this.cmp(t)>=0};Rt.isInteger=Rt.isint=function(){return this.e>this.d.length-2};Rt.isNegative=Rt.isneg=function(){return this.s<0};Rt.isPositive=Rt.ispos=function(){return this.s>0};Rt.isZero=function(){return this.s===0};Rt.lessThan=Rt.lt=function(t){return this.cmp(t)<0};Rt.lessThanOrEqualTo=Rt.lte=function(t){return this.cmp(t)<1};Rt.logarithm=Rt.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(Ss))throw Error(xo+"NaN");if(n.s<1)throw Error(xo+(n.s?"NaN":"-Infinity"));return n.eq(Ss)?new r(0):(wr=!1,e=kc(W0(n,a),W0(t,a),a),wr=!0,lr(e,i))};Rt.minus=Rt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?PK(e,t):CK(e,(t.s=-t.s,t))};Rt.modulo=Rt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(xo+"NaN");return n.s?(wr=!1,e=kc(n,t,0,1).times(t),wr=!0,n.minus(e)):lr(new r(n),i)};Rt.naturalExponential=Rt.exp=function(){return kK(this)};Rt.naturalLogarithm=Rt.ln=function(){return W0(this)};Rt.negated=Rt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Rt.plus=Rt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?CK(e,t):PK(e,(t.s=-t.s,t))};Rt.precision=Rt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Ih+t);if(e=di(i)+1,r=i.d.length-1,n=r*gr+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};Rt.squareRoot=Rt.sqrt=function(){var t,e,n,r,i,a,s,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(xo+"NaN")}for(t=di(l),wr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=dl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=dg((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(kc(l,a,s+2)).times(.5),dl(a.d).slice(0,s)===(e=dl(r.d)).slice(0,s)){if(e=e.slice(s-3,s+1),i==s&&e=="4999"){if(lr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;s+=4}return wr=!0,lr(r,n)};Rt.times=Rt.mul=function(t){var e,n,r,i,a,s,l,c,u,d=this,f=d.constructor,g=d.d,p=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=g.length,u=p.length,c<u&&(a=g,g=p,p=a,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;)l=a[i]+p[r]*g[i-r-1]+e,a[i--]=l%Fi|0,e=l/Fi|0;a[i]=(a[i]+e)%Fi|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,wr?lr(t,f.precision):t};Rt.toDecimalPlaces=Rt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(vl(t,0,ug),e===void 0?e=r.rounding:vl(e,0,8),lr(n,t+di(n)+1,e))};Rt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=sf(r,!0):(vl(t,0,ug),e===void 0?e=i.rounding:vl(e,0,8),r=lr(new i(r),t+1,e),n=sf(r,!0,t+1)),n};Rt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?sf(i):(vl(t,0,ug),e===void 0?e=a.rounding:vl(e,0,8),r=lr(new a(i),t+di(i)+1,e),n=sf(r.abs(),!1,t+di(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Rt.toInteger=Rt.toint=function(){var t=this,e=t.constructor;return lr(new e(t),di(t)+1,e.rounding)};Rt.toNumber=function(){return+this};Rt.toPower=Rt.pow=function(t){var e,n,r,i,a,s,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(Ss);if(l=new c(l),!l.s){if(t.s<1)throw Error(xo+"Infinity");return l}if(l.eq(Ss))return l;if(r=c.precision,t.eq(Ss))return lr(l,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=l.s,s){if((n=d<0?-d:d)<=NK){for(i=new c(Ss),e=Math.ceil(r/gr+4),wr=!1;n%2&&(i=i.times(l),v8(i.d,e)),n=dg(n/2),n!==0;)l=l.times(l),v8(l.d,e);return wr=!0,t.s<0?new c(Ss).div(i):lr(i,r)}}else if(a<0)throw Error(xo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,wr=!1,i=t.times(W0(l,r+u)),wr=!0,i=kK(i),i.s=a,i};Rt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=di(i),r=sf(i,n<=a.toExpNeg||n>=a.toExpPos)):(vl(t,1,ug),e===void 0?e=a.rounding:vl(e,0,8),i=lr(new a(i),t,e),n=di(i),r=sf(i,t<=n||n<=a.toExpNeg,t)),r};Rt.toSignificantDigits=Rt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(vl(t,1,ug),e===void 0?e=r.rounding:vl(e,0,8)),lr(new r(n),t,e)};Rt.toString=Rt.valueOf=Rt.val=Rt.toJSON=Rt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=di(t),n=t.constructor;return sf(t,e<=n.toExpNeg||e>=n.toExpPos)};function CK(t,e){var n,r,i,a,s,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),wr?lr(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,l=u.length):(r=u,i=s,l=c.length),s=Math.ceil(f/gr),l=s>l?s+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/Fi|0,c[a]%=Fi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,wr?lr(e,f):e}function vl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Ih+t)}function dl(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=gr-r.length,n&&(a+=Uu(n)),a+=r;s=t[e],r=s+"",n=gr-r.length,n&&(a+=Uu(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var kc=(function(){function t(r,i){var a,s=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+s,r[l]=a%Fi|0,s=a/Fi|0;return s&&r.unshift(s),r}function e(r,i,a,s){var l,c;if(a!=s)c=a>s?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var s=0;a--;)r[a]-=s,s=r[a]<i[a]?1:0,r[a]=s*Fi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,s){var l,c,u,d,f,g,p,x,v,y,b,E,w,T,A,C,N,F,k=r.constructor,R=r.s==i.s?1:-1,I=r.d,L=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(xo+"Division by zero");for(c=r.e-i.e,N=L.length,A=I.length,p=new k(R),x=p.d=[],u=0;L[u]==(I[u]||0);)++u;if(L[u]>(I[u]||0)&&--c,a==null?E=a=k.precision:s?E=a+(di(r)-di(i))+1:E=a,E<0)return new k(0);if(E=E/gr+2|0,u=0,N==1)for(d=0,L=L[0],E++;(u<A||d)&&E--;u++)w=d*Fi+(I[u]||0),x[u]=w/L|0,d=w%L|0;else{for(d=Fi/(L[0]+1)|0,d>1&&(L=t(L,d),I=t(I,d),N=L.length,A=I.length),T=N,v=I.slice(0,N),y=v.length;y<N;)v[y++]=0;F=L.slice(),F.unshift(0),C=L[0],L[1]>=Fi/2&&++C;do d=0,l=e(L,v,N,y),l<0?(b=v[0],N!=y&&(b=b*Fi+(v[1]||0)),d=b/C|0,d>1?(d>=Fi&&(d=Fi-1),f=t(L,d),g=f.length,y=v.length,l=e(f,v,g,y),l==1&&(d--,n(f,N<g?F:L,g))):(d==0&&(l=d=1),f=L.slice()),g=f.length,g<y&&f.unshift(0),n(v,f,y),l==-1&&(y=v.length,l=e(L,v,N,y),l<1&&(d++,n(v,N<y?F:L,y))),y=v.length):l===0&&(d++,v=[0]),x[u++]=d,l&&v[0]?v[y++]=I[T]||0:(v=[I[T]],y=1);while((T++<A||v[0]!==void 0)&&E--)}return x[0]||x.shift(),p.e=c,lr(p,s?a+di(p)+1:a)}})();function kK(t,e){var n,r,i,a,s,l,c=0,u=0,d=t.constructor,f=d.precision;if(di(t)>16)throw Error(gD+di(t));if(!t.s)return new d(Ss);for(wr=!1,l=f,s=new d(.03125);t.abs().gte(.1);)t=t.times(s),u+=5;for(r=Math.log(mh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Ss),d.precision=l;;){if(i=lr(i.times(t),l),n=n.times(++c),s=a.plus(kc(i,n,l)),dl(s.d).slice(0,l)===dl(a.d).slice(0,l)){for(;u--;)a=lr(a.times(a),l);return d.precision=f,e==null?(wr=!0,lr(a,f)):a}a=s}}function di(t){for(var e=t.e*gr,n=t.d[0];n>=10;n/=10)e++;return e}function lN(t,e,n){if(e>t.LN10.sd())throw wr=!0,n&&(t.precision=n),Error(xo+"LN10 precision limit exceeded");return lr(new t(t.LN10),e)}function Uu(t){for(var e="";t--;)e+="0";return e}function W0(t,e){var n,r,i,a,s,l,c,u,d,f=1,g=10,p=t,x=p.d,v=p.constructor,y=v.precision;if(p.s<1)throw Error(xo+(p.s?"NaN":"-Infinity"));if(p.eq(Ss))return new v(0);if(e==null?(wr=!1,u=y):u=e,p.eq(10))return e==null&&(wr=!0),lN(v,u);if(u+=g,v.precision=u,n=dl(x),r=n.charAt(0),a=di(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=dl(p.d),r=n.charAt(0),f++;a=di(p),r>1?(p=new v("0."+n),a++):p=new v(r+"."+n.slice(1))}else return c=lN(v,u+2,y).times(a+""),p=W0(new v(r+"."+n.slice(1)),u-g).plus(c),v.precision=y,e==null?(wr=!0,lr(p,y)):p;for(l=s=p=kc(p.minus(Ss),p.plus(Ss),u),d=lr(p.times(p),u),i=3;;){if(s=lr(s.times(d),u),c=l.plus(kc(s,new v(i),u)),dl(c.d).slice(0,u)===dl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(lN(v,u+2,y).times(a+""))),l=kc(l,new v(f),u),v.precision=y,e==null?(wr=!0,lr(l,y)):l;l=c,i+=2}}function y8(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=dg(n/gr),t.d=[],r=(n+1)%gr,n<0&&(r+=gr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=gr;r<i;)t.d.push(+e.slice(r,r+=gr));e=e.slice(r),r=gr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),wr&&(t.e>_w||t.e<-_w))throw Error(gD+n)}else t.s=0,t.e=0,t.d=[0];return t}function lr(t,e,n){var r,i,a,s,l,c,u,d,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(r=e-s,r<0)r+=gr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/gr),a=f.length,d>=a)return t;for(u=a=f[d],s=1;a>=10;a/=10)s++;r%=gr,i=r-gr+s}if(n!==void 0&&(a=mh(10,s-i-1),l=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/mh(10,s-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=di(t),f.length=1,e=e-a-1,f[0]=mh(10,(gr-e%gr)%gr),t.e=dg(-e/gr)||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=mh(10,gr-r),f[d]=i>0?(u/mh(10,s-i)%mh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Fi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Fi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(wr&&(t.e>_w||t.e<-_w))throw Error(gD+di(t));return t}function PK(t,e){var n,r,i,a,s,l,c,u,d,f,g=t.constructor,p=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),wr?lr(e,p):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,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(p/gr),l)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}s=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>s;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=Fi-1;--c[a],c[i]+=Fi}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,wr?lr(e,p):e):new g(0)}function sf(t,e,n){var r,i=di(t),a=dl(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Uu(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Uu(-i-1)+a,n&&(r=n-s)>0&&(a+=Uu(r))):i>=s?(a+=Uu(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+Uu(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=Uu(r))),t.s<0?"-"+a:a}function v8(t,e){if(t.length>e)return t.length=e,!0}function jK(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(Ih+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 y8(s,a.toString())}else if(typeof a!="string")throw Error(Ih+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,vye.test(a))y8(s,a);else throw Error(Ih+a)}if(i.prototype=Rt,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=jK,i.config=i.set=_ye,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 _ye(t){if(!t||typeof t!="object")throw Error(xo+"Object expected");var e,n,r,i=["precision",1,ug,"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(dg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Ih+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Ih+n+": "+r);return this}var xD=jK(yye);Ss=new xD(1);const Vn=xD;var wye=t=>t,RK={},DK=t=>t===RK,_8=t=>function e(){return arguments.length===0||arguments.length===1&&DK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},OK=(t,e)=>t===1?e:_8(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!==RK).length;return a>=t?e(...r):OK(t-a,_8(function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];var u=r.map(d=>DK(d)?l.shift():d);return e(...u,...l)}))}),Sye=t=>OK(t.length,t),H3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Mye=Sye((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Eye=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return wye;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((l,c)=>c(l),a(...arguments))}},$3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function LK(t){var e;return t===0?e=1:e=Math.floor(new Vn(t).abs().log(10).toNumber())+1,e}function IK(t,e,n){for(var r=new Vn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var FK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},UK=(t,e,n)=>{if(t.lte(0))return new Vn(0);var r=LK(t.toNumber()),i=new Vn(10).pow(r),a=t.div(i),s=r!==1?.05:.1,l=new Vn(Math.ceil(a.div(s).toNumber())).add(n).mul(s),c=l.mul(i);return e?new Vn(c.toNumber()):new Vn(Math.ceil(c.toNumber()))},Tye=(t,e,n)=>{var r=new Vn(1),i=new Vn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Vn(10).pow(LK(t)-1),i=new Vn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Vn(Math.floor(t)))}else t===0?i=new Vn(Math.floor((e-1)/2)):n||(i=new Vn(Math.floor(t)));var s=Math.floor((e-1)/2),l=Eye(Mye(c=>i.add(new Vn(c-s).mul(r)).toNumber()),H3);return l(0,e)},zK=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 Vn(0),tickMin:new Vn(0),tickMax:new Vn(0)};var s=UK(new Vn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Vn(0):(l=new Vn(e).add(n).div(2),l=l.sub(new Vn(l).mod(s)));var c=Math.ceil(l.sub(e).div(s).toNumber()),u=Math.ceil(new Vn(n).sub(l).div(s).toNumber()),d=c+u+1;return d>r?zK(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:l.sub(new Vn(c).mul(s)),tickMax:l.add(new Vn(u).mul(s))})},Aye=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),[l,c]=FK([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...H3(0,i-1).map(()=>1/0)]:[...H3(0,i-1).map(()=>-1/0),c];return n>r?$3(u):u}if(l===c)return Tye(l,i,a);var{step:d,tickMin:f,tickMax:g}=zK(l,c,s,a,0),p=IK(f,g.add(new Vn(.1).mul(d)),d);return n>r?$3(p):p},Nye=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,l]=FK([r,i]);if(s===-1/0||l===1/0)return[r,i];if(s===l)return[s];var c=Math.max(n,2),u=UK(new Vn(l).sub(s).div(c-1),a,0),d=[...IK(new Vn(s),new Vn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?$3(d):d},BK=t=>t.rootProps.maxBarSize,Cye=t=>t.rootProps.barGap,HK=t=>t.rootProps.barCategoryGap,kye=t=>t.rootProps.barSize,Hb=t=>t.rootProps.stackOffset,$K=t=>t.rootProps.reverseStackOrder,bD=t=>t.options.chartName,yD=t=>t.rootProps.syncId,VK=t=>t.rootProps.syncMethod,vD=t=>t.options.eventEmitter,Pye=t=>t.rootProps.baseValue,$r={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},bc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},_s={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},CM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},jye={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:bc.angleAxisId,includeHidden:!1,name:void 0,reversed:bc.reversed,scale:bc.scale,tick:bc.tick,tickCount:void 0,ticks:void 0,type:bc.type,unit:void 0},Rye={allowDataOverflow:_s.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:_s.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:_s.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:_s.scale,tick:_s.tick,tickCount:_s.tickCount,ticks:void 0,type:_s.type,unit:void 0},Dye={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:bc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:bc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:bc.scale,tick:bc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Oye={allowDataOverflow:_s.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:_s.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:_s.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:_s.scale,tick:_s.tick,tickCount:_s.tickCount,ticks:void 0,type:"category",unit:void 0},_D=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Dye:jye,wD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Oye:Rye,kM=t=>t.polarOptions,SD=Ze([Yc,Zc,Mi],Hq),GK=Ze([kM,SD],(t,e)=>{if(t!=null)return va(t.innerRadius,e,0)}),WK=Ze([kM,SD],(t,e)=>{if(t!=null)return va(t.outerRadius,e,e*.8)}),Lye=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},qK=Ze([kM],Lye);Ze([_D,qK],CM);var KK=Ze([SD,GK,WK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ze([wD,KK],CM);var XK=Ze([vn,kM,GK,WK,Yc,Zc],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:s,cy:l,startAngle:c,endAngle:u}=e;return{cx:va(s,i,i/2),cy:va(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Mr=(t,e)=>e,$b=(t,e,n)=>n;function PM(t){return t?.id}function YK(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,s=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=PM(l);u.forEach((f,g)=>{var p=a==null||i?g:String(Wn(f,a,null)),x=Wn(f,l.dataKey,0),v;s.has(p)?v=s.get(p):v={},Object.assign(v,{[d]:x}),s.set(p,v)})}}),Array.from(s.values())}function jM(t){return t.stackId!=null&&t.dataKey!=null}var RM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function DM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Iye(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 Ai=t=>{var e=vn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},hg=t=>t.tooltip.settings.axisId;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 ww(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){Fye(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 Fye(t,e,n){return(e=Uye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Uye(t){var e=zye(t,"string");return typeof e=="symbol"?e:e+""}function zye(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var V3=[0,"auto"],Oi={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},ZK=(t,e)=>t.cartesianAxis.xAxis[e],jl=(t,e)=>{var n=ZK(t,e);return n??Oi},Li={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:V3,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:Db},QK=(t,e)=>t.cartesianAxis.yAxis[e],Rl=(t,e)=>{var n=QK(t,e);return n??Li},Bye={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:""},MD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Bye},Dr=(t,e,n)=>{switch(e){case"xAxis":return jl(t,n);case"yAxis":return Rl(t,n);case"zAxis":return MD(t,n);case"angleAxis":return _D(t,n);case"radiusAxis":return wD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Hye=(t,e,n)=>{switch(e){case"xAxis":return jl(t,n);case"yAxis":return Rl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Vb=(t,e,n)=>{switch(e){case"xAxis":return jl(t,n);case"yAxis":return Rl(t,n);case"angleAxis":return _D(t,n);case"radiusAxis":return wD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},JK=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function ED(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 Gb=t=>t.graphicalItems.cartesianItems,$ye=Ze([Mr,$b],ED),TD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Wb=Ze([Gb,Dr,$ye],TD,{memoizeOptions:{resultEqualityCheck:DM}}),eX=Ze([Wb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(jM)),tX=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Vye=Ze([Wb],tX),AD=t=>t.map(e=>e.data).filter(Boolean).flat(1),Gye=Ze([Wb],AD,{memoizeOptions:{resultEqualityCheck:DM}}),ND=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},CD=Ze([Gye,Bb],ND),kD=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Wn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Wn(i,r)}))):t.map(r=>({value:r})),OM=Ze([CD,Dr,Wb],kD);function nX(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function m1(t){if(po(t)||t instanceof Date){var e=Number(t);if(qn(e))return e}}function S8(t){if(Array.isArray(t)){var e=[m1(t[0]),m1(t[1])];return bd(e)?e:void 0}var n=m1(t);if(n!=null)return[n,n]}function Gc(t){return t.map(m1).filter(Hhe)}function Wye(t,e,n){return!n||typeof e!="number"||as(e)?[]:n.length?Gc(n.flatMap(r=>{var i=Wn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!qn(a)||!qn(s)))return[e-a,e+s]})):[]}var Ni=t=>{var e=Ai(t),n=hg(t);return Vb(t,e,n)},qb=Ze([Ni],t=>t?.dataKey),qye=Ze([eX,Bb,Ni],YK),rX=(t,e,n,r)=>{var i={},a=e.reduce((s,l)=>(l.stackId==null||(s[l.stackId]==null&&(s[l.stackId]=[]),s[l.stackId].push(l)),s),i);return Object.fromEntries(Object.entries(a).map(s=>{var[l,c]=s,u=r?[...c].reverse():c,d=u.map(PM);return[l,{stackedData:hpe(t,d,n),graphicalItems:u}]}))},q0=Ze([qye,eX,Hb,$K],rX),iX=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=gpe(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},Kye=Ze([Dr],t=>t.allowDataOverflow),PD=t=>{var e;if(t==null||!("domain"in t))return V3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Gc(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:V3},jD=Ze([Dr],PD),RD=Ze([jD,Kye],AK),Xye=Ze([q0,jd,Mr,RD],iX,{memoizeOptions:{resultEqualityCheck:RM}}),LM=t=>t.errorBars,Yye=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>nX(n,r)),Sw=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),l=Math.max(...a);return[s,l]}},DD=(t,e,n,r,i)=>{var a,s;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(b=>nX(i,b)),g=Wn(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=Wye(l,g,f);if(p.length>=2){var x=Math.min(...p),v=Math.max(...p);(a==null||x<a)&&(a=x),(s==null||v>s)&&(s=v)}var y=S8(g);y!=null&&(a=a==null?y[0]:Math.min(a,y[0]),s=s==null?y[1]:Math.max(s,y[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=S8(Wn(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),s=s==null?c[1]:Math.max(s,c[1]))}),qn(a)&&qn(s))return[a,s]},Zye=Ze([CD,Dr,Vye,LM,Mr],DD,{memoizeOptions:{resultEqualityCheck:RM}});function Qye(t){var{value:e}=t;if(po(e)||e instanceof Date)return e}var Jye=(t,e,n)=>{var r=t.map(Qye).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&yW(r))?Wq(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},aX=t=>t.referenceElements.dots,fg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),eve=Ze([aX,Mr,$b],fg),sX=t=>t.referenceElements.areas,tve=Ze([sX,Mr,$b],fg),oX=t=>t.referenceElements.lines,nve=Ze([oX,Mr,$b],fg),lX=(t,e)=>{var n=Gc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},rve=Ze(eve,Mr,lX),cX=(t,e)=>{var n=Gc(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)]},ive=Ze([tve,Mr],cX);function ave(t){var e;if(t.x!=null)return Gc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Gc(n)}function sve(t){var e;if(t.y!=null)return Gc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Gc(n)}var uX=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?ave(r):sve(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},ove=Ze([nve,Mr],uX),lve=Ze(rve,ove,ive,(t,e,n)=>Sw(t,n,e)),OD=(t,e,n,r,i,a,s,l)=>{if(n!=null)return n;var c=s==="vertical"&&l==="xAxis"||s==="horizontal"&&l==="yAxis",u=c?Sw(r,a,i):Sw(a,i);return bye(e,u,t.allowDataOverflow)},cve=Ze([Dr,jD,RD,Xye,Zye,lve,vn,Mr],OD,{memoizeOptions:{resultEqualityCheck:RM}}),uve=[0,1],LD=(t,e,n,r,i,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:l,type:c}=t,u=Pl(e,a);if(u&&l==null){var d;return Wq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?Jye(r,t,u):i==="expand"?uve:s}},ID=Ze([Dr,vn,CD,OM,Hb,Mr,cve],LD),dX=(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 l="scale".concat(Nb(a));return l in Gx?l:"point"}}},mg=Ze([Dr,vn,JK,bD,Mr],dX);function dve(t){if(t!=null){if(t in Gx)return Gx[t]();var e="scale".concat(Nb(t));if(e in Gx)return Gx[e]()}}function FD(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=dve(e);if(i!=null){var a=i.domain(n).range(r);return ope(a),a}}}var UD=(t,e,n)=>{var r=PD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&bd(t))return Aye(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&bd(t))return Nye(t,e.tickCount,e.allowDecimals)}},zD=Ze([ID,Vb,mg],UD),BD=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&bd(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],s=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(s,l)]}return e},hve=Ze([Dr,ID,zD,Mr],BD),fve=Ze(OM,Dr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Gc(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var s=r[a+1]-r[a];n=Math.min(n,s)}return n/i}}),hX=Ze(fve,vn,HK,Mi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!qn(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=va(n,t*a),l=t*a/2;return l-s-(l-s)/a*s}return 0}),mve=(t,e)=>{var n=jl(t,e);return n==null||typeof n.padding!="string"?0:hX(t,"xAxis",e,n.padding)},pve=(t,e)=>{var n=Rl(t,e);return n==null||typeof n.padding!="string"?0:hX(t,"yAxis",e,n.padding)},gve=Ze(jl,mve,(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}}),xve=Ze(Rl,pve,(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}}),bve=Ze([Mi,gve,bM,xM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),yve=Ze([Mi,vn,xve,bM,xM,(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]}),Kb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return bve(t,n,r);case"yAxis":return yve(t,n,r);case"zAxis":return(i=MD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return qK(t);case"radiusAxis":return KK(t,n);default:return}},fX=Ze([Dr,Kb],CM),yd=Ze([Dr,mg,hve,fX],FD);Ze([Wb,LM,Mr],Yye);function mX(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var IM=(t,e)=>e,FM=(t,e,n)=>n,vve=Ze(pM,IM,FM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(mX)),_ve=Ze(gM,IM,FM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(mX)),pX=(t,e)=>({width:t.width,height:e.height}),wve=(t,e)=>{var n=typeof e.width=="number"?e.width:Db;return{width:n,height:t.height}},gX=Ze(Mi,jl,pX),Sve=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Mve=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Eve=Ze(Zc,Mi,vve,IM,FM,(t,e,n,r,i)=>{var a={},s;return n.forEach(l=>{var c=pX(e,l);s==null&&(s=Sve(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=s-Number(u)*c.height,s+=(u?-1:1)*c.height}),a}),Tve=Ze(Yc,Mi,_ve,IM,FM,(t,e,n,r,i)=>{var a={},s;return n.forEach(l=>{var c=wve(e,l);s==null&&(s=Mve(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=s-Number(u)*c.width,s+=(u?-1:1)*c.width}),a}),Ave=(t,e)=>{var n=jl(t,e);if(n!=null)return Eve(t,n.orientation,n.mirror)},Nve=Ze([Mi,jl,Ave,(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}}}),Cve=(t,e)=>{var n=Rl(t,e);if(n!=null)return Tve(t,n.orientation,n.mirror)},kve=Ze([Mi,Rl,Cve,(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}}}),xX=Ze(Mi,Rl,(t,e)=>{var n=typeof e.width=="number"?e.width:Db;return{width:n,height:t.height}}),M8=(t,e,n)=>{switch(e){case"xAxis":return gX(t,n).width;case"yAxis":return xX(t,n).height;default:return}},bX=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:s}=n,l=Pl(t,r),c=e.map(u=>u.value);if(s&&l&&a==="category"&&i&&yW(c))return c}},HD=Ze([vn,OM,Dr,Mr],bX),yX=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,s=Pl(t,r);if(s&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},$D=Ze([vn,OM,Vb,Mr],yX),E8=Ze([vn,Hye,mg,yd,HD,$D,Kb,zD,Mr],(t,e,n,r,i,a,s,l,c)=>{if(e!=null){var u=Pl(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:s,realScaleType:n,scale:r}}}),Pve=(t,e,n,r,i,a,s,l,c)=>{if(!(e==null||r==null)){var u=Pl(t,c),{type:d,ticks:f,tickCount:g}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Bi(a[0]-a[1])*2*x:x;var v=f||i;if(v){var y=v.map((b,E)=>{var w=s?s.indexOf(b):b;return{index:E,coordinate:r(w)+x,value:b,offset:x}});return y.filter(b=>qn(b.coordinate))}return u&&l?l.map((b,E)=>({coordinate:r(b)+x,value:b,index:E,offset:x})).filter(b=>qn(b.coordinate)):r.ticks?r.ticks(g).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,E)=>({coordinate:r(b)+x,value:s?s[b]:b,index:E,offset:x}))}},vX=Ze([vn,Vb,mg,yd,zD,Kb,HD,$D,Mr],Pve),jve=(t,e,n,r,i,a,s)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Pl(t,s),{tickCount:c}=e,u=0;return u=s==="angleAxis"&&r?.length>=2?Bi(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},_l=Ze([vn,Vb,yd,Kb,HD,$D,Mr],jve),wl=Ze(Dr,yd,(t,e)=>{if(!(t==null||e==null))return ww(ww({},t),{},{scale:e})}),Rve=Ze([Dr,mg,ID,fX],FD);Ze((t,e,n)=>MD(t,n),Rve,(t,e)=>{if(!(t==null||e==null))return ww(ww({},t),{},{scale:e})});var Dve=Ze([vn,pM,gM],(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}}),_X=t=>t.options.defaultTooltipEventType,wX=t=>t.options.validateTooltipEventTypes;function SX(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function VD(t,e){var n=_X(t),r=wX(t);return SX(e,n,r)}function Ove(t){return kt(e=>VD(e,t))}var MX=(t,e)=>{var n,r=Number(e);if(!(as(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},Lve=t=>t.tooltip.settings,qu={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},Ive={itemInteraction:{click:qu,hover:qu},axisInteraction:{click:qu,hover:qu},keyboardInteraction:qu,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}},EX=ss({name:"tooltip",initialState:Ive,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:vr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=zo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:vr()},removeTooltipEntrySettings:{reducer(t,e){var n=zo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:vr()},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:Fve,replaceTooltipEntrySettings:Uve,removeTooltipEntrySettings:zve,setTooltipSettingsState:Bve,setActiveMouseOverItemIndex:TX,mouseLeaveItem:Hve,mouseLeaveChart:AX,setActiveClickItemIndex:$ve,setMouseOverAxisIndex:NX,setMouseClickAxisIndex:Vve,setSyncInteraction:G3,setKeyboardInteraction:W3}=EX.actions,Gve=EX.reducer;function T8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T8(Object(n),!0).forEach(function(r){Wve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Wve(t,e,n){return(e=qve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qve(t){var e=Kve(t,"string");return typeof e=="symbol"?e:e+""}function Kve(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 Xve(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function Yve(t){return t.index!=null}var CX=(t,e,n,r)=>{if(e==null)return qu;var i=Xve(t,e,n);if(i==null)return qu;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(Yve(i)){if(a)return zv(zv({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return zv(zv({},qu),{},{coordinate:i.coordinate})};function Zve(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 Qve(t,e){var n=Zve(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 Jve(t,e,n){if(n==null||e==null)return!0;var r=Wn(t,e);return r==null||!bd(n)?!0:Qve(r,n)}var GD=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!qn(a))return i;var s=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(s,Math.min(a,l)),u=e[c];return u==null||Jve(u,n,r)?String(c):null},kX=(t,e,n,r,i,a,s,l)=>{if(!(a==null||l==null)){var c=s[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},PX=(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})},Xb=t=>t.options.tooltipPayloadSearcher,pg=t=>t.tooltip;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 N8(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)}function r_e(t,e){return t??e}var jX=(t,e,n,r,i,a,s)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,p)=>{var x,{dataDefinedOnItem:v,settings:y}=p,b=r_e(v,l),E=Array.isArray(b)?mq(b,u,d):b,w=(x=y?.dataKey)!==null&&x!==void 0?x:r,T=y?.nameKey,A;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&s==="axis"?A=vW(E,r,i):A=a(E,e,c,T),Array.isArray(A))A.forEach(N=>{var F=N8(N8({},y),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(Kz({tooltipEntrySettings:F,dataKey:N.dataKey,payload:N.payload,value:Wn(N.payload,N.dataKey),name:N.name}))});else{var C;g.push(Kz({tooltipEntrySettings:y,dataKey:w,payload:A,value:Wn(A,w),name:(C=Wn(A,T))!==null&&C!==void 0?C:y?.name}))}return g},f)}},WD=Ze([Ni,vn,JK,bD,Ai],dX),i_e=Ze([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),a_e=Ze([Ai,hg],ED),Yb=Ze([i_e,Ni,a_e],TD,{memoizeOptions:{resultEqualityCheck:DM}}),s_e=Ze([Yb],t=>t.filter(jM)),o_e=Ze([Yb],AD,{memoizeOptions:{resultEqualityCheck:DM}}),gg=Ze([o_e,jd],ND),l_e=Ze([s_e,jd,Ni],YK),qD=Ze([gg,Ni,Yb],kD),RX=Ze([Ni],PD),c_e=Ze([Ni],t=>t.allowDataOverflow),DX=Ze([RX,c_e],AK),u_e=Ze([Yb],t=>t.filter(jM)),d_e=Ze([l_e,u_e,Hb,$K],rX),h_e=Ze([d_e,jd,Ai,DX],iX),f_e=Ze([Yb],tX),m_e=Ze([gg,Ni,f_e,LM,Ai],DD,{memoizeOptions:{resultEqualityCheck:RM}}),p_e=Ze([aX,Ai,hg],fg),g_e=Ze([p_e,Ai],lX),x_e=Ze([sX,Ai,hg],fg),b_e=Ze([x_e,Ai],cX),y_e=Ze([oX,Ai,hg],fg),v_e=Ze([y_e,Ai],uX),__e=Ze([g_e,v_e,b_e],Sw),w_e=Ze([Ni,RX,DX,h_e,m_e,__e,vn,Ai],OD),Zb=Ze([Ni,vn,gg,qD,Hb,Ai,w_e],LD),S_e=Ze([Zb,Ni,WD],UD),M_e=Ze([Ni,Zb,S_e,Ai],BD),OX=t=>{var e=Ai(t),n=hg(t),r=!1;return Kb(t,e,n,r)},LX=Ze([Ni,OX],CM),IX=Ze([Ni,WD,M_e,LX],FD),E_e=Ze([vn,qD,Ni,Ai],bX),T_e=Ze([vn,qD,Ni,Ai],yX),A_e=(t,e,n,r,i,a,s,l)=>{if(e){var{type:c}=e,u=Pl(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?Bi(i[0]-i[1])*2*f:f,u&&s?s.map((g,p)=>({coordinate:r(g)+f,value:g,index:p,offset:f})):r.domain().map((g,p)=>({coordinate:r(g)+f,value:a?a[g]:g,index:p,offset:f}))}}},Jc=Ze([vn,Ni,WD,IX,OX,E_e,T_e,Ai],A_e),KD=Ze([_X,wX,Lve],(t,e,n)=>SX(n.shared,t,e)),FX=t=>t.tooltip.settings.trigger,XD=t=>t.tooltip.settings.defaultIndex,Qb=Ze([pg,KD,FX,XD],CX),vd=Ze([Qb,gg,qb,Zb],GD),UX=Ze([Jc,vd],MX),YD=Ze([Qb],t=>{if(t)return t.dataKey}),N_e=Ze([Qb],t=>{if(t)return t.graphicalItemId}),zX=Ze([pg,KD,FX,XD],PX),C_e=Ze([Yc,Zc,vn,Mi,Jc,XD,zX,Xb],kX),k_e=Ze([Qb,C_e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),P_e=Ze([Qb],t=>t.active),j_e=Ze([zX,vd,jd,qb,UX,Xb,KD],jX),R_e=Ze([j_e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});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 k8(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){D_e(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 D_e(t,e,n){return(e=O_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O_e(t){var e=L_e(t,"string");return typeof e=="symbol"?e:e+""}function L_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 I_e=()=>kt(Ni),F_e=()=>{var t=I_e(),e=kt(Jc),n=kt(IX);return xd(!t||!n?void 0:k8(k8({},t),{},{scale:n}),e)};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 om(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){U_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 U_e(t,e,n){return(e=z_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function z_e(t){var e=B_e(t,"string");return typeof e=="symbol"?e:e+""}function B_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 H_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}},$_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 om(om(om({},r),ci(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}var l=i.coordinate,{angle:c}=r;return om(om(om({},r),ci(r.cx,r.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function V_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 BX=(t,e,n,r,i)=>{var a,s=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,g=void 0;if(Bi(d-u)!==Bi(f-d)){var p=[];if(Bi(f-d)===Bi(i[1]-i[0])){g=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{g=u;var v=f+i[1]-i[0];p[0]=Math.min(d,(v+d)/2),p[1]=Math.max(d,(v+d)/2)}var y=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>y[0]&&t<=y[1]||t>=p[0]&&t<=p[1]){({index:s}=n[c]);break}}else{var b=Math.min(u,f),E=Math.max(u,f);if(t>(b+d)/2&&t<=(E+d)/2){({index:s}=n[c]);break}}}else if(e){for(var w=0;w<l;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:s}=e[w]);break}}return s},HX=()=>kt(bD),ZD=(t,e)=>e,$X=(t,e,n)=>n,QD=(t,e,n,r)=>r,G_e=Ze(Jc,t=>sM(t,e=>e.coordinate)),JD=Ze([pg,ZD,$X,QD],CX),eO=Ze([JD,gg,qb,Zb],GD),W_e=(t,e,n)=>{if(e!=null){var r=pg(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=Ze([pg,ZD,$X,QD],PX),Mw=Ze([Yc,Zc,vn,Mi,Jc,QD,VX,Xb],kX),q_e=Ze([JD,Mw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),GX=Ze([Jc,eO],MX),K_e=Ze([VX,eO,jd,qb,GX,Xb,ZD],jX),X_e=Ze([JD,eO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),Y_e=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&V_e(t,s)){var l=xpe(t,e),c=BX(l,a,i,n,r),u=H_e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},Z_e=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var l=Dxe(t,n);if(l){var c=bpe(l,e),u=BX(c,s,a,r,i),d=$_e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},Q_e=(t,e,n,r,i,a,s,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?Y_e(t,e,r,i,a,s,l):Z_e(t,e,n,r,i,a,s)},J_e=Ze(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),e1e=Ze(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values($r)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Iye}});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 R8(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){t1e(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 t1e(t,e,n){return(e=n1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n1e(t){var e=r1e(t,"string");return typeof e=="symbol"?e:e+""}function r1e(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 i1e={},a1e={zIndexMap:Object.values($r).reduce((t,e)=>R8(R8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),i1e)},s1e=new Set(Object.values($r));function o1e(t){return s1e.has(t)}var WX=ss({name:"zIndex",initialState:a1e,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:vr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!o1e(n)&&delete t.zIndexMap[n])},prepare:vr()},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:vr()},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:vr()}}}),{registerZIndexPortal:l1e,unregisterZIndexPortal:c1e,registerZIndexPortalId:u1e,unregisterZIndexPortalId:d1e}=WX.actions,h1e=WX.reducer;function wa(t){var{zIndex:e,children:n}=t,r=Ype(),i=r&&e!==void 0&&e!==0,a=Ei(),s=cr();M.useLayoutEffect(()=>i?(s(l1e({zIndex:e})),()=>{s(c1e({zIndex:e}))}):Cb,[s,e,i]);var l=kt(u=>J_e(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?wc.createPortal(n,c):null}function q3(){return q3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},q3.apply(null,arguments)}function D8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Bv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D8(Object(n),!0).forEach(function(r){f1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function f1e(t,e,n){return(e=m1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function m1e(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)}function g1e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return M.isValidElement(e)?M.cloneElement(e,r):M.createElement(n,r)}function x1e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:s,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,v,y;if(d==="ScatterChart")x=f,v=Xge,y=$r.cursorLine;else if(d==="BarChart")x=Yge(l,f,a,s),v=Bq,y=$r.cursorRectangle;else if(l==="radial"&&wW(f)){var{cx:b,cy:E,radius:w,startAngle:T,endAngle:A}=$q(f);x={cx:b,cy:E,startAngle:T,endAngle:A,innerRadius:w,outerRadius:w},v=Gq,y=$r.cursorLine}else x={points:Fxe(l,f,a)},v=cp,y=$r.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,N=Bv(Bv(Bv(Bv({stroke:"#ccc",pointerEvents:"none"},a),x),tf(c)),{},{payload:g,payloadIndex:p,className:Cn("recharts-tooltip-cursor",C)});return M.createElement(wa,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:y},M.createElement(g1e,{cursor:c,cursorComp:v,cursorProps:N}))}function b1e(t){var e=F_e(),n=Eq(),r=vf(),i=HX();return e==null||n==null||r==null||i==null?null:M.createElement(x1e,q3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var qX=M.createContext(null),y1e=()=>M.useContext(qX),cN={exports:{}},O8;function v1e(){return O8||(O8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,g),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function s(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,p=f.length,x=new Array(p);g<p;g++)x[g]=f[g].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,g,p,x){var v=n?n+u:u;if(!this._events[v])return!1;var y=this._events[v],b=arguments.length,E,w;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,f),!0;case 4:return y.fn.call(y.context,d,f,g),!0;case 5:return y.fn.call(y.context,d,f,g,p),!0;case 6:return y.fn.call(y.context,d,f,g,p,x),!0}for(w=1,E=new Array(b-1);w<b;w++)E[w-1]=arguments[w];y.fn.apply(y.context,E)}else{var T=y.length,A;for(w=0;w<T;w++)switch(y[w].once&&this.removeListener(u,y[w].fn,void 0,!0),b){case 1:y[w].fn.call(y[w].context);break;case 2:y[w].fn.call(y[w].context,d);break;case 3:y[w].fn.call(y[w].context,d,f);break;case 4:y[w].fn.call(y[w].context,d,f,g);break;default:if(!E)for(A=1,E=new Array(b-1);A<b;A++)E[A-1]=arguments[A];y[w].fn.apply(y[w].context,E)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,g){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return s(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&s(this,p);else{for(var v=0,y=[],b=x.length;v<b;v++)(x[v].fn!==d||g&&!x[v].once||f&&x[v].context!==f)&&y.push(x[v]);y.length?this._events[p]=y.length===1?y[0]:y:s(this,p)}return this},l.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},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(cN)),cN.exports}var _1e=v1e();const w1e=bo(_1e);var K0=new w1e,K3="recharts.syncEvent.tooltip",L8="recharts.syncEvent.brush";function UM(t,e){if(e){var n=Number.parseInt(e,10);if(!as(n))return t?.[n]}}var S1e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},KX=ss({name:"options",initialState:S1e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),M1e=KX.reducer,{createEventEmitter:E1e}=KX.actions;function T1e(t){return t.tooltip.syncInteraction}var A1e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},XX=ss({name:"chartData",initialState:A1e,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:I8,setDataStartEndIndexes:N1e,setComputedData:LWe}=XX.actions,C1e=XX.reducer,k1e=["x","y"];function F8(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 lm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F8(Object(n),!0).forEach(function(r){P1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function P1e(t,e,n){return(e=j1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j1e(t){var e=R1e(t,"string");return typeof e=="symbol"?e:e+""}function R1e(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 D1e(t,e){if(t==null)return{};var n,r,i=O1e(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 O1e(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 L1e(){var t=kt(yD),e=kt(vD),n=cr(),r=kt(VK),i=kt(Jc),a=vf(),s=Ob(),l=kt(c=>c.rootProps.className);M.useEffect(()=>{if(t==null)return Cb;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 p=d.payload.coordinate,{x,y:v}=p,y=D1e(p,k1e),{x:b,y:E,width:w,height:T}=d.payload.sourceViewBox,A=lm(lm({},y),{},{x:s.x+(w?(x-b)/w:0)*s.width,y:s.y+(T?(v-E)/T:0)*s.height});n(lm(lm({},d),{},{payload:lm(lm({},d.payload),{},{coordinate:A})}))}else n(d);return}if(i!=null){var C;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},F=r(i,N);C=i[F]}else r==="value"&&(C=i.find(K=>String(K.value)===d.payload.label));var{coordinate:k}=d.payload;if(C==null||d.payload.active===!1||k==null||s==null){n(G3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:I}=k,L=Math.min(R,s.x+s.width),q=Math.min(I,s.y+s.height),j={x:a==="horizontal"?C.coordinate:L,y:a==="horizontal"?q:C.coordinate},V=G3({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(V)}}};return K0.on(K3,c),()=>{K0.off(K3,c)}},[l,n,e,t,r,i,a,s])}function I1e(){var t=kt(yD),e=kt(vD),n=cr();M.useEffect(()=>{if(t==null)return Cb;var r=(i,a,s)=>{e!==s&&t===i&&n(N1e(a))};return K0.on(L8,r),()=>{K0.off(L8,r)}},[n,e,t])}function F1e(){var t=cr();M.useEffect(()=>{t(E1e())},[t]),L1e(),I1e()}function U1e(t,e,n,r,i,a){var s=kt(p=>W_e(p,t,e)),l=kt(vD),c=kt(yD),u=kt(VK),d=kt(T1e),f=d?.active,g=Ob();M.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=G3({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});K0.emit(K3,c,p,l)}},[f,n,s,i,r,l,c,u,a,g])}function U8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function z8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U8(Object(n),!0).forEach(function(r){z1e(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 z1e(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=H1e(t,"string");return typeof e=="symbol"?e:e+""}function H1e(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 $1e(t){return t.dataKey}function V1e(t,e){return M.isValidElement(t)?M.cloneElement(t,e):typeof t=="function"?M.createElement(t,e):M.createElement(Nge,e)}var B8=[],G1e={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 p1(t){var e,n,r=Rr(t,G1e),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:p,reverseDirection:x,useTranslate3d:v,wrapperStyle:y,cursor:b,shared:E,trigger:w,defaultIndex:T,portal:A,axisId:C}=r,N=cr(),F=typeof T=="number"?String(T):T;M.useEffect(()=>{N(Bve({shared:E,trigger:w,axisId:C,active:i,defaultIndex:F}))},[N,E,w,C,i,F]);var k=Ob(),R=Lq(),I=Ove(E),{activeIndex:L,isActive:q}=(e=kt(xe=>X_e(xe,I,w,F)))!==null&&e!==void 0?e:{},j=kt(xe=>K_e(xe,I,w,F)),V=kt(xe=>GX(xe,I,w,F)),K=kt(xe=>q_e(xe,I,w,F)),W=j,J=y1e(),ee=(n=i??q)!==null&&n!==void 0?n:!1,[Z,B]=FW([W,ee]),G=I==="axis"?V:void 0;U1e(I,w,K,G,L,ee);var Q=A??J;if(Q==null||k==null||I==null)return null;var te=W??B8;ee||(te=B8),u&&te.length&&(te=jW(te.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),g,$1e));var he=te.length>0,oe=M.createElement(Oge,{allowEscapeViewBox:a,animationDuration:s,animationEasing:l,isAnimationActive:d,active:ee,coordinate:K,hasPayload:he,offset:f,position:p,reverseDirection:x,useTranslate3d:v,viewBox:k,wrapperStyle:y,lastBoundingBox:Z,innerRef:B,hasPortalFromProps:!!A},V1e(c,z8(z8({},r),{},{payload:te,label:G,active:ee,activeIndex:L,coordinate:K,accessibilityLayer:R})));return M.createElement(M.Fragment,null,wc.createPortal(oe,Q),ee&&M.createElement(b1e,{cursor:b,tooltipEventType:I,coordinate:K,payload:te,index:L}))}var Jb=t=>null;Jb.displayName="Cell";function W1e(t,e,n){return(e=q1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q1e(t){var e=K1e(t,"string");return typeof e=="symbol"?e:e+""}function K1e(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 X1e{constructor(e){W1e(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 H8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Y1e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H8(Object(n),!0).forEach(function(r){Z1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Z1e(t,e,n){return(e=Q1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q1e(t){var e=J1e(t,"string");return typeof e=="symbol"?e:e+""}function J1e(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 ewe={cacheSize:2e3,enableCache:!0},YX=Y1e({},ewe),$8=new X1e(YX.cacheSize),twe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},V8="recharts_measurement_span";function nwe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(s,"|").concat(l)}var G8=(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,twe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},i0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||sg.isSsr)return{width:0,height:0};if(!YX.enableCache)return G8(e,n);var r=nwe(e,n),i=$8.get(r);if(i)return i;var a=G8(e,n);return $8.set(r,a),a},W8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,q8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,rwe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,iwe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,ZX={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},awe=Object.keys(ZX),np="NaN";function swe(t,e){return t*ZX[e]}class Ya{static parse(e){var n,[,r,i]=(n=iwe.exec(e))!==null&&n!==void 0?n:[];return new Ya(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,as(e)&&(this.unit=""),n!==""&&!rwe.test(n)&&(this.num=NaN,this.unit=""),awe.includes(n)&&(this.num=swe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Ya(NaN,""):new Ya(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Ya(NaN,""):new Ya(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ya(NaN,""):new Ya(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ya(NaN,""):new Ya(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return as(this.num)}}function QX(t){if(t.includes(np))return np;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=W8.exec(e))!==null&&n!==void 0?n:[],s=Ya.parse(r??""),l=Ya.parse(a??""),c=i==="*"?s.multiply(l):s.divide(l);if(c.isNaN())return np;e=e.replace(W8,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=q8.exec(e))!==null&&u!==void 0?u:[],p=Ya.parse(d??""),x=Ya.parse(g??""),v=f==="+"?p.add(x):p.subtract(x);if(v.isNaN())return np;e=e.replace(q8,v.toString())}return e}var K8=/\(([^()]*)\)/;function owe(t){for(var e=t,n;(n=K8.exec(e))!=null;){var[,r]=n;e=e.replace(K8,QX(r))}return e}function lwe(t){var e=t.replace(/\s+/g,"");return e=owe(e),e=QX(e),e}function cwe(t){try{return lwe(t)}catch{return np}}function uN(t){var e=cwe(t.slice(5,-1));return e===np?"":e}var uwe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],dwe=["dx","dy","angle","className","breakAll"];function X3(){return X3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},X3.apply(null,arguments)}function X8(t,e){if(t==null)return{};var n,r,i=hwe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function hwe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var JX=/[ \f\n\r\t\v\u2028\u2029]+/,eY=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];xr(e)||(n?i=e.toString().split(""):i=e.toString().split(JX));var a=i.map(l=>({word:l,width:i0(l,r).width})),s=n?0:i0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function fwe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var tY=(t,e,n,r)=>t.reduce((i,a)=>{var{word:s,width:l}=a,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(s),c.width+=l+n;else{var u={words:[s],width:l};i.push(u)}return i},[]),nY=t=>t.reduce((e,n)=>e.width>n.width?e:n),mwe="…",Y8=(t,e,n,r,i,a,s,l)=>{var c=t.slice(0,e),u=eY({breakAll:n,style:r,children:c+mwe});if(!u)return[!1,[]];var d=tY(u.wordsWithComputedWidth,a,s,l),f=d.length>i||nY(d).width>Number(a);return[f,d]},pwe=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:l,breakAll:c}=t,u=jt(a),d=String(s),f=tY(e,r,n,i);if(!u||i)return f;var g=f.length>a||nY(f).width>Number(r);if(!g)return f;for(var p=0,x=d.length-1,v=0,y;p<=x&&v<=d.length-1;){var b=Math.floor((p+x)/2),E=b-1,[w,T]=Y8(d,E,c,l,a,r,n,i),[A]=Y8(d,b,c,l,a,r,n,i);if(!w&&!A&&(p=b+1),w&&A&&(x=b-1),!w&&A){y=T;break}v++}return y||f},Z8=t=>{var e=xr(t)?[]:t.toString().split(JX);return[{words:e,width:void 0}]},gwe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!sg.isSsr){var l,c,u=eY({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return Z8(r);return pwe({breakAll:a,children:r,maxLines:s,style:i},l,c,e,!!n)}return Z8(r)},rY="#808080",xwe={angle:0,breakAll:!1,capHeight:"0.71em",fill:rY,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},zM=M.forwardRef((t,e)=>{var n=Rr(t,xwe),{x:r,y:i,lineHeight:a,capHeight:s,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=X8(n,uwe),g=M.useMemo(()=>gwe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:x,angle:v,className:y,breakAll:b}=f,E=X8(f,dwe);if(!po(r)||!po(i)||g.length===0)return null;var w=Number(r)+(jt(p)?p:0),T=Number(i)+(jt(x)?x:0);if(!qn(w)||!qn(T))return null;var A;switch(d){case"start":A=uN("calc(".concat(s,")"));break;case"middle":A=uN("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:A=uN("calc(".concat(g.length-1," * -").concat(a,")"));break}var C=[];if(c){var N=g[0].width,{width:F}=f;C.push("scale(".concat(jt(F)&&jt(N)?F/N:1,")"))}return v&&C.push("rotate(".concat(v,", ").concat(w,", ").concat(T,")")),C.length&&(E.transform=C.join(" ")),M.createElement("text",X3({},la(E),{ref:e,x:w,y:T,className:Cn("recharts-text",y),textAnchor:u,fill:l.includes("url")?rY:l}),g.map((k,R)=>{var I=k.words.join(b?"":" ");return M.createElement("tspan",{x:w,dy:R===0?A:a,key:"".concat(I,"-").concat(R)},I)}))});zM.displayName="Text";var bwe=["labelRef"];function ywe(t,e){if(t==null)return{};var n,r,i=vwe(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 vwe(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 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 Yr(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){_we(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 _we(t,e,n){return(e=wwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wwe(t){var e=Swe(t,"string");return typeof e=="symbol"?e:e+""}function Swe(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 yc(){return yc=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},yc.apply(null,arguments)}var iY=M.createContext(null),aY=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s,children:l}=t,c=M.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s}),[e,n,r,i,a,s]);return M.createElement(iY.Provider,{value:c},l)},sY=()=>{var t=M.useContext(iY),e=Ob();return t||Mq(e)},Mwe=M.createContext(null),Ewe=()=>{var t=M.useContext(Mwe),e=kt(XK);return t||e},Twe=t=>{var{value:e,formatter:n}=t,r=xr(t.children)?e:t.children;return typeof n=="function"?n(r):r},tO=t=>t!=null&&typeof t=="function",Awe=(t,e)=>{var n=Bi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},Nwe=(t,e,n,r,i)=>{var{offset:a,className:s}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:p}=i,x=(u+d)/2,v=Awe(f,g),y=v>=0?1:-1,b,E;switch(e){case"insideStart":b=f+y*a,E=p;break;case"insideEnd":b=g-y*a,E=!p;break;case"end":b=g+y*a,E=p;break;default:throw new Error("Unsupported position ".concat(e))}E=v<=0?E:!E;var w=ci(l,c,x,b),T=ci(l,c,x,b+(E?1:-1)*359),A="M".concat(w.x,",").concat(w.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
- `).concat(T.x,",").concat(T.y),C=xr(t.id)?D0("recharts-radial-line-"):t.id;return M.createElement("text",yc({},r,{dominantBaseline:"central",className:Cn("recharts-radial-bar-label",s)}),M.createElement("defs",null,M.createElement("path",{id:C,d:A})),M.createElement("textPath",{xlinkHref:"#".concat(C)},n))},Cwe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:s,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=ci(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:p,y:x}=ci(r,i,g,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},Y3=t=>"cx"in t&&jt(t.cx),kwe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!Y3(n)&&(a=n);var{x:s,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=s,g=s+(c-u)/2,p=(f+g)/2,x=(c+u)/2,v=f+c/2,y=d>=0?1:-1,b=y*r,E=y>0?"end":"start",w=y>0?"start":"end",T=c>=0?1:-1,A=T*r,C=T>0?"end":"start",N=T>0?"start":"end";if(i==="top"){var F={x:f+c/2,y:l-b,textAnchor:"middle",verticalAnchor:E};return Yr(Yr({},F),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var k={x:g+u/2,y:l+d+b,textAnchor:"middle",verticalAnchor:w};return Yr(Yr({},k),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var R={x:p-A,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return Yr(Yr({},R),a?{width:Math.max(R.x-a.x,0),height:d}:{})}if(i==="right"){var I={x:p+x+A,y:l+d/2,textAnchor:N,verticalAnchor:"middle"};return Yr(Yr({},I),a?{width:Math.max(a.x+a.width-I.x,0),height:d}:{})}var L=a?{width:x,height:d}:{};return i==="insideLeft"?Yr({x:p+A,y:l+d/2,textAnchor:N,verticalAnchor:"middle"},L):i==="insideRight"?Yr({x:p+x-A,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},L):i==="insideTop"?Yr({x:f+c/2,y:l+b,textAnchor:"middle",verticalAnchor:w},L):i==="insideBottom"?Yr({x:g+u/2,y:l+d-b,textAnchor:"middle",verticalAnchor:E},L):i==="insideTopLeft"?Yr({x:f+A,y:l+b,textAnchor:N,verticalAnchor:w},L):i==="insideTopRight"?Yr({x:f+c-A,y:l+b,textAnchor:C,verticalAnchor:w},L):i==="insideBottomLeft"?Yr({x:g+A,y:l+d-b,textAnchor:N,verticalAnchor:E},L):i==="insideBottomRight"?Yr({x:g+u-A,y:l+d-b,textAnchor:C,verticalAnchor:E},L):i&&typeof i=="object"&&(jt(i.x)||zc(i.x))&&(jt(i.y)||zc(i.y))?Yr({x:s+va(i.x,x),y:l+va(i.y,d),textAnchor:"end",verticalAnchor:"end"},L):Yr({x:v,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},L)},Pwe={angle:0,offset:5,zIndex:$r.label,position:"middle",textBreakAll:!1};function zu(t){var e=Rr(t,Pwe),{viewBox:n,position:r,value:i,children:a,content:s,className:l="",textBreakAll:c,labelRef:u}=e,d=Ewe(),f=sY(),g=r==="center"?f:d??f,p,x,v;if(n==null?p=g:Y3(n)?p=n:p=Mq(n),!p||xr(i)&&xr(a)&&!M.isValidElement(s)&&typeof s!="function")return null;var y=Yr(Yr({},e),{},{viewBox:p});if(M.isValidElement(s)){var{labelRef:b}=y,E=ywe(y,bwe);return M.cloneElement(s,E)}if(typeof s=="function"){if(x=M.createElement(s,y),M.isValidElement(x))return x}else x=Twe(e);var w=la(e);if(Y3(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return Nwe(e,r,x,w,p);v=Cwe(p,e.offset,e.position)}else v=kwe(e,p);return M.createElement(wa,{zIndex:e.zIndex},M.createElement(zM,yc({ref:u,className:Cn("recharts-label",l)},w,v,{textAnchor:fwe(w.textAnchor)?w.textAnchor:v.textAnchor,breakAll:c}),x))}zu.displayName="Label";var jwe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?M.createElement(zu,yc({key:"label-implicit"},r)):po(t)?M.createElement(zu,yc({key:"label-implicit",value:t},r)):M.isValidElement(t)?t.type===zu?M.cloneElement(t,Yr({key:"label-implicit"},r)):M.createElement(zu,yc({key:"label-implicit",content:t},r)):tO(t)?M.createElement(zu,yc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?M.createElement(zu,yc({},t,{key:"label-implicit"},r)):null};function oY(t){var{label:e,labelRef:n}=t,r=sY();return jwe(e,r,n)||null}var dN={},hN={},J8;function Rwe(){return J8||(J8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(hN)),hN}var fN={},e6;function Dwe(){return e6||(e6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(fN)),fN}var t6;function Owe(){return t6||(t6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rwe(),n=Dwe(),r=CR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(dN)),dN}var mN,n6;function Lwe(){return n6||(n6=1,mN=Owe().last),mN}var Iwe=Lwe();const Fwe=bo(Iwe);var Uwe=["valueAccessor"],zwe=["dataKey","clockWise","id","textBreakAll","zIndex"];function Ew(){return Ew=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},Ew.apply(null,arguments)}function r6(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}var Hwe=t=>Array.isArray(t.value)?Fwe(t.value):t.value,lY=M.createContext(void 0),nO=lY.Provider,cY=M.createContext(void 0),$we=cY.Provider;function Vwe(){return M.useContext(lY)}function Gwe(){return M.useContext(cY)}function g1(t){var{valueAccessor:e=Hwe}=t,n=r6(t,Uwe),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:l}=n,c=r6(n,zwe),u=Vwe(),d=Gwe(),f=u||d;return!f||!f.length?null:M.createElement(wa,{zIndex:l??$r.label},M.createElement(jr,{className:"recharts-label-list"},f.map((g,p)=>{var x,v=xr(r)?e(g,p):Wn(g&&g.payload,r),y=xr(a)?{}:{id:"".concat(a,"-").concat(p)};return M.createElement(zu,Ew({key:"label-".concat(p)},la(g),c,y,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:v,textBreakAll:s,viewBox:g.viewBox,index:p,zIndex:0}))})))}g1.displayName="LabelList";function BM(t){var{label:e}=t;return e?e===!0?M.createElement(g1,{key:"labelList-implicit"}):M.isValidElement(e)||tO(e)?M.createElement(g1,{key:"labelList-implicit",content:e}):typeof e=="object"?M.createElement(g1,Ew({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function Z3(){return Z3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Z3.apply(null,arguments)}var uY=t=>{var{cx:e,cy:n,r,className:i}=t,a=Cn("recharts-dot",i);return jt(e)&&jt(n)&&jt(r)?M.createElement("circle",Z3({},Oa(t),NR(t),{className:a,cx:e,cy:n,r})):null},dY=t=>t.graphicalItems.polarItems,Wwe=Ze([Mr,$b],ED),HM=Ze([dY,Dr,Wwe],TD),qwe=Ze([HM],AD),$M=Ze([qwe,pD],ND),Kwe=Ze([$M,Dr,HM],kD);Ze([$M,Dr,HM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Wn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Wn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var i6=()=>{},Xwe=Ze([$M,Dr,HM,LM,Mr],DD),Ywe=Ze([Dr,jD,RD,i6,Xwe,i6,vn,Mr],OD),hY=Ze([Dr,vn,$M,Kwe,Hb,Mr,Ywe],LD),Zwe=Ze([hY,Dr,mg],UD);Ze([Dr,hY,Zwe,Mr],BD);var Qwe={radiusAxis:{},angleAxis:{}},fY=ss({name:"polarAxis",initialState:Qwe,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:IWe,removeRadiusAxis:FWe,addAngleAxis:UWe,removeAngleAxis:zWe}=fY.actions,Jwe=fY.reducer;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 s6(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){eSe(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 eSe(t,e,n){return(e=tSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tSe(t){var e=nSe(t,"string");return typeof e=="symbol"?e:e+""}function nSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var rSe=(t,e)=>e,rO=Ze([dY,rSe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),iSe=[],iO=(t,e,n)=>n?.length===0?iSe:n,mY=Ze([pD,rO,iO],(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=>s6(s6({},e.presentationProps),a.props))),i!=null)return i}}),aSe=Ze([mY,rO,iO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Wn(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Cd(s,e.dataKey),color:l,payload:r,type:e.legendType}})}),sSe=Ze([mY,rO,iO,Mi],(t,e,n,r)=>{if(!(e==null||t==null))return oMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),pN={exports:{}},Zn={};var o6;function oSe(){if(o6)return Zn;o6=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"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(v){if(typeof v=="object"&&v!==null){var y=v.$$typeof;switch(y){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case g:return v;default:switch(v=v&&v.$$typeof,v){case s:case l:case f:case d:return v;case a:return v;default:return y}}case e:return y}}}return Zn.ContextConsumer=a,Zn.ContextProvider=s,Zn.Element=t,Zn.ForwardRef=l,Zn.Fragment=n,Zn.Lazy=f,Zn.Memo=d,Zn.Portal=e,Zn.Profiler=i,Zn.StrictMode=r,Zn.Suspense=c,Zn.SuspenseList=u,Zn.isContextConsumer=function(v){return x(v)===a},Zn.isContextProvider=function(v){return x(v)===s},Zn.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},Zn.isForwardRef=function(v){return x(v)===l},Zn.isFragment=function(v){return x(v)===n},Zn.isLazy=function(v){return x(v)===f},Zn.isMemo=function(v){return x(v)===d},Zn.isPortal=function(v){return x(v)===e},Zn.isProfiler=function(v){return x(v)===i},Zn.isStrictMode=function(v){return x(v)===r},Zn.isSuspense=function(v){return x(v)===c},Zn.isSuspenseList=function(v){return x(v)===u},Zn.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===d||v.$$typeof===s||v.$$typeof===a||v.$$typeof===l||v.$$typeof===p||v.getModuleId!==void 0)},Zn.typeOf=x,Zn}var l6;function lSe(){return l6||(l6=1,pN.exports=oSe()),pN.exports}var cSe=lSe(),c6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",u6=null,gN=null,pY=t=>{if(t===u6&&Array.isArray(gN))return gN;var e=[];return M.Children.forEach(t,n=>{xr(n)||(cSe.isFragment(n)?e=e.concat(pY(n.props.children)):e.push(n))}),gN=e,u6=t,e};function aO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>c6(i)):r=[c6(e)],pY(t).forEach(i=>{var a=nf(i,"type.displayName")||nf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var sO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,xN={},d6;function uSe(){return d6||(d6=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})(xN)),xN}var bN,h6;function dSe(){return h6||(h6=1,bN=uSe().isPlainObject),bN}var hSe=dSe();const fSe=bo(hSe);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 m6(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){mSe(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 mSe(t,e,n){return(e=pSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pSe(t){var e=gSe(t,"string");return typeof e=="symbol"?e:e+""}function gSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Tw(){return Tw=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},Tw.apply(null,arguments)}var p6=(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},xSe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},bSe=t=>{var e=Rr(t,xSe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:s,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=M.useRef(null),[p,x]=M.useState(-1),v=M.useRef(i),y=M.useRef(a),b=M.useRef(s),E=M.useRef(n),w=M.useRef(r),T=lg(t,"trapezoid-");if(M.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var j=g.current.getTotalLength();j&&x(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var A=Cn("recharts-trapezoid",l);if(!f)return M.createElement("g",null,M.createElement("path",Tw({},la(e),{className:A,d:p6(n,r,i,a,s)})));var C=v.current,N=y.current,F=b.current,k=E.current,R=w.current,I="0px ".concat(p===-1?1:p,"px"),L="".concat(p,"px 0px"),q=Iq(["strokeDasharray"],u,c);return M.createElement(og,{animationId:T,key:T,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},j=>{var V=Un(C,i,j),K=Un(N,a,j),W=Un(F,s,j),J=Un(k,n,j),ee=Un(R,r,j);g.current&&(v.current=V,y.current=K,b.current=W,E.current=J,w.current=ee);var Z=j>0?{transition:q,strokeDasharray:L}:{strokeDasharray:I};return M.createElement("path",Tw({},la(e),{className:A,d:p6(J,ee,V,K,W),ref:g,style:m6(m6({},Z),e.style)}))})},ySe=["option","shapeType","propTransformer","activeClassName"];function vSe(t,e){if(t==null)return{};var n,r,i=_Se(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 _Se(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 Aw(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){wSe(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 wSe(t,e,n){return(e=SSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SSe(t){var e=MSe(t,"string");return typeof e=="symbol"?e:e+""}function MSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ESe(t,e){return Aw(Aw({},e),t)}function TSe(t,e){return t==="symbols"}function x6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return M.createElement(Bq,n);case"trapezoid":return M.createElement(bSe,n);case"sector":return M.createElement(Gq,n);case"symbols":if(TSe(e))return M.createElement(AR,n);break;case"curve":return M.createElement(cp,n);default:return null}}function ASe(t){return M.isValidElement(t)?t.props:t}function oO(t){var{option:e,shapeType:n,propTransformer:r=ESe,activeClassName:i="recharts-active-shape"}=t,a=vSe(t,ySe),s;if(M.isValidElement(e))s=M.cloneElement(e,Aw(Aw({},a),ASe(e)));else if(typeof e=="function")s=e(a,a.index);else if(fSe(e)&&typeof e!="boolean"){var l=r(e,a);s=M.createElement(x6,{shapeType:n,elementProps:l})}else{var c=a;s=M.createElement(x6,{shapeType:n,elementProps:c})}return a.isActive?M.createElement(jr,{className:i},s):s}var lO=(t,e,n)=>{var r=cr();return(i,a)=>s=>{t?.(i,a,s),r(TX({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},cO=t=>{var e=cr();return(n,r)=>i=>{t?.(n,r,i),e(Hve())}},uO=(t,e,n)=>{var r=cr();return(i,a)=>s=>{t?.(i,a,s),r($ve({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function VM(t){var{tooltipEntrySettings:e}=t,n=cr(),r=Ei(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(Fve(e)):i.current!==e&&n(Uve({prev:i.current,next:e})),i.current=e)},[e,n,r]),M.useLayoutEffect(()=>()=>{i.current&&(n(zve(i.current)),i.current=null)},[n]),null}function dO(t){var{legendPayload:e}=t,n=cr(),r=Ei(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(Rq(e)):i.current!==e&&n(Dq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(Oq(i.current)),i.current=null)},[n]),null}function NSe(t){var{legendPayload:e}=t,n=cr(),r=kt(vn),i=M.useRef(null);return M.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(Rq(e)):i.current!==e&&n(Dq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(Oq(i.current)),i.current=null)},[n]),null}var yN,CSe=()=>{var[t]=M.useState(()=>D0("uid-"));return t},kSe=(yN=tie.useId)!==null&&yN!==void 0?yN:CSe;function gY(t,e){var n=kSe();return e||(t?"".concat(t,"-").concat(n):n)}var PSe=M.createContext(void 0),GM=t=>{var{id:e,type:n,children:r}=t,i=gY("recharts-".concat(n),e);return M.createElement(PSe.Provider,{value:i},r(i))},jSe={cartesianItems:[],polarItems:[]},xY=ss({name:"graphicalItems",initialState:jSe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:vr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=zo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:vr()},removeCartesianGraphicalItem:{reducer(t,e){var n=zo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:vr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:vr()},removePolarGraphicalItem:{reducer(t,e){var n=zo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:vr()}}}),{addCartesianGraphicalItem:RSe,replaceCartesianGraphicalItem:DSe,removeCartesianGraphicalItem:OSe,addPolarGraphicalItem:LSe,removePolarGraphicalItem:ISe}=xY.actions,FSe=xY.reducer,USe=t=>{var e=cr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(RSe(t)):n.current!==t&&e(DSe({prev:n.current,next:t})),n.current=t},[e,t]),M.useLayoutEffect(()=>()=>{n.current&&(e(OSe(n.current)),n.current=null)},[e]),null},hO=M.memo(USe);function zSe(t){var e=cr();return M.useLayoutEffect(()=>(e(LSe(t)),()=>{e(ISe(t))}),[e,t]),null}var BSe=["key"],HSe=["onMouseEnter","onClick","onMouseLeave"],$Se=["id"],VSe=["id"];function b6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Br(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b6(Object(n),!0).forEach(function(r){GSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GSe(t,e,n){return(e=WSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WSe(t){var e=qSe(t,"string");return typeof e=="symbol"?e:e+""}function qSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function _d(){return _d=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_d.apply(null,arguments)}function WM(t,e){if(t==null)return{};var n,r,i=KSe(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 KSe(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 XSe(t){var e=M.useMemo(()=>aO(t.children,Jb),[t.children]),n=kt(r=>aSe(r,t.id,e));return n==null?null:M.createElement(NSe,{legendPayload:n})}var YSe=M.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:s,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:Cd(l,e),hide:c,type:u,color:s,unit:""}};return M.createElement(VM,{tooltipEntrySettings:d})}),ZSe=(t,e)=>t>e?"start":t<e?"end":"middle",QSe=(t,e,n)=>va(typeof e=="function"?e(t):e,n,n*.8),JSe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,l=Hq(a,s),c=i+va(t.cx,a,a/2),u=r+va(t.cy,s,s/2),d=va(t.innerRadius,l,0),f=QSe(n,t.outerRadius,l),g=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},eMe=(t,e)=>{var n=Bi(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function tMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var nMe=(t,e)=>{if(M.isValidElement(t))return M.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Cn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=WM(e,BSe);return M.createElement(cp,_d({},i,{type:"linear",className:n}))},rMe=(t,e,n)=>{if(M.isValidElement(t))return M.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),M.isValidElement(r)))return r;var i=Cn("recharts-pie-label-text",tMe(t));return M.createElement(zM,_d({},e,{alignmentBaseline:"middle",className:i}),r)};function iMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var l=Oa(n),c=tf(i),u=tf(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,p)=>{var x=(g.startAngle+g.endAngle)/2,v=ci(g.cx,g.cy,g.outerRadius+d,x),y=Br(Br(Br(Br({},l),g),{},{stroke:"none"},c),{},{index:p,textAnchor:ZSe(v.x,g.cx)},v),b=Br(Br(Br(Br({},l),g),{},{fill:"none",stroke:g.fill},u),{},{index:p,points:[ci(g.cx,g.cy,g.outerRadius,x),v],key:"line"});return M.createElement(wa,{zIndex:$r.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(p)},M.createElement(jr,null,a&&nMe(a,b),rMe(i,y,Wn(g,s))))});return M.createElement(jr,{className:"recharts-pie-labels"},f)}function aMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?M.createElement(BM,{label:i}):M.createElement(iMe,{sectors:e,props:n,showLabels:r})}function sMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,l=kt(vd),c=kt(YD),u=kt(N_e),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,p=WM(i,HSe),x=lO(d,i.dataKey,s),v=cO(g),y=uO(f,i.dataKey,s);return e==null||e.length===0?null:M.createElement(M.Fragment,null,e.map((b,E)=>{if(b?.startAngle===0&&b?.endAngle===0&&e.length!==1)return null;var w=u==null||u===s,T=String(E)===l&&(c==null||i.dataKey===c)&&w,A=l?r:null,C=n&&T?n:A,N=Br(Br({},b),{},{stroke:b.stroke,tabIndex:-1,[yq]:E,[vq]:i.dataKey});return M.createElement(jr,_d({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},kb(p,b,E),{onMouseEnter:x(b,E),onMouseLeave:v(b,E),onClick:y(b,E)}),M.createElement(oO,_d({option:a??C,index:E,shapeType:"sector",isActive:T},N)))}))}function oMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:s,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),p=eMe(l,c),x=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,y=r.filter(C=>Wn(C,u,0)!==0).length,b=(x>=360?y:y-1)*v,E=x-y*g-b,w=r.reduce((C,N)=>{var F=Wn(N,u,0);return C+(jt(F)?F:0)},0),T;if(w>0){var A;T=r.map((C,N)=>{var F=Wn(C,u,0),k=Wn(C,d,N),R=JSe(n,a,C),I=(jt(F)?F:0)/w,L,q=Br(Br({},C),i&&i[N]&&i[N].props);N?L=A.endAngle+Bi(p)*v*(F!==0?1:0):L=l;var j=L+Bi(p)*((F!==0?g:0)+I*E),V=(L+j)/2,K=(R.innerRadius+R.outerRadius)/2,W=[{name:k,value:F,payload:q,dataKey:u,type:f}],J=ci(R.cx,R.cy,K,V);return A=Br(Br(Br(Br({},n.presentationProps),{},{percent:I,cornerRadius:typeof s=="string"?parseFloat(s):s,name:k,tooltipPayload:W,midAngle:V,middleRadius:K,tooltipPosition:J},q),R),{},{value:F,dataKey:u,startAngle:L,endAngle:j,payload:q,paddingAngle:Bi(p)*v}),A})}return T}function lMe(t){var{showLabels:e,sectors:n,children:r}=t,i=M.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 M.createElement($we,{value:e?i:void 0},r)}function cMe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:s,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,p=lg(e,"recharts-pie-"),x=n.current,[v,y]=M.useState(!1),b=M.useCallback(()=>{typeof g=="function"&&g(),y(!1)},[g]),E=M.useCallback(()=>{typeof f=="function"&&f(),y(!0)},[f]);return M.createElement(lMe,{showLabels:!v,sectors:i},M.createElement(og,{animationId:p,begin:s,duration:l,isActive:a,easing:c,onAnimationStart:E,onAnimationEnd:b,key:p},w=>{var T=[],A=i&&i[0],C=A?.startAngle;return i?.forEach((N,F)=>{var k=x&&x[F],R=F>0?nf(N,"paddingAngle",0):0;if(k){var I=Un(k.endAngle-k.startAngle,N.endAngle-N.startAngle,w),L=Br(Br({},N),{},{startAngle:C+R,endAngle:C+I+R});T.push(L),C=L.endAngle}else{var{endAngle:q,startAngle:j}=N,V=Un(0,q-j,w),K=Br(Br({},N),{},{startAngle:C+R,endAngle:C+V+R});T.push(K),C=K.endAngle}}),n.current=T,M.createElement(jr,null,M.createElement(sMe,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),M.createElement(aMe,{showLabels:!v,sectors:i,props:e}),e.children)}var uMe={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:$r.area};function dMe(t){var{id:e}=t,n=WM(t,$Se),{hide:r,className:i,rootTabIndex:a}=t,s=M.useMemo(()=>aO(t.children,Jb),[t.children]),l=kt(d=>sSe(d,e,s)),c=M.useRef(null),u=Cn("recharts-pie",i);return r||l==null?(c.current=null,M.createElement(jr,{tabIndex:a,className:u})):M.createElement(wa,{zIndex:t.zIndex},M.createElement(YSe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:l,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),M.createElement(jr,{tabIndex:a,className:u},M.createElement(cMe,{props:Br(Br({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function bY(t){var e=Rr(t,uMe),{id:n}=e,r=WM(e,VSe),i=Oa(r);return M.createElement(GM,{id:n,type:"pie"},a=>M.createElement(M.Fragment,null,M.createElement(zSe,{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}),M.createElement(XSe,_d({},r,{id:a})),M.createElement(dMe,_d({},r,{id:a}))))}bY.displayName="Pie";var hMe=["points"];function y6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y6(Object(n),!0).forEach(function(r){fMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fMe(t,e,n){return(e=mMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mMe(t){var e=pMe(t,"string");return typeof e=="symbol"?e:e+""}function pMe(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 Nw(){return Nw=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},Nw.apply(null,arguments)}function gMe(t,e){if(t==null)return{};var n,r,i=xMe(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 xMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function bMe(t){var{option:e,dotProps:n,className:r}=t;if(M.isValidElement(e))return M.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Cn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,l=gMe(a,hMe);return M.createElement(uY,Nw({},l,{className:i}))}function yMe(t,e){return t==null?!1:e?!0:t.length===1}function yY(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:l,clipPathId:c,zIndex:u=$r.scatter}=t;if(!yMe(e,n))return null;var d=sO(n),f=Yde(n),g=e.map((x,v)=>{var y,b,E=vN(vN(vN({r:3},s),f),{},{index:v,cx:(y=x.x)!==null&&y!==void 0?y:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return M.createElement(bMe,{key:"dot-".concat(v),option:n,dotProps:E,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),M.createElement(wa,{zIndex:u},M.createElement(jr,Nw({className:r},p),g))}function v6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v6(Object(n),!0).forEach(function(r){vMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vMe(t,e,n){return(e=_Me(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Me(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)}var SMe={xAxis:{},yAxis:{},zAxis:{}},vY=ss({name:"cartesianAxis",initialState:SMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:vr()},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:vr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:vr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:vr()},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:vr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:vr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:vr()},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:vr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:vr()},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]=_6(_6({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:MMe,replaceXAxis:EMe,removeXAxis:TMe,addYAxis:AMe,replaceYAxis:NMe,removeYAxis:CMe,addZAxis:BWe,replaceZAxis:HWe,removeZAxis:$We,updateYAxisWidth:kMe}=vY.actions,PMe=vY.reducer,jMe=Ze([Mi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),RMe=Ze([jMe,Yc,Zc],(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)}}),qM=()=>kt(RMe),DMe=()=>kt(R_e);function w6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _N(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w6(Object(n),!0).forEach(function(r){OMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OMe(t,e,n){return(e=LMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LMe(t){var e=IMe(t,"string");return typeof e=="symbol"?e:e+""}function IMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var FMe=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 l={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=_N(_N(_N({},l),tf(i)),NR(i)),u;return M.isValidElement(i)?u=M.cloneElement(i,c):typeof i=="function"?u=i(c):u=M.createElement(uY,c),M.createElement(jr,{className:"recharts-active-dot",clipPath:s},u)};function Q3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=$r.activeDot}=t,l=kt(vd),c=DMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return xr(u)?null:M.createElement(wa,{zIndex:s},M.createElement(FMe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var UMe="Invariant failed";function zMe(t,e){throw new Error(UMe)}var BMe=["x","y"];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 S6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ex(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S6(Object(n),!0).forEach(function(r){HMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function HMe(t,e,n){return(e=$Me(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Me(t){var e=VMe(t,"string");return typeof e=="symbol"?e:e+""}function VMe(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 GMe(t,e){if(t==null)return{};var n,r,i=WMe(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 WMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function qMe(t,e){var{x:n,y:r}=t,i=GMe(t,BMe),a="".concat(n),s=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return Ex(Ex(Ex(Ex(Ex({},e),i),s?{x:s}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function Cw(t){return M.createElement(oO,J3({shapeType:"rectangle",propTransformer:qMe,activeClassName:"recharts-active-bar"},t))}var KMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(jt(e))return e;var a=jt(r)||xr(r);return a?e(r,i):(a||zMe(),n)}},XMe={},_Y=ss({name:"errorBars",initialState:XMe,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:VWe,replaceErrorBar:GWe,removeErrorBar:WWe}=_Y.actions,YMe=_Y.reducer,ZMe=["children"];function QMe(t,e){if(t==null)return{};var n,r,i=JMe(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 JMe(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 eEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},tEe=M.createContext(eEe);function wY(t){var{children:e}=t,n=QMe(t,ZMe);return M.createElement(tEe.Provider,{value:n},e)}function KM(t,e){var n,r,i=kt(u=>jl(u,t)),a=kt(u=>Rl(u,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Oi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Li.allowDataOverflow,c=s||l;return{needClip:c,needClipX:s,needClipY:l}}function fO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=qM(),{needClipX:a,needClipY:s,needClip:l}=KM(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return M.createElement("clipPath",{id:"clipPath-".concat(r)},M.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 nEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&qn(t.zIndex)?t.zIndex:e}var wN={exports:{}},SN={};var M6;function rEe(){if(M6)return SN;M6=1;var t=Jp();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,l=t.useDebugValue;return SN.useSyncExternalStoreWithSelector=function(c,u,d,f,g){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=s(function(){function y(A){if(!b){if(b=!0,E=A,A=f(A),g!==void 0&&x.hasValue){var C=x.value;if(g(C,A))return w=C}return w=A}if(C=w,n(E,A))return C;var N=f(A);return g!==void 0&&g(C,N)?(E=A,C):(E=A,w=N)}var b=!1,E,w,T=d===void 0?null:d;return[function(){return y(u())},T===null?void 0:function(){return y(T())}]},[u,d,f,g]);var v=r(c,p[0],p[1]);return a(function(){x.hasValue=!0,x.value=v},[v]),l(v),v},SN}var E6;function iEe(){return E6||(E6=1,wN.exports=rEe()),wN.exports}iEe();function aEe(t){t()}function sEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){aEe(()=>{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 T6={notify(){},get:()=>[]};function oEe(t,e){let n,r=T6,i=0,a=!1;function s(v){d();const y=r.subscribe(v);let b=!1;return()=>{b||(b=!0,y(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=sEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=T6)}function g(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const x={addNestedSub:s,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:p,getListeners:()=>r};return x}var lEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",cEe=lEe(),uEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",dEe=uEe(),hEe=()=>cEe||dEe?M.useLayoutEffect:M.useEffect,fEe=hEe();function A6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function mEe(t,e){if(A6(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])||!A6(t[n[i]],e[n[i]]))return!1;return!0}var pEe=Symbol.for("react-redux-context"),gEe=typeof globalThis<"u"?globalThis:{};function xEe(){if(!M.createContext)return{};const t=gEe[pEe]??=new Map;let e=t.get(M.createContext);return e||(e=M.createContext(null),t.set(M.createContext,e)),e}var bEe=xEe();function yEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=M.useMemo(()=>{const c=oEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),s=M.useMemo(()=>i.getState(),[i]);fEe(()=>{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 l=n||bEe;return M.createElement(l.Provider,{value:a},e)}var vEe=yEe,_Ee=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function wEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function ey(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(_Ee.has(r)){if(t[r]==null&&e[r]==null)continue;if(!mEe(t[r],e[r]))return!1}else if(!wEe(t[r],e[r]))return!1;return!0}var SEe=["onMouseEnter","onMouseLeave","onClick"],MEe=["value","background","tooltipPosition"],EEe=["id"],TEe=["onMouseEnter","onClick","onMouseLeave"];function Wc(){return Wc=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},Wc.apply(null,arguments)}function N6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ka(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N6(Object(n),!0).forEach(function(r){AEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function AEe(t,e,n){return(e=NEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NEe(t){var e=CEe(t,"string");return typeof e=="symbol"?e:e+""}function CEe(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 kw(t,e){if(t==null)return{};var n,r,i=kEe(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 kEe(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 PEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Cd(n,e),payload:t}]},jEe=M.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Cd(a,e),hide:s,type:c,color:i,unit:l}};return M.createElement(VM,{tooltipEntrySettings:u})});function REe(t){var e=kt(vd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:l,onClick:c}=a,u=kw(a,SEe),d=lO(s,r),f=cO(l),g=uO(c,r);if(!i||n==null)return null;var p=tf(i);return M.createElement(wa,{zIndex:nEe(i,$r.barBackground)},n.map((x,v)=>{var{value:y,background:b,tooltipPosition:E}=x,w=kw(x,MEe);if(!b)return null;var T=d(x,v),A=f(x,v),C=g(x,v),N=ka(ka(ka(ka(ka({option:i,isActive:String(v)===e},w),{},{fill:"#eee"},b),p),kb(u,x,v)),{},{onMouseEnter:T,onMouseLeave:A,onClick:C,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return M.createElement(Cw,Wc({key:"background-bar-".concat(v)},N))}))}function DEe(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 ka(ka({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return M.createElement(nO,{value:e?i:void 0},n)}function OEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,l=kt(vd),c=kt(YD),u=n&&String(a)===l&&(c==null||s===c),d=u?n:e;return u?M.createElement(wa,{zIndex:$r.activeBar},M.createElement(Cw,Wc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))):M.createElement(Cw,Wc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))}function LEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return M.createElement(Cw,Wc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function IEe(t){var e,{data:n,props:r}=t,i=(e=Oa(r))!==null&&e!==void 0?e:{},{id:a}=i,s=kw(i,EEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,p=kw(r,TEe),x=lO(d,c),v=cO(g),y=uO(f,c);return n?M.createElement(M.Fragment,null,n.map((b,E)=>M.createElement(jr,Wc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(E),className:"recharts-bar-rectangle"},kb(p,b,E),{onMouseEnter:x(b,E),onMouseLeave:v(b,E),onClick:y(b,E)}),u?M.createElement(OEe,{shape:l,activeBar:u,baseProps:s,entry:b,index:E,dataKey:c}):M.createElement(LEe,{shape:l,baseProps:s,entry:b,index:E,dataKey:c})))):null}function FEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:s,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=lg(e,"recharts-bar-"),[p,x]=M.useState(!1),v=!p,y=M.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),b=M.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return M.createElement(DEe,{showLabels:v,rects:r},M.createElement(og,{animationId:g,begin:s,duration:l,isActive:a,easing:c,onAnimationEnd:y,onAnimationStart:b,key:g},E=>{var w=E===1?r:r?.map((T,A)=>{var C=f&&f[A];if(C)return ka(ka({},T),{},{x:Un(C.x,T.x,E),y:Un(C.y,T.y,E),width:Un(C.width,T.width,E),height:Un(C.height,T.height,E)});if(i==="horizontal"){var N=Un(0,T.height,E),F=Un(T.stackedBarStart,T.y,E);return ka(ka({},T),{},{y:F,height:N})}var k=Un(0,T.width,E),R=Un(T.stackedBarStart,T.x,E);return ka(ka({},T),{},{width:k,x:R})});return E>0&&(n.current=w??null),w==null?null:M.createElement(jr,null,M.createElement(IEe,{props:e,data:w}))}),M.createElement(BM,{label:e.label}),e.children)}function UEe(t){var e=M.useRef(null);return M.createElement(FEe,{previousRectanglesRef:e,props:t})}var SY=0,zEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Wn(t,e)}};class BEe extends M.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:s,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=Cn("recharts-bar",i),f=u;return M.createElement(jr,{className:d,id:u},l&&M.createElement("defs",null,M.createElement(fO,{clipPathId:f,xAxisId:a,yAxisId:s})),M.createElement(jr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},M.createElement(REe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),M.createElement(UEe,this.props)))}}var HEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:SY,xAxisId:0,yAxisId:0,zIndex:$r.bar};function $Ee(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=KM(e,n),g=vf(),p=Ei(),x=aO(t.children,Jb),v=kt(E=>x2e(E,e,n,p,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var y,b=v?.[0];return b==null||b.height==null||b.width==null?y=0:y=g==="vertical"?b.height/2:b.width/2,M.createElement(wY,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:zEe,errorBarOffset:y},M.createElement(BEe,Wc({},t,{layout:g,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function VEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:s,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:p,parentViewBox:x,dataStartIndex:v}=t,y=e==="horizontal"?l:s,b=d?y.scale.domain():null,E=fpe({numericAxis:y}),w=y.scale(E);return f.map((T,A)=>{var C,N,F,k,R,I;d?C=lpe(d[A+v],b):(C=Wn(T,n),Array.isArray(C)||(C=[E,C]));var L=KMe(r,SY)(C[1],A);if(e==="horizontal"){var q,[j,V]=[l.scale(C[0]),l.scale(C[1])];N=Gz({axis:s,ticks:c,bandSize:a,offset:i.offset,entry:T,index:A}),F=(q=V??j)!==null&&q!==void 0?q:void 0,k=i.size;var K=j-V;if(R=as(K)?0:K,I={x:N,y:g.top,width:k,height:g.height},Math.abs(L)>0&&Math.abs(R)<Math.abs(L)){var W=Bi(R||L)*(Math.abs(L)-Math.abs(R));F-=W,R+=W}}else{var[J,ee]=[s.scale(C[0]),s.scale(C[1])];if(N=J,F=Gz({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:T,index:A}),k=ee-J,R=i.size,I={x:g.left,y:F,width:g.width,height:R},Math.abs(L)>0&&Math.abs(k)<Math.abs(L)){var Z=Bi(k||L)*(Math.abs(L)-Math.abs(k));k+=Z}}if(N==null||F==null||k==null||R==null)return null;var B=ka(ka({},T),{},{stackedBarStart:w,x:N,y:F,width:k,height:R,value:d?C:C[1],payload:T,background:I,tooltipPosition:{x:N+k/2,y:F+R/2},parentViewBox:x},p&&p[A]&&p[A].props);return B}).filter(Boolean)}function GEe(t){var e=Rr(t,HEe),n=Ei();return M.createElement(GM,{id:e.id,type:"bar"},r=>M.createElement(M.Fragment,null,M.createElement(dO,{legendPayload:PEe(e)}),M.createElement(jEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),M.createElement(hO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:xq(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),M.createElement(wa,{zIndex:e.zIndex},M.createElement($Ee,Wc({},e,{id:r})))))}var MY=M.memo(GEe,ey);MY.displayName="Bar";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 Hv(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){WEe(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 WEe(t,e,n){return(e=qEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qEe(t){var e=KEe(t,"string");return typeof e=="symbol"?e:e+""}function KEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var XEe=(t,e)=>e,YEe=(t,e,n)=>n,ZEe=(t,e,n,r)=>r,QEe=(t,e,n,r,i)=>i,ty=Ze([Gb,QEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),JEe=Ze([ty],t=>t?.maxBarSize),e2e=(t,e,n,r,i,a)=>a,k6=(t,e,n)=>{var r=n??t;if(!xr(r))return va(r,e,0)},t2e=Ze([vn,Gb,XEe,YEe,ZEe],(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")),n2e=(t,e,n,r)=>{var i=vn(t);return i==="horizontal"?q0(t,"yAxis",n,r):q0(t,"xAxis",e,r)},r2e=(t,e,n)=>{var r=vn(t);return r==="horizontal"?M8(t,"xAxis",e):M8(t,"yAxis",n)},i2e=(t,e,n)=>{var r={},i=t.filter(jM),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),l=Object.entries(s).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),p=k6(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:p}}),c=a.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=k6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},a2e=Ze([t2e,kye,r2e],i2e),s2e=(t,e,n,r,i)=>{var a,s,l=ty(t,e,n,r,i);if(l!=null){var c=vn(t),u=BK(t),{maxBarSize:d}=l,f=xr(d)?u:d,g,p;return c==="horizontal"?(g=wl(t,"xAxis",e,r),p=_l(t,"xAxis",e,r)):(g=wl(t,"yAxis",n,r),p=_l(t,"yAxis",n,r)),(a=(s=xd(g,p,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},EY=(t,e,n,r)=>{var i=vn(t),a,s;return i==="horizontal"?(a=wl(t,"xAxis",e,r),s=_l(t,"xAxis",e,r)):(a=wl(t,"yAxis",n,r),s=_l(t,"yAxis",n,r)),xd(a,s)};function o2e(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=va(t,n,0,!0),l,c=[];if(qn(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((b,E)=>b+(E.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,p={offset:g-s,size:0};l=r.reduce((b,E)=>{var w,T={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:p.offset+p.size+s,size:u?d:(w=E.barSize)!==null&&w!==void 0?w:0}},A=[...b,T];return p=A[A.length-1].position,A},c)}else{var x=va(e,n,0,!0);n-2*x-(a-1)*s<=0&&(s=0);var v=(n-2*x-(a-1)*s)/a;v>1&&(v>>=0);var y=qn(i)?Math.min(v,i):v;l=r.reduce((b,E,w)=>[...b,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(v+s)*w+(v-y)/2,size:y}}],c)}return l}}var l2e=(t,e,n,r,i,a,s)=>{var l=xr(s)?e:s,c=o2e(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>Hv(Hv({},u),{},{position:Hv(Hv({},u.position),{},{offset:u.position.offset-i/2})}))),c},c2e=Ze([a2e,BK,Cye,HK,s2e,EY,JEe],l2e),u2e=(t,e,n,r)=>wl(t,"xAxis",e,r),d2e=(t,e,n,r)=>wl(t,"yAxis",n,r),h2e=(t,e,n,r)=>_l(t,"xAxis",e,r),f2e=(t,e,n,r)=>_l(t,"yAxis",n,r),m2e=Ze([c2e,ty],(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}}),p2e=(t,e)=>{var n=PM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(s=>s.key===n)}}}},g2e=Ze([n2e,ty],p2e),x2e=Ze([Mi,UR,u2e,d2e,h2e,f2e,m2e,vn,Bb,EY,g2e,ty,e2e],(t,e,n,r,i,a,s,l,c,u,d,f,g)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:v}=c;if(!(f==null||s==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:y}=f,b;if(y!=null&&y.length>0?b=y:b=p?.slice(x,v+1),b!=null)return VEe({layout:l,barSettings:f,pos:s,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:b,offset:t,cells:g,dataStartIndex:x})}}),TY=t=>{var{chartData:e}=t,n=cr(),r=Ei();return M.useEffect(()=>r?()=>{}:(n(I8(e)),()=>{n(I8(void 0))}),[e,n,r]),null},P6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},AY=ss({name:"brush",initialState:P6,reducers:{setBrushSettings(t,e){return e.payload==null?P6:e.payload}}}),{setBrushSettings:qWe}=AY.actions,b2e=AY.reducer;function j6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $v(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j6(Object(n),!0).forEach(function(r){NY(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NY(t,e,n){return(e=y2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function y2e(t){var e=v2e(t,"string");return typeof e=="symbol"?e:e+""}function v2e(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 _2e=(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)}},w2e=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return _2e({x:e,y:n},{x:r,y:i})};class XM{static create(e){return new XM(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}}NY(XM,"EPS",1e-4);var S2e=t=>{var e=Object.keys(t).reduce((n,r)=>$v($v({},n),{},{[r]:XM.create(t[r])}),{});return $v($v({},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,l]=a;return[s,e[s].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function M2e(t){return(t%180+180)%180}var E2e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=M2e(i),s=a*Math.PI/180,l=Math.atan(r/n),c=s>l&&s<Math.PI-l?r/Math.sin(s):n/Math.cos(s);return Math.abs(c)},T2e={dots:[],areas:[],lines:[]},CY=ss({name:"referenceElements",initialState:T2e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=zo(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=zo(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=zo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:KWe,removeDot:XWe,addArea:YWe,removeArea:ZWe,addLine:A2e,removeLine:N2e}=CY.actions,C2e=CY.reducer,kY=M.createContext(void 0),k2e=t=>{var{children:e}=t,[n]=M.useState("".concat(D0("recharts"),"-clip")),r=qM();if(r==null)return null;var{x:i,y:a,width:s,height:l}=r;return M.createElement(kY.Provider,{value:n},M.createElement("defs",null,M.createElement("clipPath",{id:n},M.createElement("rect",{x:i,y:a,height:l,width:s}))),e)},P2e=()=>M.useContext(kY);function R6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function D6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R6(Object(n),!0).forEach(function(r){j2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function j2e(t,e,n){return(e=R2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function R2e(t){var e=D2e(t,"string");return typeof e=="symbol"?e:e+""}function D2e(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 O2e=(t,e)=>{var n;if(M.isValidElement(t))n=M.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!qn(e.x1)||!qn(e.y1)||!qn(e.x2)||!qn(e.y2))return null;n=M.createElement("line",Pw({},e,{className:"recharts-reference-line-line"}))}return n},L2e=(t,e,n,r,i,a)=>{var{x:s,width:l}=a,c=i.y.apply(t,{position:n});if(as(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:s+l,y:c},{x:s,y:c}];return r==="left"?u.reverse():u},I2e=(t,e,n,r,i,a)=>{var{y:s,height:l}=a,c=i.x.apply(t,{position:n});if(as(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:s+l},{x:c,y:s}];return r==="top"?u.reverse():u},F2e=(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},U2e=(t,e,n,r,i,a)=>{var{x:s,y:l,segment:c,ifOverflow:u}=a,d=po(s),f=po(l);return f?L2e(l,u,n,i,t,e):d?I2e(s,u,n,r,t,e):c!=null&&c.length===2?F2e(c,u,n,t):null};function z2e(t){var e=cr();return M.useEffect(()=>(e(A2e(t)),()=>{e(N2e(t))})),null}function B2e(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,s=Ei(),l=P2e(),c=kt(C=>jl(C,e)),u=kt(C=>Rl(C,n)),d=kt(C=>yd(C,"xAxis",e,s)),f=kt(C=>yd(C,"yAxis",n,s)),g=Ob();if(!l||!g||c==null||u==null||d==null||f==null)return null;var p=S2e({x:d,y:f}),x=U2e(p,g,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:v,y},{x:b,y:E}]=x,w=a==="hidden"?"url(#".concat(l,")"):void 0,T=D6(D6({clipPath:w},la(t)),{},{x1:v,y1:y,x2:b,y2:E}),A=w2e({x1:v,y1:y,x2:b,y2:E});return M.createElement(wa,{zIndex:t.zIndex},M.createElement(jr,{className:Cn("recharts-reference-line",i)},O2e(r,T),M.createElement(aY,Pw({},A,{lowerWidth:A.width,upperWidth:A.width}),M.createElement(oY,{label:t.label}),t.children)))}var H2e={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:$r.line};function Wx(t){var e=Rr(t,H2e);return M.createElement(M.Fragment,null,M.createElement(z2e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),M.createElement(B2e,e))}Wx.displayName="ReferenceLine";function PY(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 $2e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return E2e(r,n)}function V2e(t,e,n){var r=n==="width",{x:i,y:a,width:s,height:l}=t;return e===1?{start:r?i:a,end:r?i+s:a+l}:{start:r?i+s:a+l,end:r?i:a}}function jw(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 G2e(t,e){return PY(t,e+1)}function W2e(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:l}=e,c=0,u=1,d=s,f=function(){var x=r?.[c];if(x===void 0)return{v:PY(r,u)};var v=c,y,b=()=>(y===void 0&&(y=n(x,v)),y),E=x.coordinate,w=c===0||jw(t,E,b,d,l);w||(c=0,d=s,u+=1),w&&(d=E+t*(b()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}function O6(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 pa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O6(Object(n),!0).forEach(function(r){q2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function q2e(t,e,n){return(e=K2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function K2e(t){var e=X2e(t,"string");return typeof e=="symbol"?e:e+""}function X2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Y2e(t,e,n,r,i){for(var a=(r||[]).slice(),s=a.length,{start:l}=e,{end:c}=e,u=function(g){var p=a[g],x,v=()=>(x===void 0&&(x=n(p,g)),x);if(g===s-1){var y=t*(p.coordinate+t*v()/2-c);a[g]=p=pa(pa({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate})}else a[g]=p=pa(pa({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var b=jw(t,p.tickCoord,v,l,c);b&&(c=p.tickCoord-t*(v()/2+i),a[g]=pa(pa({},p),{},{isShow:!0}))}},d=s-1;d>=0;d--)u(d);return a}function Z2e(t,e,n,r,i,a){var s=(r||[]).slice(),l=s.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),g=t*(d.coordinate+t*f/2-u);if(s[l-1]=d=pa(pa({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var p=jw(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),s[l-1]=pa(pa({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,v=function(E){var w=s[E],T,A=()=>(T===void 0&&(T=n(w,E)),T);if(E===0){var C=t*(w.coordinate-t*A()/2-c);s[E]=w=pa(pa({},w),{},{tickCoord:C<0?w.coordinate-C*t:w.coordinate})}else s[E]=w=pa(pa({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var N=jw(t,w.tickCoord,A,c,u);N&&(c=w.tickCoord+t*(A()/2+i),s[E]=pa(pa({},w),{},{isShow:!0}))}},y=0;y<x;y++)v(y);return s}function mO(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:s,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(jt(c)||sg.isSsr){var g;return(g=G2e(i,jt(c)?c:0))!==null&&g!==void 0?g:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",v=d&&x==="width"?i0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},y=(w,T)=>{var A=typeof u=="function"?u(w.value,T):w.value;return x==="width"?$2e(i0(A,{fontSize:e,letterSpacing:n}),v,f):i0(A,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?Bi(i[1].coordinate-i[0].coordinate):1,E=V2e(a,b,x);return c==="equidistantPreserveStart"?W2e(b,E,y,i,s):(c==="preserveStart"||c==="preserveStartEnd"?p=Z2e(b,E,y,i,s,c==="preserveStartEnd"):p=Y2e(b,E,y,i,s),p.filter(w=>w.isShow))}var Q2e=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 l=n?n.getBoundingClientRect().width:0,c=i+a,u=s+c+l+(n?r:0);return Math.round(u)}return 0},J2e=["axisLine","width","height","className","hide","ticks","axisType"];function eTe(t,e){if(t==null)return{};var n,r,i=tTe(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 tTe(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 of(){return of=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},of.apply(null,arguments)}function 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 oi(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){nTe(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 nTe(t,e,n){return(e=rTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rTe(t){var e=iTe(t,"string");return typeof e=="symbol"?e:e+""}function iTe(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 Pc={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:$r.axis};function aTe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:s,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=oi(oi(oi({},c),Oa(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!s||a==="bottom"&&s);u=oi(oi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!s||a==="right"&&s);u=oi(oi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return M.createElement("line",of({},u,{className:Cn("recharts-cartesian-axis-line",nf(l,"className"))}))}function sTe(t,e,n,r,i,a,s,l,c){var u,d,f,g,p,x,v=l?-1:1,y=t.tickSize||s,b=jt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!l*i,f=g-v*y,x=f-v*c,p=b;break;case"left":f=g=t.coordinate,d=e+ +!l*r,u=d-v*y,p=u-v*c,x=b;break;case"right":f=g=t.coordinate,d=e+ +l*r,u=d+v*y,p=u+v*c,x=b;break;default:u=d=t.coordinate,g=n+ +l*i,f=g+v*y,x=f+v*c,p=b;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:p,y:x}}}function oTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function lTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function cTe(t){var{option:e,tickProps:n,value:r}=t,i,a=Cn(n.className,"recharts-cartesian-axis-tick-value");if(M.isValidElement(e))i=M.cloneElement(e,oi(oi({},n),{},{className:a}));else if(typeof e=="function")i=e(oi(oi({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=Cn(s,e?.className)),i=M.createElement(zM,of({},n,{className:s}),r)}return i}var uTe=M.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:s,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:g,y:p,width:x,height:v,tickSize:y,tickMargin:b,fontSize:E,letterSpacing:w,getTicksConfig:T,events:A,axisType:C}=t,N=mO(oi(oi({},T),{},{ticks:n}),E,w),F=oTe(d,f),k=lTe(d,f),R=Oa(T),I=tf(r),L={};typeof i=="object"&&(L=i);var q=oi(oi({},R),{},{fill:"none"},L),j=N.map(W=>oi({entry:W},sTe(W,g,p,x,v,d,y,f,b))),V=j.map(W=>{var{entry:J,line:ee}=W;return M.createElement(jr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(J.value,"-").concat(J.coordinate,"-").concat(J.tickCoord)},i&&M.createElement("line",of({},q,ee,{className:Cn("recharts-cartesian-axis-tick-line",nf(i,"className"))})))}),K=j.map((W,J)=>{var{entry:ee,tick:Z}=W,B=oi(oi(oi(oi({textAnchor:F,verticalAnchor:k},R),{},{stroke:"none",fill:a},I),Z),{},{index:J,payload:ee,visibleTicksCount:N.length,tickFormatter:s,padding:c},u);return M.createElement(jr,of({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ee.value,"-").concat(ee.coordinate,"-").concat(ee.tickCoord)},kb(A,ee,J)),r&&M.createElement(cTe,{option:r,tickProps:B,value:"".concat(typeof s=="function"?s(ee.value,J):ee.value).concat(l||"")}))});return M.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},K.length>0&&M.createElement(wa,{zIndex:$r.label},M.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},K)),V.length>0&&M.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},V))}),dTe=M.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:l,axisType:c}=t,u=eTe(t,J2e),[d,f]=M.useState(""),[g,p]=M.useState(""),x=M.useRef(null);M.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var y;return Q2e({ticks:x.current,label:(y=t.labelRef)===null||y===void 0?void 0:y.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=M.useCallback(y=>{if(y){var b=y.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var E=b[0];if(E){var w=window.getComputedStyle(E),T=w.fontSize,A=w.letterSpacing;(T!==d||A!==g)&&(f(T),p(A))}}},[d,g]);return s||r!=null&&r<=0||i!=null&&i<=0?null:M.createElement(wa,{zIndex:t.zIndex},M.createElement(jr,{className:Cn("recharts-cartesian-axis",a)},M.createElement(aTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Oa(t)}),M.createElement(uTe,{ref:v,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),M.createElement(aY,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},M.createElement(oY,{label:t.label,labelRef:t.labelRef}),t.children)))}),pO=M.forwardRef((t,e)=>{var n=Rr(t,Pc);return M.createElement(dTe,of({},n,{ref:e}))});pO.displayName="CartesianAxis";var hTe=["x1","y1","x2","y2","key"],fTe=["offset"],mTe=["xAxisId","yAxisId"],pTe=["xAxisId","yAxisId"];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 xa(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){gTe(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 gTe(t,e,n){return(e=xTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xTe(t){var e=bTe(t,"string");return typeof e=="symbol"?e:e+""}function bTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Th(){return Th=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Th.apply(null,arguments)}function Rw(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}var vTe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:s,ry:l}=t;return M.createElement("rect",{x:r,y:i,ry:l,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function jY(t){var{option:e,lineItemProps:n}=t,r;if(M.isValidElement(e))r=M.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:s,x2:l,y2:c,key:u}=n,d=Rw(n,hTe),f=(i=Oa(d))!==null&&i!==void 0?i:{},{offset:g}=f,p=Rw(f,fTe);r=M.createElement("line",Th({},p,{x1:a,y1:s,x2:l,y2:c,fill:"none",key:u}))}return r}function _Te(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,l=Rw(t,mTe),c=i.map((u,d)=>{var f=xa(xa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return M.createElement(jY,{key:"line-".concat(d),option:r,lineItemProps:f})});return M.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function wTe(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,l=Rw(t,pTe),c=i.map((u,d)=>{var f=xa(xa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return M.createElement(jY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return M.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function STe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:s,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%e.length;return M.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:a,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function MTe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:s,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%n.length;return M.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:x,height:l,stroke:"none",fill:n[v],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var ETe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return pq(mO(xa(xa(xa({},Pc),n),{},{ticks:gq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},TTe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return pq(mO(xa(xa(xa({},Pc),n),{},{ticks:gq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},ATe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:$r.grid};function Dw(t){var e=BR(),n=HR(),r=Eq(),i=xa(xa({},Rr(t,ATe)),{},{x:jt(t.x)?t.x:r.left,y:jt(t.y)?t.y:r.top,width:jt(t.width)?t.width:r.width,height:jt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:s,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:p}=i,x=Ei(),v=kt(k=>E8(k,"xAxis",a,x)),y=kt(k=>E8(k,"yAxis",s,x));if(!yl(u)||!yl(d)||!jt(l)||!jt(c))return null;var b=i.verticalCoordinatesGenerator||ETe,E=i.horizontalCoordinatesGenerator||TTe,{horizontalPoints:w,verticalPoints:T}=i;if((!w||!w.length)&&typeof E=="function"){var A=g&&g.length,C=E({yAxis:y?xa(xa({},y),{},{ticks:A?g:y.ticks}):void 0,width:e??u,height:n??d,offset:r},A?!0:f);rw(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}if((!T||!T.length)&&typeof b=="function"){var N=p&&p.length,F=b({xAxis:v?xa(xa({},v),{},{ticks:N?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);rw(Array.isArray(F),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof F,"]")),Array.isArray(F)&&(T=F)}return M.createElement(wa,{zIndex:i.zIndex},M.createElement("g",{className:"recharts-cartesian-grid"},M.createElement(vTe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),M.createElement(STe,Th({},i,{horizontalPoints:w})),M.createElement(MTe,Th({},i,{verticalPoints:T})),M.createElement(_Te,Th({},i,{offset:r,horizontalPoints:w,xAxis:v,yAxis:y})),M.createElement(wTe,Th({},i,{offset:r,verticalPoints:T,xAxis:v,yAxis:y}))))}Dw.displayName="CartesianGrid";var RY=(t,e,n,r)=>wl(t,"xAxis",e,r),DY=(t,e,n,r)=>_l(t,"xAxis",e,r),OY=(t,e,n,r)=>wl(t,"yAxis",n,r),LY=(t,e,n,r)=>_l(t,"yAxis",n,r),NTe=Ze([vn,RY,OY,DY,LY],(t,e,n,r,i)=>Pl(t,"xAxis")?xd(e,r,!1):xd(n,i,!1)),CTe=(t,e,n,r,i)=>i;function kTe(t){return t.type==="line"}var PTe=Ze([Gb,CTe],(t,e)=>t.filter(kTe).find(n=>n.id===e)),jTe=Ze([vn,RY,OY,DY,LY,PTe,NTe,Bb],(t,e,n,r,i,a,s,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:g}=a,p;if(g!=null&&g.length>0?p=g:p=c?.slice(u,d+1),p!=null)return QTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:s,displayedData:p})}});function IY(t){var e=tf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,s=Number(i),l=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(l)||l<0)&&(l=r),{r:s,strokeWidth:l}}return{r:n,strokeWidth:r}}var RTe=["id"],DTe=["type","layout","connectNulls","needClip","shape"],OTe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function X0(){return X0=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},X0.apply(null,arguments)}function F6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function sl(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){LTe(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 LTe(t,e,n){return(e=ITe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ITe(t){var e=FTe(t,"string");return typeof e=="symbol"?e:e+""}function FTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gO(t,e){if(t==null)return{};var n,r,i=UTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var zTe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Cd(n,e),payload:t}]},BTe=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Cd(s,e),hide:l,type:u,color:r,unit:c}};return M.createElement(VM,{tooltipEntrySettings:d})}),FY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function HTe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var $Te=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return FY(e,t);for(var i=Math.floor(t/r),a=t%r,s=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,s]:[s];return[...HTe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function VTe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:s}=r,{id:l}=r,c=gO(r,RTe),u=Oa(c);return M.createElement(yY,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:s,clipPathId:e})}function GTe(t){var{showLabels:e,children:n,points:r}=t,i=M.useMemo(()=>r?.map(a=>{var s,l,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return sl(sl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return M.createElement(nO,{value:e?i:void 0},n)}function U6(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:s,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=gO(a,DTe),g=sl(sl({},la(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:s,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return M.createElement(M.Fragment,null,r?.length>1&&M.createElement(oO,X0({shapeType:"curve",option:d},g,{pathRef:n})),M.createElement(VTe,{points:r,clipPathId:e,props:a}))}function WTe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function qTe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:s,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:p,height:x,onAnimationEnd:v,onAnimationStart:y}=n,b=i.current,E=lg(s,"recharts-line-"),w=M.useRef(E),[T,A]=M.useState(!1),C=!T,N=M.useCallback(()=>{typeof v=="function"&&v(),A(!1)},[v]),F=M.useCallback(()=>{typeof y=="function"&&y(),A(!0)},[y]),k=WTe(r.current),R=M.useRef(0);w.current!==E&&(R.current=a.current,w.current=E);var I=R.current;return M.createElement(GTe,{points:s,showLabels:C},n.children,M.createElement(og,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:F,key:E},L=>{var q=Un(I,k+I,L),j=Math.min(q,k),V;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(ee=>parseFloat(ee));V=$Te(j,k,K)}else V=FY(k,j);else V=l==null?void 0:String(l);if(L>0&&k>0&&(i.current=s,a.current=Math.max(a.current,j)),b){var W=b.length/s.length,J=L===1?s:s.map((ee,Z)=>{var B=Math.floor(Z*W);if(b[B]){var G=b[B];return sl(sl({},ee),{},{x:Un(G.x,ee.x,L),y:Un(G.y,ee.y,L)})}return g?sl(sl({},ee),{},{x:Un(p*2,ee.x,L),y:Un(x/2,ee.y,L)}):sl(sl({},ee),{},{x:ee.x,y:ee.y})});return i.current=J,M.createElement(U6,{props:n,points:J,clipPathId:e,pathRef:r,strokeDasharray:V})}return M.createElement(U6,{props:n,points:s,clipPathId:e,pathRef:r,strokeDasharray:V})}),M.createElement(BM,{label:n.label}))}function KTe(t){var{clipPathId:e,props:n}=t,r=M.useRef(null),i=M.useRef(0),a=M.useRef(null);return M.createElement(qTe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var XTe=(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:Wn(t.payload,e)}};class YTe extends M.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:s,top:l,left:c,width:u,height:d,id:f,needClip:g,zIndex:p}=this.props;if(e)return null;var x=Cn("recharts-line",i),v=f,{r:y,strokeWidth:b}=IY(n),E=sO(n),w=y*2+b,T=g?"url(#clipPath-".concat(E?"":"dots-").concat(v,")"):void 0;return M.createElement(wa,{zIndex:p},M.createElement(jr,{className:x},g&&M.createElement("defs",null,M.createElement(fO,{clipPathId:v,xAxisId:a,yAxisId:s}),!E&&M.createElement("clipPath",{id:"clipPath-dots-".concat(v)},M.createElement("rect",{x:c-w/2,y:l-w/2,width:u+w,height:d+w}))),M.createElement(wY,{xAxisId:a,yAxisId:s,data:r,dataPointFormatter:XTe,errorBarOffset:0},M.createElement(KTe,{props:this.props,clipPathId:v}))),M.createElement(Q3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var UY={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:$r.line,type:"linear"};function ZTe(t){var e=Rr(t,UY),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:p,yAxisId:x,id:v}=e,y=gO(e,OTe),{needClip:b}=KM(p,x),E=qM(),w=vf(),T=Ei(),A=kt(R=>jTe(R,p,x,T,v));if(w!=="horizontal"&&w!=="vertical"||A==null||E==null)return null;var{height:C,width:N,x:F,y:k}=E;return M.createElement(YTe,X0({},y,{id:v,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:p,yAxisId:x,points:A,layout:w,height:C,width:N,left:F,top:k,needClip:b}))}function QTe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:s,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=Wn(u,s);if(e==="horizontal"){var g=nw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=xr(f)?null:r.scale(f);return{x:g,y:p,value:f,payload:u}}var x=xr(f)?null:n.scale(f),v=nw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||v==null?null:{x,y:v,value:f,payload:u}}).filter(Boolean)}function JTe(t){var e=Rr(t,UY),n=Ei();return M.createElement(GM,{id:e.id,type:"line"},r=>M.createElement(M.Fragment,null,M.createElement(dO,{legendPayload:zTe(e)}),M.createElement(BTe,{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}),M.createElement(hO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),M.createElement(ZTe,X0({},e,{id:r}))))}var zY=M.memo(JTe,ey);zY.displayName="Line";var BY=(t,e,n,r)=>wl(t,"xAxis",e,r),HY=(t,e,n,r)=>_l(t,"xAxis",e,r),$Y=(t,e,n,r)=>wl(t,"yAxis",n,r),VY=(t,e,n,r)=>_l(t,"yAxis",n,r),eAe=Ze([vn,BY,$Y,HY,VY],(t,e,n,r,i)=>Pl(t,"xAxis")?xd(e,r,!1):xd(n,i,!1)),tAe=(t,e,n,r,i)=>i,GY=Ze([Gb,tAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),nAe=(t,e,n,r,i)=>{var a,s=GY(t,e,n,r,i);if(s!=null){var l=vn(t),c=Pl(l,"xAxis"),u;if(c?u=q0(t,"yAxis",n,r):u=q0(t,"xAxis",e,r),u!=null){var{stackId:d}=s,f=PM(s);if(!(d==null||f==null)){var g=(a=u[d])===null||a===void 0?void 0:a.stackedData;return g?.find(p=>p.key===f)}}}},rAe=Ze([vn,BY,$Y,HY,VY,nAe,Bb,eAe,GY,Pye],(t,e,n,r,i,a,s,l,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||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,g+1),x!=null)return wAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),iAe=["id"],aAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Fh(){return Fh=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},Fh.apply(null,arguments)}function WY(t,e){if(t==null)return{};var n,r,i=sAe(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 sAe(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 z6(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 rp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z6(Object(n),!0).forEach(function(r){oAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oAe(t,e,n){return(e=lAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lAe(t){var e=cAe(t,"string");return typeof e=="symbol"?e:e+""}function cAe(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 Ow(t,e){return t&&t!=="none"?t:e}var uAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:Ow(r,i),value:Cd(n,e),payload:t}]},dAe=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Cd(s,e),hide:l,type:u,color:Ow(r,a),unit:c}};return M.createElement(VM,{tooltipEntrySettings:d})});function hAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,l=Oa(r);return M.createElement(yY,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:l,needClip:i,clipPathId:e})}function fAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var s,l,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return rp(rp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return M.createElement(nO,{value:e?i:void 0},n)}function B6(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:s,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,g=WY(a,iAe),p=Oa(g),x=la(g);return M.createElement(M.Fragment,null,e?.length>1&&M.createElement(jr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},M.createElement(cp,Fh({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),c!=="none"&&M.createElement(cp,Fh({},p,{className:"recharts-area-curve",layout:s,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&M.createElement(cp,Fh({},p,{className:"recharts-area-curve",layout:s,type:l,connectNulls:u,fill:"none",points:n}))),M.createElement(hAe,{points:e,props:g,clipPathId:i}))}function mAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!qn(a)||!qn(s))return null;var l=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.x||0));return jt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),jt(c)?M.createElement("rect",{x:0,y:a<s?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function pAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!qn(a)||!qn(s))return null;var l=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.y||0));return jt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),jt(c)?M.createElement("rect",{x:a<s?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function gAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?M.createElement(mAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):M.createElement(pAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function xAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:s,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:p}=r,x=M.useMemo(()=>({points:s,baseLine:l}),[s,l]),v=lg(x,"recharts-area-"),y=Xpe(),[b,E]=M.useState(!1),w=!b,T=M.useCallback(()=>{typeof p=="function"&&p(),E(!1)},[p]),A=M.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(y==null)return null;var C=i.current,N=a.current;return M.createElement(fAe,{showLabels:w,points:s},r.children,M.createElement(og,{animationId:v,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:A,key:v},F=>{if(C){var k=C.length/s.length,R=F===1?s:s.map((L,q)=>{var j=Math.floor(q*k);if(C[j]){var V=C[j];return rp(rp({},L),{},{x:Un(V.x,L.x,F),y:Un(V.y,L.y,F)})}return L}),I;return jt(l)?I=Un(N,l,F):xr(l)||as(l)?I=Un(N,0,F):I=l.map((L,q)=>{var j=Math.floor(q*k);if(Array.isArray(N)&&N[j]){var V=N[j];return rp(rp({},L),{},{x:Un(V.x,L.x,F),y:Un(V.y,L.y,F)})}return L}),F>0&&(i.current=R,a.current=I),M.createElement(B6,{points:R,baseLine:I,needClip:e,clipPathId:n,props:r})}return F>0&&(i.current=s,a.current=l),M.createElement(jr,null,c&&M.createElement("defs",null,M.createElement("clipPath",{id:"animationClipPath-".concat(n)},M.createElement(gAe,{alpha:F,points:s,baseLine:l,layout:y,strokeWidth:r.strokeWidth}))),M.createElement(jr,{clipPath:"url(#animationClipPath-".concat(n,")")},M.createElement(B6,{points:s,baseLine:l,needClip:e,clipPathId:n,props:r})))}),M.createElement(BM,{label:r.label}))}function bAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=M.useRef(null),a=M.useRef();return M.createElement(xAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class yAe extends M.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:s,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:p,zIndex:x}=this.props;if(e)return null;var v=Cn("recharts-area",i),y=g,{r:b,strokeWidth:E}=IY(n),w=sO(n),T=b*2+E,A=l?"url(#clipPath-".concat(w?"":"dots-").concat(y,")"):void 0;return M.createElement(wa,{zIndex:x},M.createElement(jr,{className:v},l&&M.createElement("defs",null,M.createElement(fO,{clipPathId:y,xAxisId:c,yAxisId:u}),!w&&M.createElement("clipPath",{id:"clipPath-dots-".concat(y)},M.createElement("rect",{x:s-T/2,y:a-T/2,width:d+T,height:f+T}))),M.createElement(bAe,{needClip:l,clipPathId:y,props:this.props})),M.createElement(Q3,{points:r,mainColor:Ow(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}),this.props.isRange&&Array.isArray(p)&&M.createElement(Q3,{points:p,mainColor:Ow(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}))}}var qY={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:$r.area};function vAe(t){var e,n=Rr(t,qY),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:p,stroke:x,xAxisId:v,yAxisId:y}=n,b=WY(n,aAe),E=vf(),w=HX(),{needClip:T}=KM(v,y),A=Ei(),{points:C,isRange:N,baseLine:F}=(e=kt(j=>rAe(j,v,y,A,t.id)))!==null&&e!==void 0?e:{},k=qM();if(E!=="horizontal"&&E!=="vertical"||k==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:R,width:I,x:L,y:q}=k;return!C||!C.length?null:M.createElement(yAe,Fh({},b,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,baseLine:F,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:E,isAnimationActive:g==="auto"?!sg.isSsr:g,isRange:N,legendType:p,needClip:T,points:C,stroke:x,width:I,left:L,top:q,xAxisId:v,yAxisId:y}))}var _Ae=(t,e,n,r,i)=>{var a=n??e;if(jt(a))return a;var s=t==="horizontal"?i:r,l=s.scale.domain();if(s.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function wAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:p}=t,x=i&&i.length,v=_Ae(a,s,n,l,c),y=a==="horizontal",b=!1,E=u.map((T,A)=>{var C;x?C=i[d+A]:(C=Wn(T,r),Array.isArray(C)?b=!0:C=[v,C]);var N=C[1]==null||x&&!e&&Wn(T,r)==null;return y?{x:nw({axis:l,ticks:f,bandSize:p,entry:T,index:A}),y:N?null:c.scale(C[1]),value:C,payload:T}:{x:N?null:l.scale(C[1]),y:nw({axis:c,ticks:g,bandSize:p,entry:T,index:A}),value:C,payload:T}}),w;return x||b?w=E.map(T=>{var A=Array.isArray(T.value)?T.value[0]:null;return y?{x:T.x,y:A!=null&&T.y!=null?c.scale(A):null,payload:T.payload}:{x:A!=null?l.scale(A):null,y:T.y,payload:T.payload}}):w=y?c.scale(v):l.scale(v),{points:E,baseLine:w,isRange:b}}function SAe(t){var e=Rr(t,qY),n=Ei();return M.createElement(GM,{id:e.id,type:"area"},r=>M.createElement(M.Fragment,null,M.createElement(dO,{legendPayload:uAe(e)}),M.createElement(dAe,{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}),M.createElement(hO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:xq(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),M.createElement(vAe,Fh({},e,{id:r}))))}var KY=M.memo(SAe,ey);KY.displayName="Area";var MAe=["domain","range"],EAe=["domain","range"];function H6(t,e){if(t==null)return{};var n,r,i=TAe(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 TAe(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 $6(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 XY(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=H6(t,MAe),{domain:a,range:s}=e,l=H6(e,EAe);return!$6(n,a)||!$6(r,s)?!1:ey(i,l)}var AAe=["dangerouslySetInnerHTML","ticks"],NAe=["id"];function eP(){return eP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},eP.apply(null,arguments)}function V6(t,e){if(t==null)return{};var n,r,i=CAe(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 CAe(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 kAe(t){var e=cr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(MMe(t)):n.current!==t&&e(EMe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(TMe(n.current)),n.current=null)},[e]),null}var PAe=t=>{var{xAxisId:e,className:n}=t,r=kt(UR),i=Ei(),a="xAxis",s=kt(y=>yd(y,a,e,i)),l=kt(y=>vX(y,a,e,i)),c=kt(y=>gX(y,e)),u=kt(y=>Nve(y,e)),d=kt(y=>ZK(y,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,p=V6(t,AAe),{id:x}=d,v=V6(d,NAe);return M.createElement(pO,eP({},p,v,{scale:s,x:u.x,y:u.y,width:c.width,height:c.height,className:Cn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},jAe={allowDataOverflow:Oi.allowDataOverflow,allowDecimals:Oi.allowDecimals,allowDuplicatedCategory:Oi.allowDuplicatedCategory,angle:Oi.angle,axisLine:Pc.axisLine,height:Oi.height,hide:!1,includeHidden:Oi.includeHidden,interval:Oi.interval,minTickGap:Oi.minTickGap,mirror:Oi.mirror,orientation:Oi.orientation,padding:Oi.padding,reversed:Oi.reversed,scale:Oi.scale,tick:Oi.tick,tickCount:Oi.tickCount,tickLine:Pc.tickLine,tickSize:Pc.tickSize,type:Oi.type,xAxisId:0},RAe=t=>{var e=Rr(t,jAe);return M.createElement(M.Fragment,null,M.createElement(kAe,{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}),M.createElement(PAe,e))},Lw=M.memo(RAe,XY);Lw.displayName="XAxis";var DAe=["dangerouslySetInnerHTML","ticks"],OAe=["id"];function tP(){return tP=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},tP.apply(null,arguments)}function G6(t,e){if(t==null)return{};var n,r,i=LAe(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 LAe(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 IAe(t){var e=cr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(AMe(t)):n.current!==t&&e(NMe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(CMe(n.current)),n.current=null)},[e]),null}var FAe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=M.useRef(null),s=M.useRef(null),l=kt(UR),c=Ei(),u=cr(),d="yAxis",f=kt(A=>yd(A,d,e,c)),g=kt(A=>xX(A,e)),p=kt(A=>kve(A,e)),x=kt(A=>vX(A,d,e,c)),v=kt(A=>QK(A,e));if(M.useLayoutEffect(()=>{if(!(r!=="auto"||!g||tO(i)||M.isValidElement(i)||v==null)){var A=a.current;if(A){var C=A.getCalculatedWidth();Math.round(g.width)!==Math.round(C)&&u(kMe({id:e,width:C}))}}},[x,g,u,i,e,r,v]),g==null||p==null||v==null)return null;var{dangerouslySetInnerHTML:y,ticks:b}=t,E=G6(t,DAe),{id:w}=v,T=G6(v,OAe);return M.createElement(pO,tP({},E,T,{ref:a,labelRef:s,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:Cn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},UAe={allowDataOverflow:Li.allowDataOverflow,allowDecimals:Li.allowDecimals,allowDuplicatedCategory:Li.allowDuplicatedCategory,angle:Li.angle,axisLine:Pc.axisLine,hide:!1,includeHidden:Li.includeHidden,interval:Li.interval,minTickGap:Li.minTickGap,mirror:Li.mirror,orientation:Li.orientation,padding:Li.padding,reversed:Li.reversed,scale:Li.scale,tick:Li.tick,tickCount:Li.tickCount,tickLine:Pc.tickLine,tickSize:Pc.tickSize,type:Li.type,width:Li.width,yAxisId:0},zAe=t=>{var e=Rr(t,UAe);return M.createElement(M.Fragment,null,M.createElement(IAe,{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}),M.createElement(FAe,e))},Iw=M.memo(zAe,XY);Iw.displayName="YAxis";var BAe=(t,e)=>e,xO=Ze([BAe,vn,XK,Ai,LX,Jc,G_e,Mi],Q_e),bO=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)}},YY=go("mouseClick"),ZY=Rb();ZY.startListening({actionCreator:YY,effect:(t,e)=>{var n=t.payload,r=xO(e.getState(),bO(n));r?.activeIndex!=null&&e.dispatch(Vve({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var nP=go("mouseMove"),QY=Rb(),Vv=null;QY.startListening({actionCreator:nP,effect:(t,e)=>{var n=t.payload;Vv!==null&&cancelAnimationFrame(Vv);var r=bO(n);Vv=requestAnimationFrame(()=>{var i=e.getState(),a=VD(i,i.tooltip.settings.shared);if(a==="axis"){var s=xO(i,r);s?.activeIndex!=null?e.dispatch(NX({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(AX())}Vv=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},JY=ss({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}}}),HAe=JY.reducer,{updateOptions:$Ae}=JY.actions,eZ=ss({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:VAe}=eZ.actions,GAe=eZ.reducer,tZ=go("keyDown"),nZ=go("focus"),yO=Rb();yO.startListening({actionCreator:tZ,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=GD(i,gg(n),qb(n),Zb(n)),l=s==null?-1:Number(s);if(!(!Number.isFinite(l)||l<0)){var c=Jc(n);if(a==="Enter"){var u=Mw(n,"axis","hover",String(i.index));e.dispatch(W3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=Dve(n),f=d==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,p=l+g*f;if(!(c==null||p>=c.length||p<0)){var x=Mw(n,"axis","hover",String(p));e.dispatch(W3({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});yO.startListening({actionCreator:nZ,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=Mw(n,"axis","hover",String(a));e.dispatch(W3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var qs=go("externalEvent"),rZ=Rb(),MN=new Map;rZ.startListening({actionCreator:qs,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=MN.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:k_e(l),activeDataKey:YD(l),activeIndex:vd(l),activeLabel:UX(l),activeTooltipIndex:vd(l),isTooltipActive:P_e(l)};n(c,r)}finally{MN.delete(i)}});MN.set(i,s)}}});var WAe=Ze([pg],t=>t.tooltipItemPayloads),qAe=Ze([WAe,Xb,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var s=e(a,n);return s}}}),iZ=go("touchMove"),aZ=Rb();aZ.startListening({actionCreator:iZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=VD(r,r.tooltip.settings.shared);if(i==="axis"){var a=xO(r,bO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(NX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var s,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(yq),d=(s=c.getAttribute(vq))!==null&&s!==void 0?s:void 0,f=qAe(e.getState(),u,d);e.dispatch(TX({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var KAe=zW({brush:b2e,cartesianAxis:PMe,chartData:C1e,errorBars:YMe,graphicalItems:FSe,layout:npe,legend:uge,options:M1e,polarAxis:Jwe,polarOptions:GAe,referenceElements:C2e,rootProps:HAe,tooltip:Gve,zIndex:h1e}),XAe=function(e){return Ame({reducer:KAe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([ZY.middleware,QY.middleware,yO.middleware,rZ.middleware,aZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(tq({type:"raf"}))},devTools:sg.devToolsEnabled})};function sZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Ei(),a=M.useRef(null);if(i)return n;a.current==null&&(a.current=XAe(e));var s=kR;return M.createElement(vEe,{context:s,store:a.current},n)}function YAe(t){var{layout:e,margin:n}=t,r=cr(),i=Ei();return M.useEffect(()=>{i||(r(Jme(e)),r(Qme(n)))},[r,i,e,n]),null}var oZ=M.memo(YAe,ey);function lZ(t){var e=cr();return M.useEffect(()=>{e($Ae(t))},[e,t]),null}function q6(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=gY("".concat(r).concat(e)),a=cr();return M.useLayoutEffect(()=>(a(u1e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(d1e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),M.createElement("g",{tabIndex:-1,id:i})}function K6(t){var{children:e,isPanorama:n}=t,r=kt(e1e);if(!r||r.length===0)return e;var i=r.filter(s=>s<0),a=r.filter(s=>s>0);return M.createElement(M.Fragment,null,i.map(s=>M.createElement(q6,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>M.createElement(q6,{key:s,zIndex:s,isPanorama:n})))}var ZAe=["children"];function QAe(t,e){if(t==null)return{};var n,r,i=JAe(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 JAe(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 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)}var eNe={width:"100%",height:"100%",display:"block"},tNe=M.forwardRef((t,e)=>{var n=BR(),r=HR(),i=Lq();if(!yl(n)||!yl(r))return null;var{children:a,otherAttributes:s,title:l,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),M.createElement(vR,Fw({},s,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:eNe,ref:e}),a)}),nNe=t=>{var{children:e}=t,n=kt(bM);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return M.createElement(vR,{width:r,height:i,x:s,y:a},e)},X6=M.forwardRef((t,e)=>{var{children:n}=t,r=QAe(t,ZAe),i=Ei();return i?M.createElement(nNe,null,M.createElement(K6,{isPanorama:!0},n)):M.createElement(tNe,Fw({ref:e},r),M.createElement(K6,{isPanorama:!1},n))});function rNe(){var t=cr(),[e,n]=M.useState(null),r=kt(ype);return M.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;qn(a)&&a!==r&&t(tpe(a))}},[e,t,r]),n}function Y6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function iNe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y6(Object(n),!0).forEach(function(r){aNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aNe(t,e,n){return(e=sNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sNe(t){var e=oNe(t,"string");return typeof e=="symbol"?e:e+""}function oNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function lf(){return lf=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},lf.apply(null,arguments)}var lNe=()=>(F1e(),null);function Uw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var cNe=M.forwardRef((t,e)=>{var n,r,i=M.useRef(null),[a,s]=M.useState({containerWidth:Uw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:Uw((r=t.style)===null||r===void 0?void 0:r.height)}),l=M.useCallback((u,d)=>{s(f=>{var g=Math.round(u),p=Math.round(d);return f.containerWidth===g&&f.containerHeight===p?f:{containerWidth:g,containerHeight:p}})},[]),c=M.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var g=x=>{var{width:v,height:y}=x[0].contentRect;l(v,y)},p=new ResizeObserver(g);p.observe(u),i.current=p}},[e,l]);return M.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),M.createElement(M.Fragment,null,M.createElement(yM,{width:a.containerWidth,height:a.containerHeight}),M.createElement("div",lf({ref:c},t)))}),uNe=M.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=M.useState({containerWidth:Uw(n),containerHeight:Uw(r)}),s=M.useCallback((c,u)=>{a(d=>{var f=Math.round(c),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),l=M.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();s(u,d)}},[e,s]);return M.createElement(M.Fragment,null,M.createElement(yM,{width:i.containerWidth,height:i.containerHeight}),M.createElement("div",lf({ref:l},t)))}),dNe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return M.createElement(M.Fragment,null,M.createElement(yM,{width:n,height:r}),M.createElement("div",lf({ref:e},t)))}),hNe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return zc(n)||zc(r)?M.createElement(uNe,lf({},t,{ref:e})):M.createElement(dNe,lf({},t,{ref:e}))});function fNe(t){return t===!0?cNe:hNe}var mNe=M.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:s,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:p,onTouchMove:x,onTouchStart:v,style:y,width:b,responsive:E,dispatchTouchEvents:w=!0}=t,T=M.useRef(null),A=cr(),[C,N]=M.useState(null),[F,k]=M.useState(null),R=rNe(),I=zR(),L=I?.width>0?I.width:b,q=I?.height>0?I.height:i,j=M.useCallback(me=>{R(me),typeof e=="function"&&e(me),N(me),k(me),me!=null&&(T.current=me)},[R,e,N,k]),V=M.useCallback(me=>{A(YY(me)),A(qs({handler:a,reactEvent:me}))},[A,a]),K=M.useCallback(me=>{A(nP(me)),A(qs({handler:u,reactEvent:me}))},[A,u]),W=M.useCallback(me=>{A(AX()),A(qs({handler:d,reactEvent:me}))},[A,d]),J=M.useCallback(me=>{A(nP(me)),A(qs({handler:f,reactEvent:me}))},[A,f]),ee=M.useCallback(()=>{A(nZ())},[A]),Z=M.useCallback(me=>{A(tZ(me.key))},[A]),B=M.useCallback(me=>{A(qs({handler:s,reactEvent:me}))},[A,s]),G=M.useCallback(me=>{A(qs({handler:l,reactEvent:me}))},[A,l]),Q=M.useCallback(me=>{A(qs({handler:c,reactEvent:me}))},[A,c]),te=M.useCallback(me=>{A(qs({handler:g,reactEvent:me}))},[A,g]),he=M.useCallback(me=>{A(qs({handler:v,reactEvent:me}))},[A,v]),oe=M.useCallback(me=>{w&&A(iZ(me)),A(qs({handler:x,reactEvent:me}))},[A,w,x]),xe=M.useCallback(me=>{A(qs({handler:p,reactEvent:me}))},[A,p]),Te=fNe(E);return M.createElement(qX.Provider,{value:C},M.createElement(tW.Provider,{value:F},M.createElement(Te,{width:L??y?.width,height:q??y?.height,className:Cn("recharts-wrapper",r),style:iNe({position:"relative",cursor:"default",width:L,height:q},y),onClick:V,onContextMenu:B,onDoubleClick:G,onFocus:ee,onKeyDown:Z,onMouseDown:Q,onMouseEnter:K,onMouseLeave:W,onMouseMove:J,onMouseUp:te,onTouchEnd:xe,onTouchMove:oe,onTouchStart:he,ref:j},M.createElement(lNe,null),n)))}),pNe=["width","height","responsive","children","className","style","compact","title","desc"];function gNe(t,e){if(t==null)return{};var n,r,i=xNe(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 xNe(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 cZ=M.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:s,style:l,compact:c,title:u,desc:d}=t,f=gNe(t,pNe),g=Oa(f);return c?M.createElement(M.Fragment,null,M.createElement(yM,{width:n,height:r}),M.createElement(X6,{otherAttributes:g,title:u,desc:d},a)):M.createElement(mNe,{className:s,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},M.createElement(X6,{otherAttributes:g,title:u,desc:d,ref:e},M.createElement(k2e,null,a)))});function rP(){return rP=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},rP.apply(null,arguments)}var bNe={top:5,right:5,bottom:5,left:5},yNe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:bNe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},vO=M.forwardRef(function(e,n){var r,i=Rr(e.categoricalChartProps,yNe),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return M.createElement(sZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},M.createElement(TY,{chartData:u.data}),M.createElement(oZ,{layout:i.layout,margin:i.margin}),M.createElement(lZ,{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}),M.createElement(cZ,rP({},i,{ref:n})))}),vNe=["axis"],_Ne=M.forwardRef((t,e)=>M.createElement(vO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:vNe,tooltipPayloadSearcher:UM,categoricalChartProps:t,ref:e})),wNe=["axis","item"],SNe=M.forwardRef((t,e)=>M.createElement(vO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:wNe,tooltipPayloadSearcher:UM,categoricalChartProps:t,ref:e}));function MNe(t){var e=cr();return M.useEffect(()=>{e(VAe(t))},[e,t]),null}var ENe=["layout"];function iP(){return iP=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},iP.apply(null,arguments)}function TNe(t,e){if(t==null)return{};var n,r,i=ANe(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 ANe(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 NNe={top:5,right:5,bottom:5,left:5},uZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:NNe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},CNe=M.forwardRef(function(e,n){var r,i=Rr(e.categoricalChartProps,uZ),{layout:a}=i,s=TNe(i,ENe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return M.createElement(sZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},M.createElement(TY,{chartData:i.data}),M.createElement(oZ,{layout:a,margin:i.margin}),M.createElement(lZ,{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}),M.createElement(MNe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),M.createElement(cZ,iP({},s,{ref:n})))});function Z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Q6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z6(Object(n),!0).forEach(function(r){kNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kNe(t,e,n){return(e=PNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PNe(t){var e=jNe(t,"string");return typeof e=="symbol"?e:e+""}function jNe(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 RNe=["item"],DNe=Q6(Q6({},uZ),{},{layout:"centric",startAngle:0,endAngle:360}),ONe=M.forwardRef((t,e)=>{var n=Rr(t,DNe);return M.createElement(CNe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:RNe,tooltipPayloadSearcher:UM,categoricalChartProps:n,ref:e})}),LNe=["axis"],INe=M.forwardRef((t,e)=>M.createElement(vO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:LNe,tooltipPayloadSearcher:UM,categoricalChartProps:t,ref:e}));const J6=[{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 FNe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:s="humidity",thresholds:l}){const{t:c}=eg(),{mode:u}=ag(),[d,f]=M.useState("24h"),[g,p]=M.useState(s),x=u==="dark";M.useEffect(()=>{if(!t)return;const G=Q=>{Q.key==="Escape"&&e()};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[t,e]);const v=J6.find(G=>G.value===d)?.hours||24,{data:y,isLoading:b,error:E}=gt({queryKey:["ams-history",n,i,v],queryFn:()=>Se.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const w=y?.data.map(G=>({time:new Date(G.recorded_at).getTime(),humidity:G.humidity,temperature:G.temperature,timeLabel:new Date(G.recorded_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}})}))||[],T=l?.humidityGood||40,A=l?.humidityFair||60,C=l?.tempGood||30,N=l?.tempFair||35,F=w[w.length-1],k=F?.humidity,R=F?.temperature,I=G=>{const Q=G.filter(me=>me!=null);if(Q.length<4)return"stable";const te=Q.slice(0,Math.floor(Q.length/4)),he=Q.slice(-Math.floor(Q.length/4)),oe=te.reduce((me,ce)=>me+ce,0)/te.length,Te=he.reduce((me,ce)=>me+ce,0)/he.length-oe;return Math.abs(Te)<2?"stable":Te>0?"up":"down"},L=I(w.map(G=>G.humidity)),q=I(w.map(G=>G.temperature)),j=({trend:G})=>G==="up"?o.jsx(VG,{className:"w-4 h-4 text-red-400"}):G==="down"?o.jsx($G,{className:"w-4 h-4 text-green-400"}):o.jsx(Qk,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),V=G=>G==null?"#9ca3af":G<=T?"#22a352":G<=A?"#d4a017":"#c62828",K=G=>G==null?"#9ca3af":G<=C?"#22a352":G<=N?"#d4a017":"#c62828",W=x?"#2d2d2d":"#ffffff",J=x?"#1d1d1d":"#f3f4f6",ee=x?"#3d3d3d":"#e5e7eb",Z=x?"#ffffff":"#111827",B=x?"#9ca3af":"#4b5563";return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:o.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:W},onClick:G=>G.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:ee},children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold",style:{color:Z},children:[a," ",c("common.history","History")]}),o.jsx("p",{className:"text-sm",style:{color:B},children:r})]}),o.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:B},children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:J},children:[o.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="humidity"?"bg-blue-600 text-white":""}`,style:g!=="humidity"?{color:B}:void 0,children:[o.jsx(lR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),o.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="temperature"?"bg-orange-600 text-white":""}`,style:g!=="temperature"?{color:B}:void 0,children:[o.jsx(tM,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),o.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:J},children:J6.map(G=>o.jsx("button",{onClick:()=>f(G.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===G.value?"bg-bambu-green text-white":""}`,style:d!==G.value?{color:B}:void 0,children:G.label},G.value))})]}),o.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.current","Current")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-2xl font-bold",style:{color:V(k)},children:k!=null?`${k}%`:"—"}),o.jsx(j,{trend:L})]})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.average","Average")}),o.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:y?.avg_humidity!=null?`${y.avg_humidity}%`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.min","Min")}),o.jsx("p",{className:"text-2xl font-bold text-green-500",children:y?.min_humidity!=null?`${y.min_humidity}%`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.max","Max")}),o.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_humidity!=null?`${y.max_humidity}%`:"—"})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.current","Current")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-2xl font-bold",style:{color:K(R)},children:R!=null?`${R}°C`:"—"}),o.jsx(j,{trend:q})]})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.average","Average")}),o.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:y?.avg_temperature!=null?`${y.avg_temperature}°C`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.min","Min")}),o.jsx("p",{className:"text-2xl font-bold text-blue-500",children:y?.min_temperature!=null?`${y.min_temperature}°C`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:B},children:c("common.max","Max")}),o.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_temperature!=null?`${y.max_temperature}°C`:"—"})]})]})}),o.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:b?o.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:B},children:c("common.loading","Loading...")}):E?o.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):w.length===0?o.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:B},children:c("common.noData","No data available for this time range")}):o.jsx(f1,{width:"100%",height:300,children:o.jsxs(_Ne,{data:w,children:[o.jsx(Dw,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),o.jsx(Lw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:G=>{const Q=new Date(G);return v>24?Q.toLocaleDateString([],{day:"numeric",month:"short"}):Q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),o.jsx(Iw,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:G=>g==="humidity"?`${G}%`:`${G}°C`}),o.jsx(p1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:G=>new Date(G).toLocaleString(),formatter:G=>[g==="humidity"?`${G}%`:`${G}°C`,g==="humidity"?"Humidity":"Temperature"]}),o.jsx(GR,{}),g==="humidity"?o.jsxs(o.Fragment,{children:[o.jsx(Wx,{y:T,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),o.jsx(Wx,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):o.jsxs(o.Fragment,{children:[o.jsx(Wx,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),o.jsx(Wx,{y:N,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),o.jsx(zY,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),o.jsx("div",{className:"text-xs text-center",style:{color:B},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function EN({data:t,children:e,disabled:n,className:r=""}){const[i,a]=M.useState(!1),[s,l]=M.useState("top"),c=M.useRef(null),u=M.useRef(null),d=M.useRef(null);M.useEffect(()=>{if(i&&c.current&&u.current){const y=c.current.getBoundingClientRect(),b=u.current.offsetHeight,E=y.top,w=window.innerHeight-y.bottom;E<b+12&&w>E?l("bottom"):l("top")}},[i]);const f=()=>{n||(d.current&&clearTimeout(d.current),d.current=setTimeout(()=>a(!0),80))},g=()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>a(!1),100)};M.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const p=y=>y<=15?"#ef4444":y<=30?"#f97316":y<=50?"#eab308":"#22c55e",x=y=>{if(!y)return!1;const b=y.replace("#",""),E=parseInt(b.slice(0,2),16),w=parseInt(b.slice(2,4),16),T=parseInt(b.slice(4,6),16);return(.299*E+.587*w+.114*T)/255>.6},v=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return o.jsxs("div",{ref:c,className:`relative ${r}`,onMouseEnter:f,onMouseLeave:g,children:[e,i&&o.jsxs("div",{ref:u,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${s==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[o.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[o.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:v||"#3d3d3d"},children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),o.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${x(v)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),o.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),o.jsxs("div",{className:"p-3 space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),o.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),o.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[o.jsx(lR,{className:"w-3 h-3"}),"Fill"]}),o.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),o.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:p(t.fillLevel)}}):o.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]})]})]}),o.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${s==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function eH({children:t,className:e=""}){const[n,r]=M.useState(!1),i=M.useRef(null),a=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!0),80)},s=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!1),100)};return M.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),o.jsxs("div",{className:`relative ${e}`,onMouseEnter:a,onMouseLeave:s,children:[t,n&&o.jsxs("div",{className:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[o.jsx("div",{className:`
- px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg text-xs text-bambu-gray whitespace-nowrap
- `,children:"Empty slot"}),o.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}const UNe={Y0:"Yellow",Y1:"Savana Yellow",Y2:"Sunflower Yellow",Y3:"Lemon Yellow",O0:"Orange",O1:"Mandarin Orange",O2:"Coral Orange",R0:"Red",R1:"Scarlet Red",R2:"Magenta",R3:"Sakura Pink",R4:"Raspberry Red",P0:"Pink",P1:"Sakura Pink",V0:"Purple",V1:"Violet",V2:"Lilac Purple",B0:"Blue",B1:"Sky Blue",B2:"Navy Blue",B3:"Ice Blue",B4:"Cyan",G0:"Green",G1:"Grass Green",G2:"Lime Green",G3:"Mint Green",G4:"Olive Green",G5:"Jungle Green",G6:"Bambu Green",N0:"Brown",N1:"Peanut Brown",N2:"Coffee Brown",N3:"Caramel Brown",A0:"Gray",A1:"Charcoal Gray",A2:"Silver Gray",A3:"Titan Gray",K0:"Black",K1:"Black",W0:"White",W1:"Jade White",W2:"Ivory White",T0:"Transparent",C0:"Marble",X0:"Bronze",X1:"Gold",X2:"Silver"};function TN(t){if(!t)return null;const e=t.split("-");if(e.length<2)return null;const n=e[1];return UNe[n]||null}function AN(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,s=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=s>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,g=r/255;i===d?l=((f-g)/u+(f<g?6:0))/6:i===f?l=((g-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,s<.15?"Black":s>.85?"White":c<.15?s<.4?"Dark Gray":s>.6?"Light Gray":"Gray":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function NN(t){return(t??.02).toFixed(3)}function tH({side:t}){const{mode:e}=ag(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return o.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 nH({className:t}){return o.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.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 zNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.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"}),o.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 BNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.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"}),o.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 HNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.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"}),o.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function $Ne({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),o.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),o.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 VNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),o.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),o.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 CN({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?o.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),o.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),o.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"})]}):o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.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"}),o.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function rH({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,s=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=s?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=s?d=nH:a<=l?d=zNe:d=BNe,o.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[o.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),o.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function iH({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,s=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=HNe):t<=s?(l="#d4a017",c="Fair",u=$Ne):(l="#c62828",c="Bad",u=VNe),o.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[o.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),o.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function cm(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 aH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function GNe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function WNe(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 qNe(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 KNe(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 XNe({url:t,printName:e}){const[n,r]=M.useState(!1),[i,a]=M.useState(!1),[s,l]=M.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&l(!0),children:t&&!i?o.jsxs(o.Fragment,{children:[o.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&o.jsx(_p,{className:"w-8 h-8 text-bambu-gray"})]}):o.jsx(_p,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:o.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[o.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&o.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function YNe({printers:t}){const e=mn(),n=M.useMemo(()=>{let i=0,a=0,s=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:a++:s++}),{printing:i,idle:a,offline:s,loading:l,total:t?.length||0}},[t,e]),[,r]=M.useState(0);return M.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(s=>s+1),i=!1}))});return()=>a()},[e]),t?.length?o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),o.jsxs("span",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),o.jsxs("span",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),o.jsxs("span",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function sH(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 oH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const a=mn(),s=wb(),[l,c]=M.useState(!1),[u,d]=M.useState(!1),[f,g]=M.useState(!0),[p,x]=M.useState(!1),[v,y]=M.useState(!1),[b,E]=M.useState(!1),[w,T]=M.useState(!1),[A,C]=M.useState(!1),[N,F]=M.useState(!1),[k,R]=M.useState(null),{data:I}=gt({queryKey:["printerStatus",t.id],queryFn:()=>Se.getPrinterStatus(t.id),refetchInterval:3e4}),L=M.useMemo(()=>{const $=new Set;if(I?.ams)for(const Y of I.ams)for(const se of Y.tray||[])se.tray_info_idx&&$.add(se.tray_info_idx);return I?.vt_tray?.tray_info_idx&&$.add(I.vt_tray.tray_info_idx),Array.from($)},[I?.ams,I?.vt_tray]),{data:q}=gt({queryKey:["filamentInfo",L],queryFn:()=>Se.getFilamentInfo(L),enabled:L.length>0,staleTime:300*1e3}),[j,V]=M.useState(null);M.useEffect(()=>{I?.wifi_signal!=null&&V(I.wifi_signal)},[I?.wifi_signal]);const K=I?.wifi_signal??j,W=M.useRef(void 0);M.useEffect(()=>{I?.connected!==void 0&&(W.current=I.connected)},[I?.connected]);const J=I?.connected??W.current,ee=M.useRef({});M.useEffect(()=>{I?.ams_extruder_map&&Object.keys(I.ams_extruder_map).length>0&&(ee.current=I.ams_extruder_map)},[I?.ams_extruder_map]);const Z=I?.ams_extruder_map&&Object.keys(I.ams_extruder_map).length>0?I.ams_extruder_map:ee.current,B=M.useRef([]);M.useEffect(()=>{I?.ams&&I.ams.length>0&&(B.current=I.ams)},[I?.ams]);const G=I?.ams&&I.ams.length>0?I.ams:B.current,Q=M.useRef(255),te=I?.tray_now;te!==void 0&&te!==255&&(Q.current=te);const he=te===void 0||te===255?Q.current:te,{data:oe}=gt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Se.getSmartPlugByPrinter(t.id)}),{data:xe}=gt({queryKey:["smartPlugStatus",oe?.id],queryFn:()=>oe?Se.getSmartPlugStatus(oe.id):null,enabled:!!oe,refetchInterval:1e4}),{data:Te}=gt({queryKey:["queue",t.id,"pending"],queryFn:()=>Se.getQueue(t.id,"pending")}),me=Te?.length||0,{data:ce}=gt({queryKey:["archives",t.id,"last"],queryFn:()=>Se.getArchives(t.id,1,0),enabled:I?.connected&&I?.state!=="RUNNING"}),Ce=ce?.[0],fe=e&&J===!1,Ie=vt({mutationFn:$=>Se.deletePrinter(t.id,$.deleteArchives),onSuccess:()=>{a.invalidateQueries({queryKey:["printers"]}),a.invalidateQueries({queryKey:["archives"]})}}),z=vt({mutationFn:()=>Se.connectPrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printerStatus",t.id]})}}),H=vt({mutationFn:$=>oe?Se.controlSmartPlug(oe.id,$):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugStatus",oe?.id]})}}),re=vt({mutationFn:$=>oe?Se.updateSmartPlug(oe.id,{auto_off:$}):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),a.invalidateQueries({queryKey:["smart-plugs"]})}});return fe?null:o.jsxs(wt,{className:"relative",children:[o.jsxs(Et,{children:[o.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("img",{src:qNe(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"}`}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&o.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${I?.connected?"bg-bambu-green":"bg-red-500"}`,title:I?.connected?"Connected":"Offline"})]}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&I?.nozzles&&I.nozzles[0]?.nozzle_diameter&&o.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:I.nozzles[0].nozzle_type||"Nozzle",children:["• ",I.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&o.jsxs("span",{className:"ml-2 text-bambu-gray",children:[o.jsx(rr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),o.jsxs("div",{className:"relative flex-shrink-0",children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>c(!l),children:o.jsx(cR,{className:"w-4 h-4"})}),l&&o.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:[o.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{x(!0),c(!1)},children:[o.jsx(Uc,{className:"w-4 h-4"}),"Edit"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{z.mutate(),c(!1)},children:[o.jsx(_a,{className:"w-4 h-4"}),"Reconnect"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{E(!0),c(!1)},children:[o.jsx(HG,{className:"w-4 h-4"}),"MQTT Debug"]}),o.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:[o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&o.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[o.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${I?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[I?.connected?o.jsx(Tb,{className:"w-3 h-3"}):o.jsx(GG,{className:"w-3 h-3"}),I?.connected?"Connected":"Offline"]}),I?.connected&&K!=null&&o.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${K>=-50||K>=-60?"bg-bambu-green/20 text-bambu-green":K>=-70?"bg-amber-500/20 text-amber-600":K>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${K} dBm - ${KNe(K).label}`,children:[o.jsx(kue,{className:"w-3 h-3"}),K,"dBm"]}),I?.connected&&(()=>{const $=I.hms_errors?Hde(I.hms_errors):[];return o.jsxs("button",{onClick:()=>F(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${$.length>0?$.some(Y=>Y.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:[o.jsx(Gn,{className:"w-3 h-3"}),$.length>0?$.length:"OK"]})})(),n&&o.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:[o.jsx(gd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),me>0&&o.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:`${me} print${me>1?"s":""} in queue`,children:[o.jsx(pd,{className:"w-3 h-3"}),me]})]})]}),u&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:o.jsx(wt,{className:"w-full max-w-md mx-4",children:o.jsxs(Et,{children:[o.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[o.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:o.jsx(Gn,{className:"w-5 h-5 text-red-400"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),o.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),o.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:f,onChange:$=>g($.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:f?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:()=>{d(!1),g(!0)},children:"Cancel"}),o.jsx(ke,{variant:"danger",onClick:()=>{Ie.mutate({deleteArchives:f}),d(!1),g(!0)},children:"Delete"})]})]})})}),I?.connected&&o.jsxs(o.Fragment,{children:[r==="compact"?o.jsx("div",{className:"mt-2",children:I.state==="RUNNING"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:o.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${I.progress||0}%`}})}),o.jsxs("span",{className:"text-xs text-white",children:[Math.round(I.progress||0),"%"]})]}):o.jsx("p",{className:"text-xs text-bambu-gray",children:sH(I.state,I.stg_cur_name)})}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:o.jsxs("div",{className:"flex gap-3",children:[o.jsx(XNe,{url:I.state==="RUNNING"?I.cover_url:null,printName:I.state==="RUNNING"&&(I.subtask_name||I.current_print)||void 0}),o.jsx("div",{className:"flex-1 min-w-0",children:I.current_print&&I.state==="RUNNING"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:I.stg_cur_name||"Printing"}),o.jsx("p",{className:"text-white text-sm mb-2 truncate",children:I.subtask_name||I.current_print}),o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:o.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${I.progress||0}%`}})}),o.jsxs("span",{className:"text-white",children:[Math.round(I.progress||0),"%"]})]}),o.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[I.remaining_time!=null&&I.remaining_time>0&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(rr,{className:"w-3 h-3"}),GNe(I.remaining_time*60)]}),o.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",WNe(I.remaining_time)]})]}),I.layer_num!=null&&I.total_layers!=null&&I.total_layers>0&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(pd,{className:"w-3 h-3"}),I.layer_num,"/",I.total_layers]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),o.jsx("p",{className:"text-white text-sm mb-2",children:sH(I.state,I.stg_cur_name)}),o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:o.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),o.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Ce?o.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Ce.print_name||Ce.filename,children:["Last: ",Ce.print_name||Ce.filename,Ce.completed_at&&o.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(Ce.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):o.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),I.state!=="RUNNING"&&o.jsx(Wde,{printerId:t.id})]}),I.temperatures&&r==="expanded"&&(()=>{const $=I.temperatures.nozzle_heating||I.temperatures.nozzle_2_heating||!1,Y=I.temperatures.bed_heating||!1,se=I.temperatures.chamber_heating||!1;return o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(CN,{className:"w-4 h-4 mx-auto mb-1",color:"text-orange-400",isHeating:$}),I.temperatures.nozzle_2!==void 0?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),o.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.nozzle||0),"°C / ",Math.round(I.temperatures.nozzle_2||0),"°C"]})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),o.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.nozzle||0),"°C"]})]})]}),o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(CN,{className:"w-4 h-4 mx-auto mb-1",color:"text-blue-400",isHeating:Y}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),o.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.bed||0),"°C"]})]}),I.temperatures.chamber!==void 0&&o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(CN,{className:"w-4 h-4 mx-auto mb-1",color:"text-green-400",isHeating:se}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),o.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.chamber||0),"°C"]})]})]})})(),G&&G.length>0&&r==="expanded"&&(()=>{const $=G.filter(ue=>ue.tray.length>1),Y=G.filter(ue=>ue.tray.length===1),se=t.nozzle_count===2||I?.temperatures?.nozzle_2!==void 0;return o.jsxs("div",{className:"mt-4 pt-3 border-t border-bambu-dark-tertiary/50",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Filaments"}),o.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),o.jsxs("div",{className:"space-y-3",children:[$.length>0&&o.jsx("div",{className:"grid grid-cols-2 gap-3",children:$.map(ue=>{const Ee=Z[String(ue.id)],Me=ue.id>=128?ue.id-128:ue.id,U=Ee!==void 0?Ee:Me,O=U===1,ne=U===0;return o.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[10px] text-white font-medium",children:cm(ue.id,ue.tray.length)}),se&&(O||ne)&&o.jsx(tH,{side:O?"L":"R"})]}),(ue.humidity!=null||ue.temp!=null)&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[ue.humidity!=null&&o.jsx(rH,{humidity:ue.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>R({amsId:ue.id,amsLabel:cm(ue.id,ue.tray.length),mode:"humidity"}),compact:!0}),ue.temp!=null&&o.jsx(iH,{temp:ue.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>R({amsId:ue.id,amsLabel:cm(ue.id,ue.tray.length),mode:"temperature"}),compact:!0})]})]}),o.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(be=>{const ye=ue.tray[be]||ue.tray.find(ze=>ze.id===be),_e=ye?.tray_type&&ye.remain>=0,We=!ye?.tray_type,Ve=ue.id*4+be,Ye=he===Ve,lt=ye?.tray_info_idx?q?.[ye.tray_info_idx]:null,de=ye?.tray_type?{vendor:ye.tray_uuid?"Bambu Lab":"Generic",profile:lt?.name||ye.tray_sub_brands||ye.tray_type,colorName:TN(ye.tray_id_name)||AN(ye.tray_color),colorHex:ye.tray_color||null,kFactor:NN(ye.k),fillLevel:_e?ye.remain:null}:null,ae=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${We?"opacity-50":""} ${Ye?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[o.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:ye?.tray_color?`#${ye.tray_color}`:ye?.tray_type?"#333":"transparent",borderColor:We?"#666":"rgba(255,255,255,0.1)",borderStyle:We?"dashed":"solid"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ye?.tray_type||"—"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:_e&&ye?o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ye.remain}%`,backgroundColor:aH(ye.remain)}}):ye?.tray_type?o.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return de?o.jsx(EN,{data:de,children:ae},be):o.jsx(eH,{children:ae},be)})})]},ue.id)})}),(Y.length>0||I.vt_tray&&I.vt_tray.tray_type)&&o.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Y.map(ue=>{const Ee=Z[String(ue.id)],Me=ue.id>=128?ue.id-128:ue.id,U=Ee!==void 0?Ee:Me,O=U===1,ne=U===0,be=ue.tray[0],ye=be?.tray_type&&be.remain>=0,_e=!be?.tray_type,We=ue.id*4+(be?.id??0),Ve=he===We,Ye=be?.tray_info_idx?q?.[be.tray_info_idx]:null,lt=be?.tray_type?{vendor:be.tray_uuid?"Bambu Lab":"Generic",profile:Ye?.name||be.tray_sub_brands||be.tray_type,colorName:TN(be.tray_id_name)||AN(be.tray_color),colorHex:be.tray_color||null,kFactor:NN(be.k),fillLevel:ye?be.remain:null}:null,de=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${_e?"opacity-50":""} ${Ve?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[o.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:be?.tray_color?`#${be.tray_color}`:be?.tray_type?"#333":"transparent",borderColor:_e?"#666":"rgba(255,255,255,0.1)",borderStyle:_e?"dashed":"solid"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:be?.tray_type||"—"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:ye?o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${be.remain}%`,backgroundColor:aH(be.remain)}}):be?.tray_type?o.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return o.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[o.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[o.jsx("span",{className:"text-[10px] text-white font-medium",children:cm(ue.id,ue.tray.length)}),se&&(O||ne)&&o.jsx(tH,{side:O?"L":"R"})]}),o.jsxs("div",{className:"flex gap-1.5",children:[lt?o.jsx(EN,{data:lt,className:"flex-1",children:de}):o.jsx(eH,{className:"flex-1",children:de}),(ue.humidity!=null||ue.temp!=null)&&o.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[ue.temp!=null&&o.jsx(iH,{temp:ue.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>R({amsId:ue.id,amsLabel:cm(ue.id,ue.tray.length),mode:"temperature"}),compact:!0}),ue.humidity!=null&&o.jsx(rH,{humidity:ue.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>R({amsId:ue.id,amsLabel:cm(ue.id,ue.tray.length),mode:"humidity"}),compact:!0})]})]})]},ue.id)}),I.vt_tray&&I.vt_tray.tray_type&&(()=>{const ue=I.vt_tray,Ee=he===254,Me=ue.tray_info_idx?q?.[ue.tray_info_idx]:null,U={vendor:ue.tray_uuid?"Bambu Lab":"Generic",profile:Me?.name||ue.tray_sub_brands||ue.tray_type||"Unknown",colorName:TN(ue.tray_id_name)||AN(ue.tray_color),colorHex:ue.tray_color||null,kFactor:NN(ue.k),fillLevel:null},O=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Ee?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[o.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:ue.tray_color?`#${ue.tray_color}`:"#333",borderColor:Ee?"var(--accent)":"rgba(255,255,255,0.1)"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ue.tray_type||"Spool"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return o.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[o.jsx("div",{className:"flex items-center gap-1 mb-2",children:o.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),o.jsx(EN,{data:U,children:O})]})})()]})]})]})})()]}),oe&&r==="expanded"&&o.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(ef,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),o.jsx("span",{className:"text-sm text-white truncate",children:oe.name}),xe&&o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${xe.state==="ON"?"bg-bambu-green/20 text-bambu-green":xe.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:xe.state||"?"}),xe?.energy?.power!=null&&xe.state==="ON"&&o.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[xe.energy.power,"W"]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("button",{onClick:()=>T(!0),disabled:H.isPending||xe?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${xe?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[o.jsx(kl,{className:"w-3 h-3"}),"On"]}),o.jsxs("button",{onClick:()=>C(!0),disabled:H.isPending||xe?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${xe?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[o.jsx(JS,{className:"w-3 h-3"}),"Off"]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:`text-xs hidden sm:inline ${oe.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:oe.auto_off_executed?"Auto-off done":"Auto-off"}),o.jsx("button",{onClick:()=>re.mutate(!oe.auto_off),disabled:re.isPending||oe.auto_off_executed,title:oe.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 ${oe.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":oe.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:o.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${oe.auto_off||oe.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[o.jsxs("div",{className:"text-xs text-bambu-gray",children:[o.jsx("p",{children:t.ip_address}),o.jsx("p",{className:"truncate",children:t.serial_number})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>{const $=localStorage.getItem("cameraWindowState"),Y=$?JSON.parse($):{width:640,height:400},se=[`width=${Y.width}`,`height=${Y.height}`,Y.left!==void 0?`left=${Y.left}`:"",Y.top!==void 0?`top=${Y.top}`:"","menubar=no,toolbar=no,location=no,status=no"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,se)},disabled:!I?.connected,title:"Open camera in new window",children:o.jsx(WG,{className:"w-4 h-4"})}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>y(!0),title:"Browse printer files",children:[o.jsx(hR,{className:"w-4 h-4"}),"Files"]})]})]})]}),v&&o.jsx(Ude,{printerId:t.id,printerName:t.name,onClose:()=>y(!1)}),b&&o.jsx(zde,{printerId:t.id,printerName:t.name,onClose:()=>E(!1)}),w&&oe&&o.jsx(kr,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{H.mutate("on"),T(!1)},onCancel:()=>T(!1)}),A&&oe&&o.jsx(kr,{title:"Power Off Printer",message:I?.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:()=>{H.mutate("off"),C(!1)},onCancel:()=>C(!1)}),N&&o.jsx(Vde,{printerName:t.name,errors:I?.hms_errors||[],onClose:()=>F(!1)}),k&&o.jsx(FNe,{isOpen:!!k,onClose:()=>R(null),printerId:t.id,printerName:t.name,amsId:k.amsId,amsLabel:k.amsLabel,initialMode:k.mode,thresholds:i}),p&&o.jsx(QNe,{printer:t,onClose:()=>x(!1)})]})}function ZNe({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=M.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,s]=M.useState(!1),[l,c]=M.useState([]),[u,d]=M.useState(""),[f,g]=M.useState(!1),[p,x]=M.useState(!1),[v,y]=M.useState("192.168.1.0/24"),[b,E]=M.useState({scanned:0,total:0});M.useEffect(()=>{Jo.getInfo().then(N=>{x(N.is_docker)}).catch(()=>{})},[]);const w=l.filter(N=>!n.includes(N.serial)),T=async()=>{d(""),c([]),s(!0),g(!1),E({scanned:0,total:0});try{if(p){await Jo.startSubnetScan(v);const N=setInterval(async()=>{try{const F=await Jo.getScanStatus();E({scanned:F.scanned,total:F.total});const k=await Jo.getDiscoveredPrinters();c(k),F.running||(clearInterval(N),s(!1),g(!0))}catch(F){console.error("Failed to get scan status:",F)}},500)}else{await Jo.startDiscovery(10);const N=setInterval(async()=>{try{const F=await Jo.getDiscoveredPrinters();c(F)}catch(F){console.error("Failed to get discovered printers:",F)}},1e3);setTimeout(async()=>{clearInterval(N);try{await Jo.stopDiscovery()}catch{}s(!1),g(!0);try{const F=await Jo.getDiscoveredPrinters();c(F)}catch(F){console.error("Failed to get final discovered printers:",F)}},1e4)}}catch(N){console.error("Failed to start discovery:",N),d(N instanceof Error?N.message:"Failed to start discovery"),s(!1),g(!0)}},A=N=>N?{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"}[N]||N:"",C=N=>{i({...r,name:N.name||"",serial_number:N.serial,ip_address:N.ip_address,model:A(N.model)}),c([])};return M.useEffect(()=>()=>{Jo.stopDiscovery().catch(()=>{}),Jo.stopSubnetScan().catch(()=>{})},[]),M.useEffect(()=>{const N=F=>{F.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]),o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:o.jsx(wt,{className:"w-full max-w-md",onClick:N=>N.stopPropagation(),children:o.jsxs(Et,{children:[o.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),o.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[p&&o.jsxs("div",{className:"mb-3",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),o.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:v,onChange:N=>y(N.target.value),placeholder:"192.168.1.0/24",disabled:a}),o.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",o.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),o.jsx(ke,{type:"button",variant:"secondary",onClick:T,disabled:a,className:"w-full",children:a?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),p&&b.total>0?`Scanning... ${b.scanned}/${b.total}`:"Scanning..."]}):o.jsxs(o.Fragment,{children:[o.jsx(bl,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&o.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),w.length>0&&o.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:w.map(N=>o.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>C(N),children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"font-medium text-white text-sm truncate",children:N.name||N.serial}),o.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[A(N.model)||"Unknown"," • ",N.ip_address]})]}),o.jsx(Cl,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},N.serial))}),a&&o.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!a&&l.length===0&&o.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",p?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&w.length===0&&o.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),o.jsxs("form",{onSubmit:N=>{N.preventDefault(),e(r)},className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),o.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:N=>i({...r,name:N.target.value}),placeholder:"My Printer"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),o.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:N=>i({...r,ip_address:N.target.value}),placeholder:"192.168.1.100"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),o.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:N=>i({...r,serial_number:N.target.value}),placeholder:"01P00A000000000"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),o.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:N=>i({...r,access_code:N.target.value}),placeholder:"From printer settings"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),o.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:N=>i({...r,model:N.target.value}),children:[o.jsx("option",{value:"",children:"Select model..."}),o.jsxs("optgroup",{label:"H2 Series",children:[o.jsx("option",{value:"H2C",children:"H2C"}),o.jsx("option",{value:"H2D",children:"H2D"}),o.jsx("option",{value:"H2S",children:"H2S"})]}),o.jsxs("optgroup",{label:"X1 Series",children:[o.jsx("option",{value:"X1E",children:"X1E"}),o.jsx("option",{value:"X1C",children:"X1 Carbon"}),o.jsx("option",{value:"X1",children:"X1"})]}),o.jsxs("optgroup",{label:"P Series",children:[o.jsx("option",{value:"P2S",children:"P2S"}),o.jsx("option",{value:"P1S",children:"P1S"}),o.jsx("option",{value:"P1P",children:"P1P"})]}),o.jsxs("optgroup",{label:"A1 Series",children:[o.jsx("option",{value:"A1",children:"A1"}),o.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:N=>i({...r,auto_archive:N.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),o.jsxs("div",{className:"flex gap-3 pt-4",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function QNe({printer:t,onClose:e}){const n=mn(),[r,i]=M.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=vt({mutationFn:l=>Se.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});M.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const s=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:o.jsx(wt,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:o.jsxs(Et,{children:[o.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),o.jsxs("form",{onSubmit:s,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),o.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:l=>i({...r,name:l.target.value}),placeholder:"My Printer"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),o.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:l=>i({...r,ip_address:l.target.value}),placeholder:"192.168.1.100"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),o.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}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),o.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:l=>i({...r,access_code:l.target.value}),placeholder:"Leave empty to keep current"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),o.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:l=>i({...r,model:l.target.value}),children:[o.jsx("option",{value:"",children:"Select model..."}),o.jsxs("optgroup",{label:"H2 Series",children:[o.jsx("option",{value:"H2C",children:"H2C"}),o.jsx("option",{value:"H2D",children:"H2D"}),o.jsx("option",{value:"H2S",children:"H2S"})]}),o.jsxs("optgroup",{label:"X1 Series",children:[o.jsx("option",{value:"X1E",children:"X1E"}),o.jsx("option",{value:"X1C",children:"X1 Carbon"}),o.jsx("option",{value:"X1",children:"X1"})]}),o.jsxs("optgroup",{label:"P Series",children:[o.jsx("option",{value:"P2S",children:"P2S"}),o.jsx("option",{value:"P1S",children:"P1S"}),o.jsx("option",{value:"P1P",children:"P1P"})]}),o.jsxs("optgroup",{label:"A1 Series",children:[o.jsx("option",{value:"A1",children:"A1"}),o.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),o.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:l=>i({...r,location:l.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:l=>i({...r,auto_archive:l.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),o.jsxs("div",{className:"flex gap-3 pt-4",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function JNe(t){const{data:e}=gt({queryKey:["printerStatus",t],queryFn:()=>Se.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function eCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=JNe(t.id),{data:a}=gt({queryKey:["smartPlugStatus",e.id],queryFn:()=>Se.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?o.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&o.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||"?"})]}),o.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:[o.jsx(kl,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function tCe(){const[t,e]=M.useState(!1),[n,r]=M.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=M.useState(!1),[s,l]=M.useState(null),[c,u]=M.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=M.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,p]=M.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),x=mn(),{data:v,isLoading:y}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:b}=gt({queryKey:["settings"],queryFn:Se.getSettings}),{data:E}=gt({queryKey:["smart-plugs"],queryFn:Se.getSmartPlugs}),{data:w}=gt({queryKey:["maintenanceOverview"],queryFn:Se.getMaintenanceOverview,staleTime:60*1e3}),T=w?.reduce((j,V)=>(j[V.printer_id]={due_count:V.due_count,warning_count:V.warning_count,total_print_hours:V.total_print_hours},j),{})||{},A=E?.reduce((j,V)=>(V.printer_id&&(j[V.printer_id]=V),j),{})||{},C=vt({mutationFn:Se.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),N=vt({mutationFn:j=>Se.controlSmartPlug(j,"on"),onSuccess:()=>{x.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),F=()=>{const j=!n;r(j),localStorage.setItem("hideDisconnectedPrinters",String(j))},k=j=>{u(j),localStorage.setItem("printerSortBy",j)},R=()=>{const j=!d;f(j),localStorage.setItem("printerSortAsc",String(j))},I=()=>{const j=g==="expanded"?"compact":"expanded";p(j),localStorage.setItem("printerViewMode",j)},L=M.useMemo(()=>{if(!v)return[];const j=[...v];switch(c){case"name":j.sort((V,K)=>V.name.localeCompare(K.name));break;case"model":j.sort((V,K)=>(V.model||"").localeCompare(K.model||""));break;case"location":j.sort((V,K)=>{const W=V.location||"",J=K.location||"";return!W&&J?1:W&&!J?-1:W.localeCompare(J)||V.name.localeCompare(K.name)});break;case"status":j.sort((V,K)=>{const W=x.getQueryData(["printerStatus",V.id]),J=x.getQueryData(["printerStatus",K.id]),ee=Z=>Z?.connected?Z.state==="RUNNING"?0:1:2;return ee(W)-ee(J)});break}return d||j.reverse(),j},[v,c,d,x]),q=M.useMemo(()=>{if(c!=="location")return null;const j={};return L.forEach(V=>{const K=V.location||"Ungrouped";j[K]||(j[K]=[]),j[K].push(V)}),j},[c,L]);return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"flex items-center justify-between mb-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),o.jsx(YNe,{printers:v})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("select",{value:c,onChange:j=>k(j.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:[o.jsx("option",{value:"name",children:"Name"}),o.jsx("option",{value:"status",children:"Status"}),o.jsx("option",{value:"model",children:"Model"}),o.jsx("option",{value:"location",children:"Location"})]}),o.jsx("button",{onClick:R,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?o.jsx(vp,{className:"w-4 h-4 text-bambu-gray"}):o.jsx(N0,{className:"w-4 h-4 text-bambu-gray"})})]}),o.jsx("button",{onClick:I,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"?o.jsx(xce,{className:"w-5 h-5 text-bambu-gray"}):o.jsx(QS,{className:"w-5 h-5 text-bambu-gray"})}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:n,onChange:F,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(A).length>0&&o.jsxs("div",{className:"relative",children:[o.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:[o.jsx(kl,{className:"w-4 h-4"}),"Power On",o.jsx(Cl,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),o.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:[o.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"}),v?.filter(j=>A[j.id]).map(j=>o.jsx(eCe,{printer:j,plug:A[j.id],onPowerOn:V=>{l(V),N.mutate(V)},isPowering:s===A[j.id]?.id},j.id)),v?.filter(j=>A[j.id]).length===0&&o.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),o.jsxs(ke,{onClick:()=>e(!0),children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),y?o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):v?.length===0?o.jsx(wt,{children:o.jsxs(Et,{className:"text-center py-12",children:[o.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),o.jsxs(ke,{onClick:()=>e(!0),children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?o.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([j,V])=>o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),j,o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",V.length,")"]})]}),o.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:V.map(K=>o.jsx(oH,{printer:K,hideIfDisconnected:n,maintenanceInfo:T[K.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},K.id))})]},j))}):o.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:L.map(j=>o.jsx(oH,{printer:j,hideIfDisconnected:n,maintenanceInfo:T[j.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},j.id))}),t&&o.jsx(ZNe,{onClose:()=>e(!1),onAdd:j=>C.mutate(j),existingSerials:v?.map(j=>j.serial_number)||[]})]})}function nCe(){const t=navigator.userAgent.toLowerCase(),e=navigator.platform?.toLowerCase()||"";return t.includes("win")||e.includes("win")?"windows":t.includes("mac")||e.includes("mac")?"macos":t.includes("linux")||e.includes("linux")?"linux":"unknown"}function rCe(){switch(nCe()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function gh(t){const e=rCe();window.location.href=`${e}${encodeURIComponent(t)}`}const _O="181",dp={ROTATE:0,DOLLY:1,PAN:2},ip={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},iCe=0,lH=1,aCe=2,dZ=1,sCe=2,fc=3,wd=0,es=1,ll=2,jc=0,hp=1,cH=2,uH=3,dH=4,oCe=5,xh=100,lCe=101,cCe=102,uCe=103,dCe=104,hCe=200,fCe=201,mCe=202,pCe=203,aP=204,sP=205,gCe=206,xCe=207,bCe=208,yCe=209,vCe=210,_Ce=211,wCe=212,SCe=213,MCe=214,oP=0,lP=1,cP=2,Lp=3,uP=4,dP=5,hP=6,fP=7,wO=0,ECe=1,TCe=2,sd=0,ACe=1,NCe=2,CCe=3,kCe=4,PCe=5,jCe=6,RCe=7,hZ=300,Ip=301,Fp=302,mP=303,pP=304,YM=306,gP=1e3,Ec=1001,xP=1002,Cs=1003,DCe=1004,Gv=1005,so=1006,kN=1007,Ah=1008,Sl=1009,fZ=1010,mZ=1011,Y0=1012,SO=1013,cf=1014,Tc=1015,xg=1016,MO=1017,EO=1018,Z0=1020,pZ=35902,gZ=35899,xZ=1021,bZ=1022,Lo=1023,Q0=1026,J0=1027,yZ=1028,TO=1029,AO=1030,NO=1031,CO=1033,x1=33776,b1=33777,y1=33778,v1=33779,bP=35840,yP=35841,vP=35842,_P=35843,wP=36196,SP=37492,MP=37496,EP=37808,TP=37809,AP=37810,NP=37811,CP=37812,kP=37813,PP=37814,jP=37815,RP=37816,DP=37817,OP=37818,LP=37819,IP=37820,FP=37821,UP=36492,zP=36494,BP=36495,HP=36283,$P=36284,VP=36285,GP=36286,OCe=3200,LCe=3201,vZ=0,ICe=1,Ku="",Zs="srgb",Up="srgb-linear",zw="linear",Qn="srgb",um=7680,hH=519,FCe=512,UCe=513,zCe=514,_Z=515,BCe=516,HCe=517,$Ce=518,VCe=519,fH=35044,mH="300 es",hl=2e3,Bw=2001;function wZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Hw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function GCe(){const t=Hw("canvas");return t.style.display="block",t}const pH={};function gH(...t){const e="THREE."+t.shift();console.log(e,...t)}function Zt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Zr(...t){const e="THREE."+t.shift();console.error(e,...t)}function eb(...t){const e=t.join(" ");e in pH||(pH[e]=!0,Zt(...t))}function WCe(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 Sf=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 ua=["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"],_1=Math.PI/180,WP=180/Math.PI;function ny(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ua[t&255]+ua[t>>8&255]+ua[t>>16&255]+ua[t>>24&255]+"-"+ua[e&255]+ua[e>>8&255]+"-"+ua[e>>16&15|64]+ua[e>>24&255]+"-"+ua[n&63|128]+ua[n>>8&255]+"-"+ua[n>>16&255]+ua[n>>24&255]+ua[r&255]+ua[r>>8&255]+ua[r>>16&255]+ua[r>>24&255]).toLowerCase()}function yn(t,e,n){return Math.max(e,Math.min(n,t))}function qCe(t,e){return(t%e+e)%e}function PN(t,e,n){return(1-n)*t+n*e}function Tx(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function qa(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const KCe={DEG2RAD:_1};let dn=class SZ{constructor(e=0,n=0){SZ.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=yn(this.x,e.x,n.x),this.y=yn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=yn(this.x,e,n),this.y=yn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(yn(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(yn(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}},uf=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,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=a[s+0],p=a[s+1],x=a[s+2],v=a[s+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==x){let y=c*g+u*p+d*x+f*v;y<0&&(g=-g,p=-p,x=-x,v=-v,y=-y);let b=1-l;if(y<.9995){const E=Math.acos(y),w=Math.sin(E);b=Math.sin(b*E)/w,l=Math.sin(l*E)/w,c=c*b+g*l,u=u*b+p*l,d=d*b+x*l,f=f*b+v*l}else{c=c*b+g*l,u=u*b+p*l,d=d*b+x*l,f=f*b+v*l;const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],p=a[s+2],x=a[s+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,s=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:Zt("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],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+l+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(s-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+s)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+s)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(s-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(yn(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,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*l+i*u-a*c,this._y=i*d+s*c+a*l-r*u,this._z=a*d+s*u+r*c-i*l,this._w=s*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,s=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,s=-s,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+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}},it=class MZ{constructor(e=0,n=0,r=0){MZ.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(xH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(xH.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,l=e.z,c=e.w,u=2*(s*i-l*r),d=2*(l*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-l*d,this.y=r+c*d+l*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=yn(this.x,e.x,n.x),this.y=yn(this.y,e.y,n.y),this.z=yn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=yn(this.x,e,n),this.y=yn(this.y,e,n),this.z=yn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(yn(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,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*s-r*c,this.z=r*l-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 jN.copy(this).projectOnVector(e),this.sub(jN)}reflect(e){return this.sub(jN.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(yn(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 jN=new it,xH=new uf;let fn=class EZ{constructor(e,n,r,i,a,s,l,c,u){EZ.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,l,c,u)}set(e,n,r,i,a,s,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=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],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],v=i[0],y=i[3],b=i[6],E=i[1],w=i[4],T=i[7],A=i[2],C=i[5],N=i[8];return a[0]=s*v+l*E+c*A,a[3]=s*y+l*w+c*C,a[6]=s*b+l*T+c*N,a[1]=u*v+d*E+f*A,a[4]=u*y+d*w+f*C,a[7]=u*b+d*T+f*N,a[2]=g*v+p*E+x*A,a[5]=g*y+p*w+x*C,a[8]=g*b+p*T+x*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],l=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*l*u-r*a*d+r*l*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],l=e[5],c=e[6],u=e[7],d=e[8],f=d*s-l*u,g=l*c-d*a,p=u*a-s*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*l)+s+e,-i*u,i*c,-i*(-u*s+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(RN.makeScale(e,n)),this}rotate(e){return this.premultiply(RN.makeRotation(-e)),this}translate(e,n){return this.premultiply(RN.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 RN=new fn,bH=new fn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),yH=new fn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function XCe(){const t={enabled:!0,workingColorSpace:Up,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Qn&&(i.r=Rc(i.r),i.g=Rc(i.g),i.b=Rc(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=fp(i.r),i.g=fp(i.g),i.b=fp(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===Ku?zw: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 eb("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return eb("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({[Up]:{primaries:e,whitePoint:r,transfer:zw,toXYZ:bH,fromXYZ:yH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Zs},outputColorSpaceConfig:{drawingBufferColorSpace:Zs}},[Zs]:{primaries:e,whitePoint:r,transfer:Qn,toXYZ:bH,fromXYZ:yH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Zs}}}),t}const Dn=XCe();function Rc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function fp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let dm,YCe=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{dm===void 0&&(dm=Hw("canvas")),dm.width=e.width,dm.height=e.height;const i=dm.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=dm}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=Hw("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]=Rc(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(Rc(n[r]/255)*255):n[r]=Rc(n[r]);return{data:n,width:e.width,height:e.height}}else return Zt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},ZCe=0,kO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ZCe++}),this.uuid=ny(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,l=i.length;s<l;s++)i[s].isDataTexture?a.push(DN(i[s].image)):a.push(DN(i[s]))}else a=DN(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function DN(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?YCe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Zt("Texture: Unable to serialize Texture."),{})}let QCe=0;const ON=new it;let qo=class w1 extends Sf{constructor(e=w1.DEFAULT_IMAGE,n=w1.DEFAULT_MAPPING,r=Ec,i=Ec,a=so,s=Ah,l=Lo,c=Sl,u=w1.DEFAULT_ANISOTROPY,d=Ku){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:QCe++}),this.uuid=ny(),this.name="",this.source=new kO(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=l,this.internalFormat=null,this.type=c,this.offset=new dn(0,0),this.repeat=new dn(1,1),this.center=new dn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ON).x}get height(){return this.source.getSize(ON).y}get depth(){return this.source.getSize(ON).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){Zt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Zt(`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!==hZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case gP:e.x=e.x-Math.floor(e.x);break;case Ec:e.x=e.x<0?0:1;break;case xP: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 gP:e.y=e.y-Math.floor(e.y);break;case Ec:e.y=e.y<0?0:1;break;case xP: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++}};qo.DEFAULT_IMAGE=null;qo.DEFAULT_MAPPING=hZ;qo.DEFAULT_ANISOTROPY=1;let li=class TZ{constructor(e=0,n=0,r=0,i=1){TZ.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],p=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,T=(p+1)/2,A=(b+1)/2,C=(d+g)/4,N=(f+v)/4,F=(x+y)/4;return w>T&&w>A?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=N/r):T>A?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=F/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=N/a,i=F/a),this.set(r,i,a,n),this}let E=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(y-x)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+b-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=yn(this.x,e.x,n.x),this.y=yn(this.y,e.y,n.y),this.z=yn(this.z,e.z,n.z),this.w=yn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=yn(this.x,e,n),this.y=yn(this.y,e,n),this.z=yn(this.z,e,n),this.w=yn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(yn(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}},JCe=class extends Sf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:so,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 li(0,0,e,n),this.scissorTest=!1,this.viewport=new li(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new qo(i);this.textures=[];const s=r.count;for(let l=0;l<s;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:so,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 kO(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"})}},df=class extends JCe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},AZ=class extends qo{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=Cs,this.minFilter=Cs,this.wrapR=Ec,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},eke=class extends qo{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=Cs,this.minFilter=Cs,this.wrapR=Ec,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},hf=class{constructor(e=new it(1/0,1/0,1/0),n=new it(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Mo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Mo.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=Mo.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,l=a.count;s<l;s++)e.isMesh===!0?e.getVertexPosition(s,Mo):Mo.fromBufferAttribute(a,s),Mo.applyMatrix4(e.matrixWorld),this.expandByPoint(Mo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Wv.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Wv.copy(r.boundingBox)),Wv.applyMatrix4(e.matrixWorld),this.union(Wv)}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,Mo),Mo.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(Ax),qv.subVectors(this.max,Ax),hm.subVectors(e.a,Ax),fm.subVectors(e.b,Ax),mm.subVectors(e.c,Ax),Mu.subVectors(fm,hm),Eu.subVectors(mm,fm),Qd.subVectors(hm,mm);let n=[0,-Mu.z,Mu.y,0,-Eu.z,Eu.y,0,-Qd.z,Qd.y,Mu.z,0,-Mu.x,Eu.z,0,-Eu.x,Qd.z,0,-Qd.x,-Mu.y,Mu.x,0,-Eu.y,Eu.x,0,-Qd.y,Qd.x,0];return!LN(n,hm,fm,mm,qv)||(n=[1,0,0,0,1,0,0,0,1],!LN(n,hm,fm,mm,qv))?!1:(Kv.crossVectors(Mu,Eu),n=[Kv.x,Kv.y,Kv.z],LN(n,hm,fm,mm,qv))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Mo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Mo).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:(Jl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jl),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 Jl=[new it,new it,new it,new it,new it,new it,new it,new it],Mo=new it,Wv=new hf,hm=new it,fm=new it,mm=new it,Mu=new it,Eu=new it,Qd=new it,Ax=new it,qv=new it,Kv=new it,Jd=new it;function LN(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){Jd.fromArray(t,a);const l=i.x*Math.abs(Jd.x)+i.y*Math.abs(Jd.y)+i.z*Math.abs(Jd.z),c=e.dot(Jd),u=n.dot(Jd),d=r.dot(Jd);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const tke=new hf,Nx=new it,IN=new it;let ZM=class{constructor(e=new it,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):tke.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;Nx.subVectors(e,this.center);const n=Nx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Nx,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):(IN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Nx.copy(e.center).add(IN)),this.expandByPoint(Nx.copy(e.center).sub(IN))),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 ec=new it,FN=new it,Xv=new it,Tu=new it,UN=new it,Yv=new it,zN=new it;let PO=class{constructor(e=new it,n=new it(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ec)),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=ec.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(ec.copy(this.origin).addScaledVector(this.direction,n),ec.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){FN.copy(e).add(n).multiplyScalar(.5),Xv.copy(n).sub(e).normalize(),Tu.copy(this.origin).sub(FN);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Xv),l=Tu.dot(this.direction),c=-Tu.dot(Xv),u=Tu.lengthSq(),d=Math.abs(1-s*s);let f,g,p,x;if(d>0)if(f=s*c-l,g=s*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,p=f*(f+s*g+2*l)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(s*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(FN).addScaledVector(Xv,g),p}intersectSphere(e,n){ec.subVectors(e.center,this.origin);const r=ec.dot(this.direction),i=ec.dot(ec)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),l=r-s,c=r+s;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,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?(l=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(l=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,ec)!==null}intersectTriangle(e,n,r,i,a){UN.subVectors(n,e),Yv.subVectors(r,e),zN.crossVectors(UN,Yv);let s=this.direction.dot(zN),l;if(s>0){if(i)return null;l=1}else if(s<0)l=-1,s=-s;else return null;Tu.subVectors(this.origin,e);const c=l*this.direction.dot(Yv.crossVectors(Tu,Yv));if(c<0)return null;const u=l*this.direction.dot(UN.cross(Tu));if(u<0||c+u>s)return null;const d=-l*Tu.dot(zN);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)}},hi=class qP{constructor(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){qP.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,l,c,u,d,f,g,p,x,v,y)}set(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=l,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=p,b[7]=x,b[11]=v,b[15]=y,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 qP().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/pm.setFromMatrixColumn(e,0).length(),a=1/pm.setFromMatrixColumn(e,1).length(),s=1/pm.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),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-v*u,n[9]=-l*c,n[2]=v-g*u,n[6]=x+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g+v*l,n[4]=x*l-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-l,n[2]=p*l-x,n[6]=v+g*l,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g-v*l,n[4]=-s*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=s*d,n[9]=v-g*l,n[2]=-s*u,n[6]=l,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+p,n[1]=f,n[5]=s*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=v*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(nke,e,rke)}lookAt(e,n,r){const i=this.elements;return xs.subVectors(e,n),xs.lengthSq()===0&&(xs.z=1),xs.normalize(),Au.crossVectors(r,xs),Au.lengthSq()===0&&(Math.abs(r.z)===1?xs.x+=1e-4:xs.z+=1e-4,xs.normalize(),Au.crossVectors(r,xs)),Au.normalize(),Zv.crossVectors(xs,Au),i[0]=Au.x,i[4]=Zv.x,i[8]=xs.x,i[1]=Au.y,i[5]=Zv.y,i[9]=xs.y,i[2]=Au.z,i[6]=Zv.z,i[10]=xs.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],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],v=r[6],y=r[10],b=r[14],E=r[3],w=r[7],T=r[11],A=r[15],C=i[0],N=i[4],F=i[8],k=i[12],R=i[1],I=i[5],L=i[9],q=i[13],j=i[2],V=i[6],K=i[10],W=i[14],J=i[3],ee=i[7],Z=i[11],B=i[15];return a[0]=s*C+l*R+c*j+u*J,a[4]=s*N+l*I+c*V+u*ee,a[8]=s*F+l*L+c*K+u*Z,a[12]=s*k+l*q+c*W+u*B,a[1]=d*C+f*R+g*j+p*J,a[5]=d*N+f*I+g*V+p*ee,a[9]=d*F+f*L+g*K+p*Z,a[13]=d*k+f*q+g*W+p*B,a[2]=x*C+v*R+y*j+b*J,a[6]=x*N+v*I+y*V+b*ee,a[10]=x*F+v*L+y*K+b*Z,a[14]=x*k+v*q+y*W+b*B,a[3]=E*C+w*R+T*j+A*J,a[7]=E*N+w*I+T*V+A*ee,a[11]=E*F+w*L+T*K+A*Z,a[15]=E*k+w*q+T*W+A*B,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],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+v*(+n*c*p-n*u*g+a*s*g-i*s*p+i*u*d-a*c*d)+y*(+n*u*f-n*l*p-a*s*f+r*s*p+a*l*d-r*u*d)+b*(-i*l*d-n*c*f+n*l*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],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],v=e[13],y=e[14],b=e[15],E=f*y*u-v*g*u+v*c*p-l*y*p-f*c*b+l*g*b,w=x*g*u-d*y*u-x*c*p+s*y*p+d*c*b-s*g*b,T=d*v*u-x*f*u+x*l*p-s*v*p-d*l*b+s*f*b,A=x*f*c-d*v*c-x*l*g+s*v*g+d*l*y-s*f*y,C=n*E+r*w+i*T+a*A;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/C;return e[0]=E*N,e[1]=(v*g*a-f*y*a-v*i*p+r*y*p+f*i*b-r*g*b)*N,e[2]=(l*y*a-v*c*a+v*i*u-r*y*u-l*i*b+r*c*b)*N,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*N,e[4]=w*N,e[5]=(d*y*a-x*g*a+x*i*p-n*y*p-d*i*b+n*g*b)*N,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*p+n*c*p)*N,e[8]=T*N,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*b-n*f*b)*N,e[10]=(s*v*a-x*l*a+x*r*u-n*v*u-s*r*b+n*l*b)*N,e[11]=(d*l*a-s*f*a-d*r*u+n*f*u+s*r*p-n*l*p)*N,e[12]=A*N,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*N,e[14]=(x*l*i-s*v*i-x*r*c+n*v*c+s*r*y-n*l*y)*N,e[15]=(s*f*i-d*l*i+d*r*c-n*f*c-s*r*g+n*l*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,l=e.y,c=e.z,u=a*s,d=a*l;return this.set(u*s+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*s,0,u*c-i*l,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,l=n._z,c=n._w,u=a+a,d=s+s,f=l+l,g=a*u,p=a*d,x=a*f,v=s*d,y=s*f,b=l*f,E=c*u,w=c*d,T=c*f,A=r.x,C=r.y,N=r.z;return i[0]=(1-(v+b))*A,i[1]=(p+T)*A,i[2]=(x-w)*A,i[3]=0,i[4]=(p-T)*C,i[5]=(1-(g+b))*C,i[6]=(y+E)*C,i[7]=0,i[8]=(x+w)*N,i[9]=(y-E)*N,i[10]=(1-(g+v))*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=pm.set(i[0],i[1],i[2]).length();const s=pm.set(i[4],i[5],i[6]).length(),l=pm.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],Eo.copy(this);const u=1/a,d=1/s,f=1/l;return Eo.elements[0]*=u,Eo.elements[1]*=u,Eo.elements[2]*=u,Eo.elements[4]*=d,Eo.elements[5]*=d,Eo.elements[6]*=d,Eo.elements[8]*=f,Eo.elements[9]*=f,Eo.elements[10]*=f,n.setFromRotationMatrix(Eo),r.x=a,r.y=s,r.z=l,this}makePerspective(e,n,r,i,a,s,l=hl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),p=(r+i)/(r-i);let x,v;if(c)x=a/(s-a),v=s*a/(s-a);else if(l===hl)x=-(s+a)/(s-a),v=-2*s*a/(s-a);else if(l===Bw)x=-s/(s-a),v=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,s,l=hl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,v;if(c)x=1/(s-a),v=s/(s-a);else if(l===hl)x=-2/(s-a),v=-(s+a)/(s-a);else if(l===Bw)x=-1/(s-a),v=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const pm=new it,Eo=new hi,nke=new it(0,0,0),rke=new it(1,1,1),Au=new it,Zv=new it,xs=new it,vH=new hi,_H=new uf;let Sd=class NZ{constructor(e=0,n=0,r=0,i=NZ.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],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(yn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-yn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(yn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-yn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(yn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-yn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:Zt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return vH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(vH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return _H.setFromEuler(this),this.setFromQuaternion(_H,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}};Sd.DEFAULT_ORDER="XYZ";let CZ=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}},ike=0;const wH=new it,gm=new uf,tc=new hi,Qv=new it,Cx=new it,ake=new it,ske=new uf,SH=new it(1,0,0),MH=new it(0,1,0),EH=new it(0,0,1),TH={type:"added"},oke={type:"removed"},xm={type:"childadded",child:null},BN={type:"childremoved",child:null};let Rs=class S1 extends Sf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ike++}),this.uuid=ny(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=S1.DEFAULT_UP.clone();const e=new it,n=new Sd,r=new uf,i=new it(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 hi},normalMatrix:{value:new fn}}),this.matrix=new hi,this.matrixWorld=new hi,this.matrixAutoUpdate=S1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=S1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new CZ,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 gm.setFromAxisAngle(e,n),this.quaternion.multiply(gm),this}rotateOnWorldAxis(e,n){return gm.setFromAxisAngle(e,n),this.quaternion.premultiply(gm),this}rotateX(e){return this.rotateOnAxis(SH,e)}rotateY(e){return this.rotateOnAxis(MH,e)}rotateZ(e){return this.rotateOnAxis(EH,e)}translateOnAxis(e,n){return wH.copy(e).applyQuaternion(this.quaternion),this.position.add(wH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(SH,e)}translateY(e){return this.translateOnAxis(MH,e)}translateZ(e){return this.translateOnAxis(EH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(tc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Qv.copy(e):Qv.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Cx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?tc.lookAt(Cx,Qv,this.up):tc.lookAt(Qv,Cx,this.up),this.quaternion.setFromRotationMatrix(tc),i&&(tc.extractRotation(i.matrixWorld),gm.setFromRotationMatrix(tc),this.quaternion.premultiply(gm.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(TH),xm.child=e,this.dispatchEvent(xm),xm.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(oke),BN.child=e,this.dispatchEvent(BN),BN.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),tc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),tc.multiply(e.parent.matrixWorld)),e.applyMatrix4(tc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(TH),xm.child=e,this.dispatchEvent(xm),xm.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(Cx,e,ake),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cx,ske,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(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),p=s(e.animations),x=s(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Rs.DEFAULT_UP=new it(0,1,0);Rs.DEFAULT_MATRIX_AUTO_UPDATE=!0;Rs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const To=new it,nc=new it,HN=new it,rc=new it,bm=new it,ym=new it,AH=new it,$N=new it,VN=new it,GN=new it,WN=new li,qN=new li,KN=new li;let kx=class Xm{constructor(e=new it,n=new it,r=new it){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),To.subVectors(e,n),i.cross(To);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){To.subVectors(i,n),nc.subVectors(r,n),HN.subVectors(e,n);const s=To.dot(To),l=To.dot(nc),c=To.dot(HN),u=nc.dot(nc),d=nc.dot(HN),f=s*u-l*l;if(f===0)return a.set(0,0,0),null;const g=1/f,p=(u*c-l*d)*g,x=(s*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,rc)===null?!1:rc.x>=0&&rc.y>=0&&rc.x+rc.y<=1}static getInterpolation(e,n,r,i,a,s,l,c){return this.getBarycoord(e,n,r,i,rc)===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,rc.x),c.addScaledVector(s,rc.y),c.addScaledVector(l,rc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,s){return WN.setScalar(0),qN.setScalar(0),KN.setScalar(0),WN.fromBufferAttribute(e,n),qN.fromBufferAttribute(e,r),KN.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(WN,a.x),s.addScaledVector(qN,a.y),s.addScaledVector(KN,a.z),s}static isFrontFacing(e,n,r,i){return To.subVectors(r,n),nc.subVectors(e,n),To.cross(nc).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 To.subVectors(this.c,this.b),nc.subVectors(this.a,this.b),To.cross(nc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Xm.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Xm.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Xm.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Xm.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Xm.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,l;bm.subVectors(i,r),ym.subVectors(a,r),$N.subVectors(e,r);const c=bm.dot($N),u=ym.dot($N);if(c<=0&&u<=0)return n.copy(r);VN.subVectors(e,i);const d=bm.dot(VN),f=ym.dot(VN);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(bm,s);GN.subVectors(e,a);const p=bm.dot(GN),x=ym.dot(GN);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(ym,l);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return AH.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(AH,l);const b=1/(y+v+g);return s=v*b,l=g*b,n.copy(r).addScaledVector(bm,s).addScaledVector(ym,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const kZ={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},Nu={h:0,s:0,l:0},Jv={h:0,s:0,l:0};function XN(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 Mn=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=Zs){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Dn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Dn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Dn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Dn.workingColorSpace){if(e=qCe(e,1),n=yn(n,0,1),r=yn(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=XN(s,a,e+1/3),this.g=XN(s,a,e),this.b=XN(s,a,e-1/3)}return Dn.colorSpaceToWorking(this,i),this}setStyle(e,n=Zs){function r(a){a!==void 0&&parseFloat(a)<1&&Zt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],l=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:Zt("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);Zt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Zs){const r=kZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Zt("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=Rc(e.r),this.g=Rc(e.g),this.b=Rc(e.b),this}copyLinearToSRGB(e){return this.r=fp(e.r),this.g=fp(e.g),this.b=fp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Zs){return Dn.workingToColorSpace(da.copy(this),e),Math.round(yn(da.r*255,0,255))*65536+Math.round(yn(da.g*255,0,255))*256+Math.round(yn(da.b*255,0,255))}getHexString(e=Zs){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Dn.workingColorSpace){Dn.workingToColorSpace(da.copy(this),n);const r=da.r,i=da.g,a=da.b,s=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+s)/2;if(l===s)c=0,u=0;else{const f=s-l;switch(u=d<=.5?f/(s+l):f/(2-s-l),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=Dn.workingColorSpace){return Dn.workingToColorSpace(da.copy(this),n),e.r=da.r,e.g=da.g,e.b=da.b,e}getStyle(e=Zs){Dn.workingToColorSpace(da.copy(this),e);const n=da.r,r=da.g,i=da.b;return e!==Zs?`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(Nu),this.setHSL(Nu.h+e,Nu.s+n,Nu.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(Nu),e.getHSL(Jv);const r=PN(Nu.h,Jv.h,n),i=PN(Nu.s,Jv.s,n),a=PN(Nu.l,Jv.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const da=new Mn;Mn.NAMES=kZ;let lke=0,bg=class extends Sf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:lke++}),this.uuid=ny(),this.name="",this.type="Material",this.blending=hp,this.side=wd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=aP,this.blendDst=sP,this.blendEquation=xh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mn(0,0,0),this.blendAlpha=0,this.depthFunc=Lp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=hH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=um,this.stencilZFail=um,this.stencilZPass=um,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){Zt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Zt(`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!==hp&&(r.blending=this.blending),this.side!==wd&&(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!==aP&&(r.blendSrc=this.blendSrc),this.blendDst!==sP&&(r.blendDst=this.blendDst),this.blendEquation!==xh&&(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!==Lp&&(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!==hH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==um&&(r.stencilFail=this.stencilFail),this.stencilZFail!==um&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==um&&(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 l in a){const c=a[l];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++}},jO=class extends bg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mn(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 Sd,this.combine=wO,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 ai=new it,e_=new dn;let cke=0,co=class{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:cke++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=fH,this.updateRanges=[],this.gpuType=Tc,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++)e_.fromBufferAttribute(this,n),e_.applyMatrix3(e),this.setXY(n,e_.x,e_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.applyMatrix3(e),this.setXYZ(n,ai.x,ai.y,ai.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.applyMatrix4(e),this.setXYZ(n,ai.x,ai.y,ai.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.applyNormalMatrix(e),this.setXYZ(n,ai.x,ai.y,ai.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.transformDirection(e),this.setXYZ(n,ai.x,ai.y,ai.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=Tx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=qa(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Tx(n,this.array)),n}setX(e,n){return this.normalized&&(n=qa(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Tx(n,this.array)),n}setY(e,n){return this.normalized&&(n=qa(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=Tx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=qa(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=Tx(n,this.array)),n}setW(e,n){return this.normalized&&(n=qa(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=qa(n,this.array),r=qa(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=qa(n,this.array),r=qa(r,this.array),i=qa(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=qa(n,this.array),r=qa(r,this.array),i=qa(i,this.array),a=qa(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==fH&&(e.usage=this.usage),e}},PZ=class extends co{constructor(e,n,r){super(new Uint16Array(e),n,r)}},jZ=class extends co{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Bo=class extends co{constructor(e,n,r){super(new Float32Array(e),n,r)}},uke=0;const Vs=new hi,YN=new Rs,vm=new it,bs=new hf,Px=new hf,Ri=new it;let Dl=class RZ extends Sf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:uke++}),this.uuid=ny(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(wZ(e)?jZ:PZ)(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 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 Vs.makeRotationFromQuaternion(e),this.applyMatrix4(Vs),this}rotateX(e){return Vs.makeRotationX(e),this.applyMatrix4(Vs),this}rotateY(e){return Vs.makeRotationY(e),this.applyMatrix4(Vs),this}rotateZ(e){return Vs.makeRotationZ(e),this.applyMatrix4(Vs),this}translate(e,n,r){return Vs.makeTranslation(e,n,r),this.applyMatrix4(Vs),this}scale(e,n,r){return Vs.makeScale(e,n,r),this.applyMatrix4(Vs),this}lookAt(e){return YN.lookAt(e),YN.updateMatrix(),this.applyMatrix4(YN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vm).negate(),this.translate(vm.x,vm.y,vm.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Bo(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&&Zt("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 hf);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 it(-1/0,-1/0,-1/0),new it(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];bs.setFromBufferAttribute(a),this.morphTargetsRelative?(Ri.addVectors(this.boundingBox.min,bs.min),this.boundingBox.expandByPoint(Ri),Ri.addVectors(this.boundingBox.max,bs.max),this.boundingBox.expandByPoint(Ri)):(this.boundingBox.expandByPoint(bs.min),this.boundingBox.expandByPoint(bs.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 ZM);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 it,1/0);return}if(e){const r=this.boundingSphere.center;if(bs.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const l=n[a];Px.setFromBufferAttribute(l),this.morphTargetsRelative?(Ri.addVectors(bs.min,Px.min),bs.expandByPoint(Ri),Ri.addVectors(bs.max,Px.max),bs.expandByPoint(Ri)):(bs.expandByPoint(Px.min),bs.expandByPoint(Px.max))}bs.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Ri.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ri));if(n)for(let a=0,s=n.length;a<s;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Ri.fromBufferAttribute(l,u),c&&(vm.fromBufferAttribute(e,u),Ri.add(vm)),i=Math.max(i,r.distanceToSquared(Ri))}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 co(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),l=[],c=[];for(let F=0;F<r.count;F++)l[F]=new it,c[F]=new it;const u=new it,d=new it,f=new it,g=new dn,p=new dn,x=new dn,v=new it,y=new it;function b(F,k,R){u.fromBufferAttribute(r,F),d.fromBufferAttribute(r,k),f.fromBufferAttribute(r,R),g.fromBufferAttribute(a,F),p.fromBufferAttribute(a,k),x.fromBufferAttribute(a,R),d.sub(u),f.sub(u),p.sub(g),x.sub(g);const I=1/(p.x*x.y-x.x*p.y);isFinite(I)&&(v.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(I),y.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(I),l[F].add(v),l[k].add(v),l[R].add(v),c[F].add(y),c[k].add(y),c[R].add(y))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let F=0,k=E.length;F<k;++F){const R=E[F],I=R.start,L=R.count;for(let q=I,j=I+L;q<j;q+=3)b(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const w=new it,T=new it,A=new it,C=new it;function N(F){A.fromBufferAttribute(i,F),C.copy(A);const k=l[F];w.copy(k),w.sub(A.multiplyScalar(A.dot(k))).normalize(),T.crossVectors(C,k);const I=T.dot(c[F])<0?-1:1;s.setXYZW(F,w.x,w.y,w.z,I)}for(let F=0,k=E.length;F<k;++F){const R=E[F],I=R.start,L=R.count;for(let q=I,j=I+L;q<j;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 co(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new it,a=new it,s=new it,l=new it,c=new it,u=new it,d=new it,f=new it;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),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++)Ri.fromBufferAttribute(e,n),Ri.normalize(),e.setXYZ(n,Ri.x,Ri.y,Ri.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,y=c.length;v<y;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[p++]}return new co(g,d,f)}if(this.index===null)return Zt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new RZ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let l=0,c=s.length;l<c;l++){const u=s[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const 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 l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const NH=new hi,eh=new PO,t_=new ZM,CH=new it,n_=new it,r_=new it,i_=new it,ZN=new it,a_=new it,kH=new it,s_=new it;let Ml=class extends Rs{constructor(e=new Dl,n=new jO){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 l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){a_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(ZN.fromBufferAttribute(f,e),s?a_.addScaledVector(ZN,d):a_.addScaledVector(ZN.sub(n),d))}n.add(a_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),t_.copy(r.boundingSphere),t_.applyMatrix4(a),eh.copy(e.ray).recast(e.near),!(t_.containsPoint(eh.origin)===!1&&(eh.intersectSphere(t_,CH)===null||eh.origin.distanceToSquared(CH)>(e.far-e.near)**2))&&(NH.copy(a).invert(),eh.copy(e.ray).applyMatrix4(NH),!(r.boundingBox!==null&&eh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,eh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(l.count,Math.min(y.start+y.count,p.start+p.count));for(let T=E,A=w;T<A;T+=3){const C=l.getX(T),N=l.getX(T+1),F=l.getX(T+2);i=o_(this,b,e,r,u,d,f,C,N,F),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=l.getX(y),w=l.getX(y+1),T=l.getX(y+2);i=o_(this,s,e,r,u,d,f,E,w,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let T=E,A=w;T<A;T+=3){const C=T,N=T+1,F=T+2;i=o_(this,b,e,r,u,d,f,C,N,F),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=y,w=y+1,T=y+2;i=o_(this,s,e,r,u,d,f,E,w,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}};function dke(t,e,n,r,i,a,s,l){let c;if(e.side===es?c=r.intersectTriangle(s,a,i,!0,l):c=r.intersectTriangle(i,a,s,e.side===wd,l),c===null)return null;s_.copy(l),s_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(s_);return u<n.near||u>n.far?null:{distance:u,point:s_.clone(),object:t}}function o_(t,e,n,r,i,a,s,l,c,u){t.getVertexPosition(l,n_),t.getVertexPosition(c,r_),t.getVertexPosition(u,i_);const d=dke(t,e,n,r,n_,r_,i_,kH);if(d){const f=new it;kx.getBarycoord(kH,n_,r_,i_,f),i&&(d.uv=kx.getInterpolatedAttribute(i,l,c,u,f,new dn)),a&&(d.uv1=kx.getInterpolatedAttribute(a,l,c,u,f,new dn)),s&&(d.normal=kx.getInterpolatedAttribute(s,l,c,u,f,new it),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:l,b:c,c:u,normal:new it,materialIndex:0};kx.getNormal(n_,r_,i_,g.normal),d.face=g,d.barycoord=f}return d}let RO=class DZ extends Dl{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 l=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Bo(u,3)),this.setAttribute("normal",new Bo(d,3)),this.setAttribute("uv",new Bo(f,2));function x(v,y,b,E,w,T,A,C,N,F,k){const R=T/N,I=A/F,L=T/2,q=A/2,j=C/2,V=N+1,K=F+1;let W=0,J=0;const ee=new it;for(let Z=0;Z<K;Z++){const B=Z*I-q;for(let G=0;G<V;G++){const Q=G*R-L;ee[v]=Q*E,ee[y]=B*w,ee[b]=j,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[y]=0,ee[b]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(G/N),f.push(1-Z/F),W+=1}}for(let Z=0;Z<F;Z++)for(let B=0;B<N;B++){const G=g+B+V*Z,Q=g+B+V*(Z+1),te=g+(B+1)+V*(Z+1),he=g+(B+1)+V*Z;c.push(G,Q,he),c.push(Q,te,he),J+=6}l.addGroup(p,J,k),p+=J,g+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new DZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function zp(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?(Zt("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 Aa(t){const e={};for(let n=0;n<t.length;n++){const r=zp(t[n]);for(const i in r)e[i]=r[i]}return e}function hke(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function OZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Dn.workingColorSpace}const fke={clone:zp,merge:Aa};var mke=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,pke=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let qc=class extends bg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=mke,this.fragmentShader=pke,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=zp(e.uniforms),this.uniformsGroups=hke(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}},LZ=class extends Rs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new hi,this.projectionMatrix=new hi,this.projectionMatrixInverse=new hi,this.coordinateSystem=hl,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const Cu=new it,PH=new dn,jH=new dn;let eo=class extends LZ{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=WP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(_1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return WP*2*Math.atan(Math.tan(_1*.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){Cu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Cu.x,Cu.y).multiplyScalar(-e/Cu.z),Cu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Cu.x,Cu.y).multiplyScalar(-e/Cu.z)}getViewSize(e,n){return this.getViewBounds(e,PH,jH),n.subVectors(jH,PH)}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(_1*.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 l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const _m=-90,wm=1;let gke=class extends Rs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new eo(_m,wm,e,n);i.layers=this.layers,this.add(i);const a=new eo(_m,wm,e,n);a.layers=this.layers,this.add(a);const s=new eo(_m,wm,e,n);s.layers=this.layers,this.add(s);const l=new eo(_m,wm,e,n);l.layers=this.layers,this.add(l);const c=new eo(_m,wm,e,n);c.layers=this.layers,this.add(c);const u=new eo(_m,wm,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,l,c]=n;for(const u of n)this.remove(u);if(e===hl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Bw)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),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},IZ=class extends qo{constructor(e=[],n=Ip,r,i,a,s,l,c,u,d){super(e,n,r,i,a,s,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},xke=class extends df{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 IZ(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new RO(5,5,5),a=new qc({name:"CubemapFromEquirect",uniforms:zp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:es,blending:jc});a.uniforms.tEquirect.value=n;const s=new Ml(i,a),l=n.minFilter;return n.minFilter===Ah&&(n.minFilter=so),new gke(1,10,this).update(e,s),n.minFilter=l,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)}},qx=class extends Rs{constructor(){super(),this.isGroup=!0,this.type="Group"}};const bke={type:"move"};let QN=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qx,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 qx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new it,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new it),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new it,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new it),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(bke)))}return l!==null&&(l.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 qx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},yke=class extends Rs{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 Sd,this.environmentIntensity=1,this.environmentRotation=new Sd,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}},vke=class extends qo{constructor(e=null,n=1,r=1,i,a,s,l,c,u=Cs,d=Cs,f,g){super(null,s,l,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const JN=new it,_ke=new it,wke=new fn;let Bu=class{constructor(e=new it(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=JN.subVectors(r,n).cross(_ke.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(JN),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||wke.getNormalMatrix(e),i=this.coplanarPoint(JN).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const th=new ZM,Ske=new dn(.5,.5),l_=new it;let DO=class{constructor(e=new Bu,n=new Bu,r=new Bu,i=new Bu,a=new Bu,s=new Bu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(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=hl,r=!1){const i=this.planes,a=e.elements,s=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],g=a[6],p=a[7],x=a[8],v=a[9],y=a[10],b=a[11],E=a[12],w=a[13],T=a[14],A=a[15];if(i[0].setComponents(u-s,p-d,b-x,A-E).normalize(),i[1].setComponents(u+s,p+d,b+x,A+E).normalize(),i[2].setComponents(u+l,p+f,b+v,A+w).normalize(),i[3].setComponents(u-l,p-f,b-v,A-w).normalize(),r)i[4].setComponents(c,g,y,T).normalize(),i[5].setComponents(u-c,p-g,b-y,A-T).normalize();else if(i[4].setComponents(u-c,p-g,b-y,A-T).normalize(),n===hl)i[5].setComponents(u+c,p+g,b+y,A+T).normalize();else if(n===Bw)i[5].setComponents(c,g,y,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),th.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),th.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(th)}intersectsSprite(e){th.center.set(0,0,0);const n=Ske.distanceTo(e.center);return th.radius=.7071067811865476+n,th.applyMatrix4(e.matrixWorld),this.intersectsSphere(th)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(l_.x=i.normal.x>0?e.max.x:e.min.x,l_.y=i.normal.y>0?e.max.y:e.min.y,l_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(l_)<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)}},FZ=class extends bg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Mn(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 $w=new it,Vw=new it,RH=new hi,jx=new PO,c_=new ZM,eC=new it,DH=new it;let Mke=class extends Rs{constructor(e=new Dl,n=new FZ){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++)$w.fromBufferAttribute(n,i-1),Vw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=$w.distanceTo(Vw);e.setAttribute("lineDistance",new Bo(r,1))}else Zt("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(),c_.copy(r.boundingSphere),c_.applyMatrix4(i),c_.radius+=a,e.ray.intersectsSphere(c_)===!1)return;RH.copy(i).invert(),jx.copy(e.ray).applyMatrix4(RH);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const p=Math.max(0,s.start),x=Math.min(d.count,s.start+s.count);for(let v=p,y=x-1;v<y;v+=u){const b=d.getX(v),E=d.getX(v+1),w=u_(this,e,jx,c,b,E,v);w&&n.push(w)}if(this.isLineLoop){const v=d.getX(x-1),y=d.getX(p),b=u_(this,e,jx,c,v,y,x-1);b&&n.push(b)}}else{const p=Math.max(0,s.start),x=Math.min(g.count,s.start+s.count);for(let v=p,y=x-1;v<y;v+=u){const b=u_(this,e,jx,c,v,v+1,v);b&&n.push(b)}if(this.isLineLoop){const v=u_(this,e,jx,c,x-1,p,x-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function u_(t,e,n,r,i,a,s){const l=t.geometry.attributes.position;if($w.fromBufferAttribute(l,i),Vw.fromBufferAttribute(l,a),n.distanceSqToSegment($w,Vw,eC,DH)>r)return;eC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(eC);if(!(u<e.near||u>e.far))return{distance:u,point:DH.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const OH=new it,LH=new it;let Eke=class extends Mke{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)OH.fromBufferAttribute(n,i),LH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+OH.distanceTo(LH);e.setAttribute("lineDistance",new Bo(r,1))}else Zt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},UZ=class extends qo{constructor(e,n,r=cf,i,a,s,l=Cs,c=Cs,u,d=Q0,f=1){if(d!==Q0&&d!==J0)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,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new kO(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}};class zZ extends qo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let OO=class BZ extends Dl{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,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const E=b*g-s;for(let w=0;w<u;w++){const T=w*f-a;x.push(T,-E,0),v.push(0,0,1),y.push(w/l),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<l;E++){const w=E+u*b,T=E+u*(b+1),A=E+1+u*(b+1),C=E+1+u*b;p.push(w,T,C),p.push(T,A,C)}this.setIndex(p),this.setAttribute("position",new Bo(x,3)),this.setAttribute("normal",new Bo(v,3)),this.setAttribute("uv",new Bo(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new BZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class Tke extends bg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Mn(16777215),this.specular=new Mn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vZ,this.normalScale=new dn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Sd,this.combine=wO,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 Ake=class extends bg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=OCe,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}},Nke=class extends bg{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}},HZ=class extends Rs{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Mn(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 tC=new hi,IH=new it,FH=new it;let Cke=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new dn(512,512),this.mapType=Sl,this.map=null,this.mapPass=null,this.matrix=new hi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new DO,this._frameExtents=new dn(1,1),this._viewportCount=1,this._viewports=[new li(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;IH.setFromMatrixPosition(e.matrixWorld),n.position.copy(IH),FH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(FH),n.updateMatrixWorld(),tC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tC,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(tC)}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}},$Z=class extends LZ{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,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,l,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class kke extends Cke{constructor(){super(new $Z(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class UH extends HZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Rs.DEFAULT_UP),this.updateMatrix(),this.target=new Rs,this.shadow=new kke}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Pke=class extends HZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},jke=class extends eo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},zH=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=yn(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(yn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Rke extends Eke{constructor(e=10,n=10,r=4473924,i=8947848){r=new Mn(r),i=new Mn(i);const a=n/2,s=e/n,l=e/2,c=[],u=[];for(let g=0,p=0,x=-l;g<=n;g++,x+=s){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const v=g===a?r:i;v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3}const d=new Dl;d.setAttribute("position",new Bo(c,3)),d.setAttribute("color",new Bo(u,3));const f=new FZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Dke extends Sf{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){Zt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function BH(t,e,n,r){const i=Oke(r);switch(n){case xZ:return t*e;case yZ:return t*e/i.components*i.byteLength;case TO:return t*e/i.components*i.byteLength;case AO:return t*e*2/i.components*i.byteLength;case NO:return t*e*2/i.components*i.byteLength;case bZ:return t*e*3/i.components*i.byteLength;case Lo:return t*e*4/i.components*i.byteLength;case CO:return t*e*4/i.components*i.byteLength;case x1:case b1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case y1:case v1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case yP:case _P:return Math.max(t,16)*Math.max(e,8)/4;case bP:case vP:return Math.max(t,8)*Math.max(e,8)/2;case wP:case SP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case MP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case EP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case TP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case AP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case NP: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 kP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case PP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case jP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case RP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case DP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case OP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case LP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case IP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case FP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case UP:case zP:case BP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case HP:case $P:return Math.ceil(t/4)*Math.ceil(e/4)*8;case VP:case GP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Oke(t){switch(t){case Sl:case fZ:return{byteLength:1,components:1};case Y0:case mZ:case xg:return{byteLength:2,components:1};case MO:case EO:return{byteLength:2,components:4};case cf:case SO:case Tc:return{byteLength:4,components:1};case pZ:case gZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_O}}));typeof window<"u"&&(window.__THREE__?Zt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_O);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 Lke(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(c,g),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,x)=>p.start-x.start);let g=0;for(let p=1;p<f.length;p++){const x=f[g],v=f[p];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++g,f[g]=v)}f.length=g+1;for(let p=0,x=f.length;p<x;p++){const v=f[p];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function s(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:a,update:s}}var Ike=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Fke=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,Uke=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,zke=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Bke=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,Hke=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,$ke=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,Vke=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Gke=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,Wke=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,qke=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Kke=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,Xke=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,Yke=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,Zke=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,Qke=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,Jke=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,e3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,t3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,n3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,r3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,i3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,a3e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,s3e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,o3e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,l3e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,c3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,u3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,d3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,h3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,f3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",m3e=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,p3e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,g3e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,x3e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,b3e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,y3e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,v3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,_3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,w3e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,S3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,M3e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,E3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,T3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,A3e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,N3e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,C3e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,k3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,P3e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,j3e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,R3e=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,D3e=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,O3e=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,L3e=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,I3e=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,F3e=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,U3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,z3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,B3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,H3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,$3e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,V3e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,G3e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,W3e=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,q3e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,K3e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,X3e=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,Y3e=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,Z3e=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,Q3e=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,J3e=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,ePe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,tPe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,nPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,rPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,iPe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,aPe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,sPe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,oPe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,lPe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,cPe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,uPe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dPe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,hPe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,fPe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,mPe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,pPe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,gPe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,xPe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,bPe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,yPe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,vPe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,_Pe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,wPe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,SPe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,MPe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,EPe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,TPe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,APe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,NPe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,CPe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,kPe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,PPe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,jPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,RPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,DPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,OPe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const LPe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,IPe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,FPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,UPe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,zPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,BPe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,HPe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,$Pe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,VPe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,GPe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,WPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,qPe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,KPe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,XPe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,YPe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,ZPe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,QPe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,JPe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,eje=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,tje=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,nje=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,rje=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,ije=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,aje=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,sje=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,oje=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,lje=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,cje=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,uje=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,dje=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,hje=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,fje=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,mje=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,pje=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,cn={alphahash_fragment:Ike,alphahash_pars_fragment:Fke,alphamap_fragment:Uke,alphamap_pars_fragment:zke,alphatest_fragment:Bke,alphatest_pars_fragment:Hke,aomap_fragment:$ke,aomap_pars_fragment:Vke,batching_pars_vertex:Gke,batching_vertex:Wke,begin_vertex:qke,beginnormal_vertex:Kke,bsdfs:Xke,iridescence_fragment:Yke,bumpmap_pars_fragment:Zke,clipping_planes_fragment:Qke,clipping_planes_pars_fragment:Jke,clipping_planes_pars_vertex:e3e,clipping_planes_vertex:t3e,color_fragment:n3e,color_pars_fragment:r3e,color_pars_vertex:i3e,color_vertex:a3e,common:s3e,cube_uv_reflection_fragment:o3e,defaultnormal_vertex:l3e,displacementmap_pars_vertex:c3e,displacementmap_vertex:u3e,emissivemap_fragment:d3e,emissivemap_pars_fragment:h3e,colorspace_fragment:f3e,colorspace_pars_fragment:m3e,envmap_fragment:p3e,envmap_common_pars_fragment:g3e,envmap_pars_fragment:x3e,envmap_pars_vertex:b3e,envmap_physical_pars_fragment:C3e,envmap_vertex:y3e,fog_vertex:v3e,fog_pars_vertex:_3e,fog_fragment:w3e,fog_pars_fragment:S3e,gradientmap_pars_fragment:M3e,lightmap_pars_fragment:E3e,lights_lambert_fragment:T3e,lights_lambert_pars_fragment:A3e,lights_pars_begin:N3e,lights_toon_fragment:k3e,lights_toon_pars_fragment:P3e,lights_phong_fragment:j3e,lights_phong_pars_fragment:R3e,lights_physical_fragment:D3e,lights_physical_pars_fragment:O3e,lights_fragment_begin:L3e,lights_fragment_maps:I3e,lights_fragment_end:F3e,logdepthbuf_fragment:U3e,logdepthbuf_pars_fragment:z3e,logdepthbuf_pars_vertex:B3e,logdepthbuf_vertex:H3e,map_fragment:$3e,map_pars_fragment:V3e,map_particle_fragment:G3e,map_particle_pars_fragment:W3e,metalnessmap_fragment:q3e,metalnessmap_pars_fragment:K3e,morphinstance_vertex:X3e,morphcolor_vertex:Y3e,morphnormal_vertex:Z3e,morphtarget_pars_vertex:Q3e,morphtarget_vertex:J3e,normal_fragment_begin:ePe,normal_fragment_maps:tPe,normal_pars_fragment:nPe,normal_pars_vertex:rPe,normal_vertex:iPe,normalmap_pars_fragment:aPe,clearcoat_normal_fragment_begin:sPe,clearcoat_normal_fragment_maps:oPe,clearcoat_pars_fragment:lPe,iridescence_pars_fragment:cPe,opaque_fragment:uPe,packing:dPe,premultiplied_alpha_fragment:hPe,project_vertex:fPe,dithering_fragment:mPe,dithering_pars_fragment:pPe,roughnessmap_fragment:gPe,roughnessmap_pars_fragment:xPe,shadowmap_pars_fragment:bPe,shadowmap_pars_vertex:yPe,shadowmap_vertex:vPe,shadowmask_pars_fragment:_Pe,skinbase_vertex:wPe,skinning_pars_vertex:SPe,skinning_vertex:MPe,skinnormal_vertex:EPe,specularmap_fragment:TPe,specularmap_pars_fragment:APe,tonemapping_fragment:NPe,tonemapping_pars_fragment:CPe,transmission_fragment:kPe,transmission_pars_fragment:PPe,uv_pars_fragment:jPe,uv_pars_vertex:RPe,uv_vertex:DPe,worldpos_vertex:OPe,background_vert:LPe,background_frag:IPe,backgroundCube_vert:FPe,backgroundCube_frag:UPe,cube_vert:zPe,cube_frag:BPe,depth_vert:HPe,depth_frag:$Pe,distanceRGBA_vert:VPe,distanceRGBA_frag:GPe,equirect_vert:WPe,equirect_frag:qPe,linedashed_vert:KPe,linedashed_frag:XPe,meshbasic_vert:YPe,meshbasic_frag:ZPe,meshlambert_vert:QPe,meshlambert_frag:JPe,meshmatcap_vert:eje,meshmatcap_frag:tje,meshnormal_vert:nje,meshnormal_frag:rje,meshphong_vert:ije,meshphong_frag:aje,meshphysical_vert:sje,meshphysical_frag:oje,meshtoon_vert:lje,meshtoon_frag:cje,points_vert:uje,points_frag:dje,shadow_vert:hje,shadow_frag:fje,sprite_vert:mje,sprite_frag:pje},Nt={common:{diffuse:{value:new Mn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},envmap:{envMap:{value:null},envMapRotation:{value:new fn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new dn(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 Mn(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 Mn(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 Mn(16777215)},opacity:{value:1},center:{value:new dn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},ol={basic:{uniforms:Aa([Nt.common,Nt.specularmap,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.fog]),vertexShader:cn.meshbasic_vert,fragmentShader:cn.meshbasic_frag},lambert:{uniforms:Aa([Nt.common,Nt.specularmap,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.fog,Nt.lights,{emissive:{value:new Mn(0)}}]),vertexShader:cn.meshlambert_vert,fragmentShader:cn.meshlambert_frag},phong:{uniforms:Aa([Nt.common,Nt.specularmap,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.fog,Nt.lights,{emissive:{value:new Mn(0)},specular:{value:new Mn(1118481)},shininess:{value:30}}]),vertexShader:cn.meshphong_vert,fragmentShader:cn.meshphong_frag},standard:{uniforms:Aa([Nt.common,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.roughnessmap,Nt.metalnessmap,Nt.fog,Nt.lights,{emissive:{value:new Mn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:cn.meshphysical_vert,fragmentShader:cn.meshphysical_frag},toon:{uniforms:Aa([Nt.common,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.gradientmap,Nt.fog,Nt.lights,{emissive:{value:new Mn(0)}}]),vertexShader:cn.meshtoon_vert,fragmentShader:cn.meshtoon_frag},matcap:{uniforms:Aa([Nt.common,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.fog,{matcap:{value:null}}]),vertexShader:cn.meshmatcap_vert,fragmentShader:cn.meshmatcap_frag},points:{uniforms:Aa([Nt.points,Nt.fog]),vertexShader:cn.points_vert,fragmentShader:cn.points_frag},dashed:{uniforms:Aa([Nt.common,Nt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:cn.linedashed_vert,fragmentShader:cn.linedashed_frag},depth:{uniforms:Aa([Nt.common,Nt.displacementmap]),vertexShader:cn.depth_vert,fragmentShader:cn.depth_frag},normal:{uniforms:Aa([Nt.common,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,{opacity:{value:1}}]),vertexShader:cn.meshnormal_vert,fragmentShader:cn.meshnormal_frag},sprite:{uniforms:Aa([Nt.sprite,Nt.fog]),vertexShader:cn.sprite_vert,fragmentShader:cn.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:cn.background_vert,fragmentShader:cn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new fn}},vertexShader:cn.backgroundCube_vert,fragmentShader:cn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:cn.cube_vert,fragmentShader:cn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:cn.equirect_vert,fragmentShader:cn.equirect_frag},distanceRGBA:{uniforms:Aa([Nt.common,Nt.displacementmap,{referencePosition:{value:new it},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:cn.distanceRGBA_vert,fragmentShader:cn.distanceRGBA_frag},shadow:{uniforms:Aa([Nt.lights,Nt.fog,{color:{value:new Mn(0)},opacity:{value:1}}]),vertexShader:cn.shadow_vert,fragmentShader:cn.shadow_frag}};ol.physical={uniforms:Aa([ol.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new dn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new Mn(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 dn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new Mn(0)},specularColor:{value:new Mn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new dn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:cn.meshphysical_vert,fragmentShader:cn.meshphysical_frag};const d_={r:0,b:0,g:0},nh=new Sd,gje=new hi;function xje(t,e,n,r,i,a,s){const l=new Mn(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(w){let T=w.isScene===!0?w.background:null;return T&&T.isTexture&&(T=(w.backgroundBlurriness>0?n:e).get(T)),T}function v(w){let T=!1;const A=x(w);A===null?b(l,c):A&&A.isColor&&(b(A,1),T=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,s):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||T)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function y(w,T){const A=x(T);A&&(A.isCubeTexture||A.mapping===YM)?(d===void 0&&(d=new Ml(new RO(1,1,1),new qc({name:"BackgroundCubeMaterial",uniforms:zp(ol.backgroundCube.uniforms),vertexShader:ol.backgroundCube.vertexShader,fragmentShader:ol.backgroundCube.fragmentShader,side:es,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,N,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),nh.copy(T.backgroundRotation),nh.x*=-1,nh.y*=-1,nh.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(nh.y*=-1,nh.z*=-1),d.material.uniforms.envMap.value=A,d.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(gje.makeRotationFromEuler(nh)),d.material.toneMapped=Dn.getTransfer(A.colorSpace)!==Qn,(f!==A||g!==A.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=A,g=A.version,p=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):A&&A.isTexture&&(u===void 0&&(u=new Ml(new OO(2,2),new qc({name:"BackgroundMaterial",uniforms:zp(ol.background.uniforms),vertexShader:ol.background.vertexShader,fragmentShader:ol.background.fragmentShader,side:wd,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=A,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=Dn.getTransfer(A.colorSpace)!==Qn,A.matrixAutoUpdate===!0&&A.updateMatrix(),u.material.uniforms.uvTransform.value.copy(A.matrix),(f!==A||g!==A.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=A,g=A.version,p=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null))}function b(w,T){w.getRGB(d_,OZ(t)),r.buffers.color.setClear(d_.r,d_.g,d_.b,T,s)}function E(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return l},setClearColor:function(w,T=1){l.set(w),c=T,b(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,b(l,c)},render:v,addToRenderList:y,dispose:E}}function bje(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function l(R,I,L,q,j){let V=!1;const K=f(q,L,I);a!==K&&(a=K,u(a.object)),V=p(R,q,L,j),V&&x(R,q,L,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(V||s)&&(s=!1,T(R,I,L,q),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,I,L){const q=L.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let V=j[I.id];V===void 0&&(V={},j[I.id]=V);let K=V[q];return K===void 0&&(K=g(c()),V[q]=K),K}function g(R){const I=[],L=[],q=[];for(let j=0;j<n;j++)I[j]=0,L[j]=0,q[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:L,attributeDivisors:q,object:R,attributes:{},index:null}}function p(R,I,L,q){const j=a.attributes,V=I.attributes;let K=0;const W=L.getAttributes();for(const J in W)if(W[J].location>=0){const Z=j[J];let B=V[J];if(B===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(B=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(B=R.instanceColor)),Z===void 0||Z.attribute!==B||B&&Z.data!==B.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function x(R,I,L,q){const j={},V=I.attributes;let K=0;const W=L.getAttributes();for(const J in W)if(W[J].location>=0){let Z=V[J];Z===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(Z=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(Z=R.instanceColor));const B={};B.attribute=Z,Z&&Z.data&&(B.data=Z.data),j[J]=B,K++}a.attributes=j,a.attributesNum=K,a.index=q}function v(){const R=a.newAttributes;for(let I=0,L=R.length;I<L;I++)R[I]=0}function y(R){b(R,0)}function b(R,I){const L=a.newAttributes,q=a.enabledAttributes,j=a.attributeDivisors;L[R]=1,q[R]===0&&(t.enableVertexAttribArray(R),q[R]=1),j[R]!==I&&(t.vertexAttribDivisor(R,I),j[R]=I)}function E(){const R=a.newAttributes,I=a.enabledAttributes;for(let L=0,q=I.length;L<q;L++)I[L]!==R[L]&&(t.disableVertexAttribArray(L),I[L]=0)}function w(R,I,L,q,j,V,K){K===!0?t.vertexAttribIPointer(R,I,L,j,V):t.vertexAttribPointer(R,I,L,q,j,V)}function T(R,I,L,q){v();const j=q.attributes,V=L.getAttributes(),K=I.defaultAttributeValues;for(const W in V){const J=V[W];if(J.location>=0){let ee=j[W];if(ee===void 0&&(W==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),W==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor)),ee!==void 0){const Z=ee.normalized,B=ee.itemSize,G=e.get(ee);if(G===void 0)continue;const Q=G.buffer,te=G.type,he=G.bytesPerElement,oe=te===t.INT||te===t.UNSIGNED_INT||ee.gpuType===SO;if(ee.isInterleavedBufferAttribute){const xe=ee.data,Te=xe.stride,me=ee.offset;if(xe.isInstancedInterleavedBuffer){for(let ce=0;ce<J.locationSize;ce++)b(J.location+ce,xe.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let ce=0;ce<J.locationSize;ce++)y(J.location+ce);t.bindBuffer(t.ARRAY_BUFFER,Q);for(let ce=0;ce<J.locationSize;ce++)w(J.location+ce,B/J.locationSize,te,Z,Te*he,(me+B/J.locationSize*ce)*he,oe)}else{if(ee.isInstancedBufferAttribute){for(let xe=0;xe<J.locationSize;xe++)b(J.location+xe,ee.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let xe=0;xe<J.locationSize;xe++)y(J.location+xe);t.bindBuffer(t.ARRAY_BUFFER,Q);for(let xe=0;xe<J.locationSize;xe++)w(J.location+xe,B/J.locationSize,te,Z,B*he,B/J.locationSize*xe*he,oe)}}else if(K!==void 0){const Z=K[W];if(Z!==void 0)switch(Z.length){case 2:t.vertexAttrib2fv(J.location,Z);break;case 3:t.vertexAttrib3fv(J.location,Z);break;case 4:t.vertexAttrib4fv(J.location,Z);break;default:t.vertexAttrib1fv(J.location,Z)}}}}E()}function A(){F();for(const R in r){const I=r[R];for(const L in I){const q=I[L];for(const j in q)d(q[j].object),delete q[j];delete I[L]}delete r[R]}}function C(R){if(r[R.id]===void 0)return;const I=r[R.id];for(const L in I){const q=I[L];for(const j in q)d(q[j].object),delete q[j];delete I[L]}delete r[R.id]}function N(R){for(const I in r){const L=r[I];if(L[R.id]===void 0)continue;const q=L[R.id];for(const j in q)d(q[j].object),delete q[j];delete L[R.id]}}function F(){k(),s=!0,a!==i&&(a=i,u(a.object))}function k(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:F,resetDefaultState:k,dispose:A,releaseStatesOfGeometry:C,releaseStatesOfProgram:N,initAttributes:v,enableAttribute:y,disableUnusedAttributes:E}}function yje(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 l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,g){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)s(u[x],d[x],g[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let v=0;v<f;v++)x+=d[v]*g[v];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function vje(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!==Lo&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(N){const F=N===xg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==Sl&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==Tc&&!F)}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&&(Zt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),A=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:y,maxAttributes:b,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:T,vertexTextures:A,maxSamples:C}}function _je(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Bu,l=new fn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const E=a?0:r,w=E*4;let T=b.clippingState||null;c.value=T,T=d(x,g,w,p);for(let A=0;A!==w;++A)T[A]=n[A];b.clippingState=T,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=p+v*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(y===null||y.length<b)&&(y=new Float32Array(b));for(let w=0,T=p;w!==v;++w,T+=4)s.copy(f[w]).applyMatrix4(E,l),s.normal.toArray(y,T),y[T+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function wje(t){let e=new WeakMap;function n(s,l){return l===mP?s.mapping=Ip:l===pP&&(s.mapping=Fp),s}function r(s){if(s&&s.isTexture){const l=s.mapping;if(l===mP||l===pP)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 xke(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 l=s.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const Qu=4,HH=[.125,.215,.35,.446,.526,.582],bh=20,Sje=256,Rx=new $Z,$H=new Mn;let nC=null,rC=0,iC=0,aC=!1;const Mje=new it;let VH=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:l=Mje}=a;nC=this._renderer.getRenderTarget(),rC=this._renderer.getActiveCubeFace(),iC=this._renderer.getActiveMipmapLevel(),aC=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,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=qH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=WH(),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(nC,rC,iC),this._renderer.xr.enabled=aC,e.scissorTest=!1,Sm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Ip||e.mapping===Fp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),nC=this._renderer.getRenderTarget(),rC=this._renderer.getActiveCubeFace(),iC=this._renderer.getActiveMipmapLevel(),aC=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:so,minFilter:so,generateMipmaps:!1,type:xg,format:Lo,colorSpace:Up,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}=Eje(a)),this._blurMaterial=Aje(a,e,n),this._ggxMaterial=Tje(a,e,n)}return i}_compileMaterial(e){const n=new Ml(new Dl,e);this._renderer.compile(n,Rx)}_sceneToCubeUV(e,n,r,i,a){const c=new eo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,g=f.autoClear,p=f.toneMapping;f.getClearColor($H),f.toneMapping=sd,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ml(new RO,new jO({name:"PMREM.Background",side:es,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,y=v.material;let b=!1;const E=e.background;E?E.isColor&&(y.color.copy(E),e.background=null,b=!0):(y.color.copy($H),b=!0);for(let w=0;w<6;w++){const T=w%3;T===0?(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[w],a.y,a.z)):T===1?(c.up.set(0,0,u[w]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[w],a.z)):(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[w]));const A=this._cubeSize;Sm(i,T*A,w>2?A:0,A,A),f.setRenderTarget(i),b&&f.render(v,c),f.render(e,c)}f.toneMapping=p,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Ip||e.mapping===Fp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=qH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=WH());const a=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Sm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,Rx)}_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,l=this._lodMeshes[r];l.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,p=f*g,{_lodMax:x}=this,v=this._sizeLods[r],y=3*v*(r>x-Qu?r-x+Qu:0),b=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,Sm(a,y,b,3*v,2*v),i.setRenderTarget(a),i.render(l,Rx),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,Sm(e,y,b,3*v,2*v),i.setRenderTarget(e),i.render(l,Rx)}_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,l){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,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*bh-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):bh;y>bh&&Zt(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${bh}`);const b=[];let E=0;for(let N=0;N<bh;++N){const F=N/v,k=Math.exp(-F*F/2);b.push(k),N===0?E+=k:N<y&&(E+=2*k)}for(let N=0;N<b.length;N++)b[N]=b[N]/E;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const T=this._sizeLods[i],A=3*T*(i>w-Qu?i-w+Qu:0),C=4*(this._cubeSize-T);Sm(n,A,C,3*T,2*T),c.setRenderTarget(n),c.render(f,Rx)}};function Eje(t){const e=[],n=[],r=[];let i=t;const a=t-Qu+1+HH.length;for(let s=0;s<a;s++){const l=Math.pow(2,i);e.push(l);let c=1/l;s>t-Qu?c=HH[s-t+Qu-1]:s===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,y=2,b=1,E=new Float32Array(v*x*p),w=new Float32Array(y*x*p),T=new Float32Array(b*x*p);for(let C=0;C<p;C++){const N=C%3*2/3-1,F=C>2?0:-1,k=[N,F,0,N+2/3,F,0,N+2/3,F+1,0,N,F,0,N+2/3,F+1,0,N,F+1,0];E.set(k,v*x*C),w.set(g,y*x*C);const R=[C,C,C,C,C,C];T.set(R,b*x*C)}const A=new Dl;A.setAttribute("position",new co(E,v)),A.setAttribute("uv",new co(w,y)),A.setAttribute("faceIndex",new co(T,b)),r.push(new Ml(A,null)),i>Qu&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function GH(t,e,n){const r=new df(t,e,n);return r.texture.mapping=YM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Sm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Tje(t,e,n){return new qc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Sje,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:QM(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:jc,depthTest:!1,depthWrite:!1})}function Aje(t,e,n){const r=new Float32Array(bh),i=new it(0,1,0);return new qc({name:"SphericalGaussianBlur",defines:{n:bh,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:QM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:jc,depthTest:!1,depthWrite:!1})}function WH(){return new qc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:QM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:jc,depthTest:!1,depthWrite:!1})}function qH(){return new qc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:QM(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:jc,depthTest:!1,depthWrite:!1})}function QM(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function Nje(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===mP||c===pP,d=c===Ip||c===Fp;if(u||d){let f=e.get(l);const g=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==g)return n===null&&(n=new VH(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new VH(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function Cje(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&&eb("WebGLRenderer: "+r+" extension not supported."),i}}}function kje(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 x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",s),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function l(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const p in g)e.update(g[p],t.ARRAY_BUFFER)}function u(f){const g=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const E=p.array;v=p.version;for(let w=0,T=E.length;w<T;w+=3){const A=E[w+0],C=E[w+1],N=E[w+2];g.push(A,C,C,N,N,A)}}else if(x!==void 0){const E=x.array;v=x.version;for(let w=0,T=E.length/3-1;w<T;w+=3){const A=w+0,C=w+1,N=w+2;g.push(A,C,C,N,N,A)}}else return;const y=new(wZ(g)?jZ:PZ)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function Pje(t,e,n){let r;function i(g){r=g}let a,s;function l(g){a=g.type,s=g.bytesPerElement}function c(g,p){t.drawElements(r,p,a,g*s),n.update(p,r,1)}function u(g,p,x){x!==0&&(t.drawElementsInstanced(r,p,a,g*s,x),n.update(p,r,x))}function d(g,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,g,0,x);let y=0;for(let b=0;b<x;b++)y+=p[b];n.update(y,r,1)}function f(g,p,x,v){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<g.length;b++)u(g[b]/s,p[b],v[b]);else{y.multiDrawElementsInstancedWEBGL(r,p,0,a,g,0,v,0,x);let b=0;for(let E=0;E<x;E++)b+=p[E]*v[E];n.update(b,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function jje(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,l){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default: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 Rje(t,e,n){const r=new WeakMap,i=new li;function a(s,l,c){const u=s.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(l);if(g===void 0||g.count!==f){let R=function(){F.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var p=R;g!==void 0&&g.texture.dispose();const x=l.morphAttributes.position!==void 0,v=l.morphAttributes.normal!==void 0,y=l.morphAttributes.color!==void 0,b=l.morphAttributes.position||[],E=l.morphAttributes.normal||[],w=l.morphAttributes.color||[];let T=0;x===!0&&(T=1),v===!0&&(T=2),y===!0&&(T=3);let A=l.attributes.position.count*T,C=1;A>e.maxTextureSize&&(C=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const N=new Float32Array(A*C*4*f),F=new AZ(N,A,C,f);F.type=Tc,F.needsUpdate=!0;const k=T*4;for(let I=0;I<f;I++){const L=b[I],q=E[I],j=w[I],V=A*C*4*I;for(let K=0;K<L.count;K++){const W=K*k;x===!0&&(i.fromBufferAttribute(L,K),N[V+W+0]=i.x,N[V+W+1]=i.y,N[V+W+2]=i.z,N[V+W+3]=0),v===!0&&(i.fromBufferAttribute(q,K),N[V+W+4]=i.x,N[V+W+5]=i.y,N[V+W+6]=i.z,N[V+W+7]=0),y===!0&&(i.fromBufferAttribute(j,K),N[V+W+8]=i.x,N[V+W+9]=i.y,N[V+W+10]=i.z,N[V+W+11]=j.itemSize===4?i.w:1)}}g={count:f,texture:F,size:new dn(A,C)},r.set(l,g),l.addEventListener("dispose",R)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let x=0;for(let y=0;y<u.length;y++)x+=u[y];const v=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),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 Dje(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}const GZ=new qo,KH=new UZ(1,1),WZ=new AZ,qZ=new eke,KZ=new IZ,XH=[],YH=[],ZH=new Float32Array(16),QH=new Float32Array(9),JH=new Float32Array(4);function yg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=XH[i];if(a===void 0&&(a=new Float32Array(i),XH[i]=a),e!==0){r.toArray(a,0);for(let s=1,l=0;s!==e;++s)l+=n,t[s].toArray(a,l)}return a}function vi(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 _i(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function JM(t,e){let n=YH[e];n===void 0&&(n=new Int32Array(e),YH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Oje(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Lje(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(vi(n,e))return;t.uniform2fv(this.addr,e),_i(n,e)}}function Ije(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(vi(n,e))return;t.uniform3fv(this.addr,e),_i(n,e)}}function Fje(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(vi(n,e))return;t.uniform4fv(this.addr,e),_i(n,e)}}function Uje(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(vi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),_i(n,e)}else{if(vi(n,r))return;JH.set(r),t.uniformMatrix2fv(this.addr,!1,JH),_i(n,r)}}function zje(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(vi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),_i(n,e)}else{if(vi(n,r))return;QH.set(r),t.uniformMatrix3fv(this.addr,!1,QH),_i(n,r)}}function Bje(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(vi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),_i(n,e)}else{if(vi(n,r))return;ZH.set(r),t.uniformMatrix4fv(this.addr,!1,ZH),_i(n,r)}}function Hje(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function $je(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(vi(n,e))return;t.uniform2iv(this.addr,e),_i(n,e)}}function Vje(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(vi(n,e))return;t.uniform3iv(this.addr,e),_i(n,e)}}function Gje(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(vi(n,e))return;t.uniform4iv(this.addr,e),_i(n,e)}}function Wje(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function qje(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(vi(n,e))return;t.uniform2uiv(this.addr,e),_i(n,e)}}function Kje(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(vi(n,e))return;t.uniform3uiv(this.addr,e),_i(n,e)}}function Xje(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(vi(n,e))return;t.uniform4uiv(this.addr,e),_i(n,e)}}function Yje(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?(KH.compareFunction=_Z,a=KH):a=GZ,n.setTexture2D(e||a,i)}function Zje(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||qZ,i)}function Qje(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||KZ,i)}function Jje(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 eRe(t){switch(t){case 5126:return Oje;case 35664:return Lje;case 35665:return Ije;case 35666:return Fje;case 35674:return Uje;case 35675:return zje;case 35676:return Bje;case 5124:case 35670:return Hje;case 35667:case 35671:return $je;case 35668:case 35672:return Vje;case 35669:case 35673:return Gje;case 5125:return Wje;case 36294:return qje;case 36295:return Kje;case 36296:return Xje;case 35678:case 36198:case 36298:case 36306:case 35682:return Yje;case 35679:case 36299:case 36307:return Zje;case 35680:case 36300:case 36308:case 36293:return Qje;case 36289:case 36303:case 36311:case 36292:return Jje}}function tRe(t,e){t.uniform1fv(this.addr,e)}function nRe(t,e){const n=yg(e,this.size,2);t.uniform2fv(this.addr,n)}function rRe(t,e){const n=yg(e,this.size,3);t.uniform3fv(this.addr,n)}function iRe(t,e){const n=yg(e,this.size,4);t.uniform4fv(this.addr,n)}function aRe(t,e){const n=yg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function sRe(t,e){const n=yg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function oRe(t,e){const n=yg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function lRe(t,e){t.uniform1iv(this.addr,e)}function cRe(t,e){t.uniform2iv(this.addr,e)}function uRe(t,e){t.uniform3iv(this.addr,e)}function dRe(t,e){t.uniform4iv(this.addr,e)}function hRe(t,e){t.uniform1uiv(this.addr,e)}function fRe(t,e){t.uniform2uiv(this.addr,e)}function mRe(t,e){t.uniform3uiv(this.addr,e)}function pRe(t,e){t.uniform4uiv(this.addr,e)}function gRe(t,e,n){const r=this.cache,i=e.length,a=JM(n,i);vi(r,a)||(t.uniform1iv(this.addr,a),_i(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||GZ,a[s])}function xRe(t,e,n){const r=this.cache,i=e.length,a=JM(n,i);vi(r,a)||(t.uniform1iv(this.addr,a),_i(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||qZ,a[s])}function bRe(t,e,n){const r=this.cache,i=e.length,a=JM(n,i);vi(r,a)||(t.uniform1iv(this.addr,a),_i(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||KZ,a[s])}function yRe(t,e,n){const r=this.cache,i=e.length,a=JM(n,i);vi(r,a)||(t.uniform1iv(this.addr,a),_i(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||WZ,a[s])}function vRe(t){switch(t){case 5126:return tRe;case 35664:return nRe;case 35665:return rRe;case 35666:return iRe;case 35674:return aRe;case 35675:return sRe;case 35676:return oRe;case 5124:case 35670:return lRe;case 35667:case 35671:return cRe;case 35668:case 35672:return uRe;case 35669:case 35673:return dRe;case 5125:return hRe;case 36294:return fRe;case 36295:return mRe;case 36296:return pRe;case 35678:case 36198:case 36298:case 36306:case 35682:return gRe;case 35679:case 36299:case 36307:return xRe;case 35680:case 36300:case 36308:case 36293:return bRe;case 36289:case 36303:case 36311:case 36292:return yRe}}let _Re=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=eRe(n.type)}},wRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=vRe(n.type)}},SRe=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 l=i[a];l.setValue(e,n[l.id],r)}}};const sC=/(\w+)(\])?(\[|\.)?/g;function e$(t,e){t.seq.push(e),t.map[e.id]=e}function MRe(t,e,n){const r=t.name,i=r.length;for(sC.lastIndex=0;;){const a=sC.exec(r),s=sC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&s+2===i){e$(n,u===void 0?new _Re(l,t,e):new wRe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new SRe(l),e$(n,f)),n=f}}}let M1=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);MRe(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 l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}};function t$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const ERe=37297;let TRe=0;function ARe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const l=s+1;r.push(`${l===e?">":" "} ${l}: ${n[s]}`)}return r.join(`
- `)}const n$=new fn;function NRe(t){Dn._getMatrix(n$,Dn.workingColorSpace,t);const e=`mat3( ${n$.elements.map(n=>n.toFixed(4))} )`;switch(Dn.getTransfer(t)){case zw:return[e,"LinearTransferOETF"];case Qn:return[e,"sRGBTransferOETF"];default:return Zt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function r$(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 l=parseInt(s[1]);return n.toUpperCase()+`
- `+a+`
- `+ARe(t.getShaderSource(e),l)}else return a}function CRe(t,e){const n=NRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function kRe(t,e){let n;switch(e){case ACe:n="Linear";break;case NCe:n="Reinhard";break;case CCe:n="Cineon";break;case kCe:n="ACESFilmic";break;case jCe:n="AgX";break;case RCe:n="Neutral";break;case PCe:n="Custom";break;default:Zt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const h_=new it;function PRe(){Dn.getLuminanceCoefficients(h_);const t=h_.x.toFixed(4),e=h_.y.toFixed(4),n=h_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function jRe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Kx).join(`
- `)}function RRe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function DRe(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 l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:l}}return n}function Kx(t){return t!==""}function i$(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 a$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ORe=/^[ \t]*#include +<([\w\d./]+)>/gm;function KP(t){return t.replace(ORe,IRe)}const LRe=new Map;function IRe(t,e){let n=cn[e];if(n===void 0){const r=LRe.get(e);if(r!==void 0)n=cn[r],Zt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return KP(n)}const FRe=/#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 s$(t){return t.replace(FRe,URe)}function URe(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 o$(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function zRe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===dZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===sCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===fc&&(e="SHADOWMAP_TYPE_VSM"),e}function BRe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Ip:case Fp:e="ENVMAP_TYPE_CUBE";break;case YM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function HRe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Fp:e="ENVMAP_MODE_REFRACTION";break}return e}function $Re(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case wO:e="ENVMAP_BLENDING_MULTIPLY";break;case ECe:e="ENVMAP_BLENDING_MIX";break;case TCe:e="ENVMAP_BLENDING_ADD";break}return e}function VRe(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 GRe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,l=n.fragmentShader;const c=zRe(n),u=BRe(n),d=HRe(n),f=$Re(n),g=VRe(n),p=jRe(n),x=RRe(a),v=i.createProgram();let y,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Kx).join(`
- `),y.length>0&&(y+=`
- `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Kx).join(`
- `),b.length>0&&(b+=`
- `)):(y=[o$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Kx).join(`
- `),b=[o$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==sd?"#define TONE_MAPPING":"",n.toneMapping!==sd?cn.tonemapping_pars_fragment:"",n.toneMapping!==sd?kRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",cn.colorspace_pars_fragment,CRe("linearToOutputTexel",n.outputColorSpace),PRe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Kx).join(`
- `)),s=KP(s),s=i$(s,n),s=a$(s,n),l=KP(l),l=i$(l,n),l=a$(l,n),s=s$(s),l=s$(l),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,y=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,b=["#define varying in",n.glslVersion===mH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===mH?"":"#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(`
- `)+`
- `+b);const w=E+y+s,T=E+b+l,A=t$(i,i.VERTEX_SHADER,w),C=t$(i,i.FRAGMENT_SHADER,T);i.attachShader(v,A),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(I){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v)||"",q=i.getShaderInfoLog(A)||"",j=i.getShaderInfoLog(C)||"",V=L.trim(),K=q.trim(),W=j.trim();let J=!0,ee=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(J=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,A,C);else{const Z=r$(i,A,"vertex"),B=r$(i,C,"fragment");Zr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Material Name: `+I.name+`
- Material Type: `+I.type+`
- Program Info Log: `+V+`
- `+Z+`
- `+B)}else V!==""?Zt("WebGLProgram: Program Info Log:",V):(K===""||W==="")&&(ee=!1);ee&&(I.diagnostics={runnable:J,programLog:V,vertexShader:{log:K,prefix:y},fragmentShader:{log:W,prefix:b}})}i.deleteShader(A),i.deleteShader(C),F=new M1(i,v),k=DRe(i,v)}let F;this.getUniforms=function(){return F===void 0&&N(this),F};let k;this.getAttributes=function(){return k===void 0&&N(this),k};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(v,ERe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=TRe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=A,this.fragmentShader=C,this}let WRe=0,qRe=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 KRe(e),n.set(e,r)),r}},KRe=class{constructor(e){this.id=WRe++,this.code=e,this.usedTimes=0}};function XRe(t,e,n,r,i,a,s){const l=new CZ,c=new qRe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(k){return u.add(k),k===0?"uv":`uv${k}`}function y(k,R,I,L,q){const j=L.fog,V=q.geometry,K=k.isMeshStandardMaterial?L.environment:null,W=(k.isMeshStandardMaterial?n:e).get(k.envMap||K),J=W&&W.mapping===YM?W.image.height:null,ee=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&Zt("WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const Z=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,B=Z!==void 0?Z.length:0;let G=0;V.morphAttributes.position!==void 0&&(G=1),V.morphAttributes.normal!==void 0&&(G=2),V.morphAttributes.color!==void 0&&(G=3);let Q,te,he,oe;if(ee){const Dt=ol[ee];Q=Dt.vertexShader,te=Dt.fragmentShader}else Q=k.vertexShader,te=k.fragmentShader,c.update(k),he=c.getVertexShaderID(k),oe=c.getFragmentShaderID(k);const xe=t.getRenderTarget(),Te=t.state.buffers.depth.getReversed(),me=q.isInstancedMesh===!0,ce=q.isBatchedMesh===!0,Ce=!!k.map,fe=!!k.matcap,Ie=!!W,z=!!k.aoMap,H=!!k.lightMap,re=!!k.bumpMap,$=!!k.normalMap,Y=!!k.displacementMap,se=!!k.emissiveMap,ue=!!k.metalnessMap,Ee=!!k.roughnessMap,Me=k.anisotropy>0,U=k.clearcoat>0,O=k.dispersion>0,ne=k.iridescence>0,be=k.sheen>0,ye=k.transmission>0,_e=Me&&!!k.anisotropyMap,We=U&&!!k.clearcoatMap,Ve=U&&!!k.clearcoatNormalMap,Ye=U&&!!k.clearcoatRoughnessMap,lt=ne&&!!k.iridescenceMap,de=ne&&!!k.iridescenceThicknessMap,ae=be&&!!k.sheenColorMap,ze=be&&!!k.sheenRoughnessMap,Ue=!!k.specularMap,et=!!k.specularColorMap,dt=!!k.specularIntensityMap,pe=ye&&!!k.transmissionMap,nt=ye&&!!k.thicknessMap,ve=!!k.gradientMap,He=!!k.alphaMap,je=k.alphaTest>0,we=!!k.alphaHash,Xe=!!k.extensions;let ot=sd;k.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(ot=t.toneMapping);const St={shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:Q,fragmentShader:te,defines:k.defines,customVertexShaderID:he,customFragmentShaderID:oe,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:ce,batchingColor:ce&&q._colorsTexture!==null,instancing:me,instancingColor:me&&q.instanceColor!==null,instancingMorph:me&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Up,alphaToCoverage:!!k.alphaToCoverage,map:Ce,matcap:fe,envMap:Ie,envMapMode:Ie&&W.mapping,envMapCubeUVHeight:J,aoMap:z,lightMap:H,bumpMap:re,normalMap:$,displacementMap:g&&Y,emissiveMap:se,normalMapObjectSpace:$&&k.normalMapType===ICe,normalMapTangentSpace:$&&k.normalMapType===vZ,metalnessMap:ue,roughnessMap:Ee,anisotropy:Me,anisotropyMap:_e,clearcoat:U,clearcoatMap:We,clearcoatNormalMap:Ve,clearcoatRoughnessMap:Ye,dispersion:O,iridescence:ne,iridescenceMap:lt,iridescenceThicknessMap:de,sheen:be,sheenColorMap:ae,sheenRoughnessMap:ze,specularMap:Ue,specularColorMap:et,specularIntensityMap:dt,transmission:ye,transmissionMap:pe,thicknessMap:nt,gradientMap:ve,opaque:k.transparent===!1&&k.blending===hp&&k.alphaToCoverage===!1,alphaMap:He,alphaTest:je,alphaHash:we,combine:k.combine,mapUv:Ce&&v(k.map.channel),aoMapUv:z&&v(k.aoMap.channel),lightMapUv:H&&v(k.lightMap.channel),bumpMapUv:re&&v(k.bumpMap.channel),normalMapUv:$&&v(k.normalMap.channel),displacementMapUv:Y&&v(k.displacementMap.channel),emissiveMapUv:se&&v(k.emissiveMap.channel),metalnessMapUv:ue&&v(k.metalnessMap.channel),roughnessMapUv:Ee&&v(k.roughnessMap.channel),anisotropyMapUv:_e&&v(k.anisotropyMap.channel),clearcoatMapUv:We&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:Ve&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ye&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:lt&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:de&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:ze&&v(k.sheenRoughnessMap.channel),specularMapUv:Ue&&v(k.specularMap.channel),specularColorMapUv:et&&v(k.specularColorMap.channel),specularIntensityMapUv:dt&&v(k.specularIntensityMap.channel),transmissionMapUv:pe&&v(k.transmissionMap.channel),thicknessMapUv:nt&&v(k.thicknessMap.channel),alphaMapUv:He&&v(k.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&($||Me),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!V.attributes.uv&&(Ce||He),fog:!!j,useFog:k.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:k.flatShading===!0&&k.wireframe===!1,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Te,skinning:q.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:G,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&I.length>0,shadowMapType:t.shadowMap.type,toneMapping:ot,decodeVideoTexture:Ce&&k.map.isVideoTexture===!0&&Dn.getTransfer(k.map.colorSpace)===Qn,decodeVideoTextureEmissive:se&&k.emissiveMap.isVideoTexture===!0&&Dn.getTransfer(k.emissiveMap.colorSpace)===Qn,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===ll,flipSided:k.side===es,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Xe&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Xe&&k.extensions.multiDraw===!0||ce)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return St.vertexUv1s=u.has(1),St.vertexUv2s=u.has(2),St.vertexUv3s=u.has(3),u.clear(),St}function b(k){const R=[];if(k.shaderID?R.push(k.shaderID):(R.push(k.customVertexShaderID),R.push(k.customFragmentShaderID)),k.defines!==void 0)for(const I in k.defines)R.push(I),R.push(k.defines[I]);return k.isRawShaderMaterial===!1&&(E(R,k),w(R,k),R.push(t.outputColorSpace)),R.push(k.customProgramCacheKey),R.join()}function E(k,R){k.push(R.precision),k.push(R.outputColorSpace),k.push(R.envMapMode),k.push(R.envMapCubeUVHeight),k.push(R.mapUv),k.push(R.alphaMapUv),k.push(R.lightMapUv),k.push(R.aoMapUv),k.push(R.bumpMapUv),k.push(R.normalMapUv),k.push(R.displacementMapUv),k.push(R.emissiveMapUv),k.push(R.metalnessMapUv),k.push(R.roughnessMapUv),k.push(R.anisotropyMapUv),k.push(R.clearcoatMapUv),k.push(R.clearcoatNormalMapUv),k.push(R.clearcoatRoughnessMapUv),k.push(R.iridescenceMapUv),k.push(R.iridescenceThicknessMapUv),k.push(R.sheenColorMapUv),k.push(R.sheenRoughnessMapUv),k.push(R.specularMapUv),k.push(R.specularColorMapUv),k.push(R.specularIntensityMapUv),k.push(R.transmissionMapUv),k.push(R.thicknessMapUv),k.push(R.combine),k.push(R.fogExp2),k.push(R.sizeAttenuation),k.push(R.morphTargetsCount),k.push(R.morphAttributeCount),k.push(R.numDirLights),k.push(R.numPointLights),k.push(R.numSpotLights),k.push(R.numSpotLightMaps),k.push(R.numHemiLights),k.push(R.numRectAreaLights),k.push(R.numDirLightShadows),k.push(R.numPointLightShadows),k.push(R.numSpotLightShadows),k.push(R.numSpotLightShadowsWithMaps),k.push(R.numLightProbes),k.push(R.shadowMapType),k.push(R.toneMapping),k.push(R.numClippingPlanes),k.push(R.numClipIntersection),k.push(R.depthPacking)}function w(k,R){l.disableAll(),R.supportsVertexTextures&&l.enable(0),R.instancing&&l.enable(1),R.instancingColor&&l.enable(2),R.instancingMorph&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),R.dispersion&&l.enable(20),R.batchingColor&&l.enable(21),R.gradientMap&&l.enable(22),k.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.reversedDepthBuffer&&l.enable(4),R.skinning&&l.enable(5),R.morphTargets&&l.enable(6),R.morphNormals&&l.enable(7),R.morphColors&&l.enable(8),R.premultipliedAlpha&&l.enable(9),R.shadowMapEnabled&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),R.decodeVideoTextureEmissive&&l.enable(20),R.alphaToCoverage&&l.enable(21),k.push(l.mask)}function T(k){const R=x[k.type];let I;if(R){const L=ol[R];I=fke.clone(L.uniforms)}else I=k.uniforms;return I}function A(k,R){let I;for(let L=0,q=d.length;L<q;L++){const j=d[L];if(j.cacheKey===R){I=j,++I.usedTimes;break}}return I===void 0&&(I=new GRe(t,R,k,a),d.push(I)),I}function C(k){if(--k.usedTimes===0){const R=d.indexOf(k);d[R]=d[d.length-1],d.pop(),k.destroy()}}function N(k){c.remove(k)}function F(){c.dispose()}return{getParameters:y,getProgramCacheKey:b,getUniforms:T,acquireProgram:A,releaseProgram:C,releaseShaderCache:N,programs:d,dispose:F}}function YRe(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let l=t.get(s);return l===void 0&&(l={},t.set(s,l)),l}function r(s){t.delete(s)}function i(s,l,c){t.get(s)[l]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function ZRe(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 l$(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 c$(){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,p,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=p,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=v,b.group=y),e++,b}function l(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.push(b):p.transparent===!0?i.push(b):n.push(b)}function c(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.unshift(b):p.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||ZRe),r.length>1&&r.sort(g||l$),i.length>1&&i.sort(g||l$)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function QRe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new c$,t.set(r,[s])):i>=a.length?(s=new c$,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function JRe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new it,color:new Mn};break;case"SpotLight":n={position:new it,direction:new it,color:new Mn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new it,color:new Mn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new it,skyColor:new Mn,groundColor:new Mn};break;case"RectAreaLight":n={color:new Mn,position:new it,halfWidth:new it,halfHeight:new it};break}return t[e.id]=n,n}}}function eDe(){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 dn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new dn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let tDe=0;function nDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function rDe(t){const e=new JRe,n=eDe(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new it);const i=new it,a=new hi,s=new hi;function l(u){let d=0,f=0,g=0;for(let k=0;k<9;k++)r.probe[k].set(0,0,0);let p=0,x=0,v=0,y=0,b=0,E=0,w=0,T=0,A=0,C=0,N=0;u.sort(nDe);for(let k=0,R=u.length;k<R;k++){const I=u[k],L=I.color,q=I.intensity,j=I.distance,V=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=L.r*q,f+=L.g*q,g+=L.b*q;else if(I.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(I.sh.coefficients[K],q);N++}else if(I.isDirectionalLight){const K=e.get(I);if(K.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const W=I.shadow,J=n.get(I);J.shadowIntensity=W.intensity,J.shadowBias=W.bias,J.shadowNormalBias=W.normalBias,J.shadowRadius=W.radius,J.shadowMapSize=W.mapSize,r.directionalShadow[p]=J,r.directionalShadowMap[p]=V,r.directionalShadowMatrix[p]=I.shadow.matrix,E++}r.directional[p]=K,p++}else if(I.isSpotLight){const K=e.get(I);K.position.setFromMatrixPosition(I.matrixWorld),K.color.copy(L).multiplyScalar(q),K.distance=j,K.coneCos=Math.cos(I.angle),K.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),K.decay=I.decay,r.spot[v]=K;const W=I.shadow;if(I.map&&(r.spotLightMap[A]=I.map,A++,W.updateMatrices(I),I.castShadow&&C++),r.spotLightMatrix[v]=W.matrix,I.castShadow){const J=n.get(I);J.shadowIntensity=W.intensity,J.shadowBias=W.bias,J.shadowNormalBias=W.normalBias,J.shadowRadius=W.radius,J.shadowMapSize=W.mapSize,r.spotShadow[v]=J,r.spotShadowMap[v]=V,T++}v++}else if(I.isRectAreaLight){const K=e.get(I);K.color.copy(L).multiplyScalar(q),K.halfWidth.set(I.width*.5,0,0),K.halfHeight.set(0,I.height*.5,0),r.rectArea[y]=K,y++}else if(I.isPointLight){const K=e.get(I);if(K.color.copy(I.color).multiplyScalar(I.intensity),K.distance=I.distance,K.decay=I.decay,I.castShadow){const W=I.shadow,J=n.get(I);J.shadowIntensity=W.intensity,J.shadowBias=W.bias,J.shadowNormalBias=W.normalBias,J.shadowRadius=W.radius,J.shadowMapSize=W.mapSize,J.shadowCameraNear=W.camera.near,J.shadowCameraFar=W.camera.far,r.pointShadow[x]=J,r.pointShadowMap[x]=V,r.pointShadowMatrix[x]=I.shadow.matrix,w++}r.point[x]=K,x++}else if(I.isHemisphereLight){const K=e.get(I);K.skyColor.copy(I.color).multiplyScalar(q),K.groundColor.copy(I.groundColor).multiplyScalar(q),r.hemi[b]=K,b++}}y>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Nt.LTC_FLOAT_1,r.rectAreaLTC2=Nt.LTC_FLOAT_2):(r.rectAreaLTC1=Nt.LTC_HALF_1,r.rectAreaLTC2=Nt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const F=r.hash;(F.directionalLength!==p||F.pointLength!==x||F.spotLength!==v||F.rectAreaLength!==y||F.hemiLength!==b||F.numDirectionalShadows!==E||F.numPointShadows!==w||F.numSpotShadows!==T||F.numSpotMaps!==A||F.numLightProbes!==N)&&(r.directional.length=p,r.spot.length=v,r.rectArea.length=y,r.point.length=x,r.hemi.length=b,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=T+A-C,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=N,F.directionalLength=p,F.pointLength=x,F.spotLength=v,F.rectAreaLength=y,F.hemiLength=b,F.numDirectionalShadows=E,F.numPointShadows=w,F.numSpotShadows=T,F.numSpotMaps=A,F.numLightProbes=N,r.version=tDe++)}function c(u,d){let f=0,g=0,p=0,x=0,v=0;const y=d.matrixWorldInverse;for(let b=0,E=u.length;b<E;b++){const w=u[b];if(w.isDirectionalLight){const T=r.directional[f];T.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(y),f++}else if(w.isSpotLight){const T=r.spot[p];T.position.setFromMatrixPosition(w.matrixWorld),T.position.applyMatrix4(y),T.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(y),p++}else if(w.isRectAreaLight){const T=r.rectArea[x];T.position.setFromMatrixPosition(w.matrixWorld),T.position.applyMatrix4(y),s.identity(),a.copy(w.matrixWorld),a.premultiply(y),s.extractRotation(a),T.halfWidth.set(w.width*.5,0,0),T.halfHeight.set(0,w.height*.5,0),T.halfWidth.applyMatrix4(s),T.halfHeight.applyMatrix4(s),x++}else if(w.isPointLight){const T=r.point[g];T.position.setFromMatrixPosition(w.matrixWorld),T.position.applyMatrix4(y),g++}else if(w.isHemisphereLight){const T=r.hemi[v];T.direction.setFromMatrixPosition(w.matrixWorld),T.direction.transformDirection(y),v++}}}return{setup:l,setupView:c,state:r}}function u$(t){const e=new rDe(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 l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:a,pushShadow:s}}function iDe(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let l;return s===void 0?(l=new u$(t),e.set(i,[l])):a>=s.length?(l=new u$(t),s.push(l)):l=s[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const aDe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,sDe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function oDe(t,e,n){let r=new DO;const i=new dn,a=new dn,s=new li,l=new Ake({depthPacking:LCe}),c=new Nke,u={},d=n.maxTextureSize,f={[wd]:es,[es]:wd,[ll]:ll},g=new qc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new dn},radius:{value:4}},vertexShader:aDe,fragmentShader:sDe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Dl;x.setAttribute("position",new co(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ml(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=dZ;let b=this.type;this.render=function(C,N,F){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||C.length===0)return;const k=t.getRenderTarget(),R=t.getActiveCubeFace(),I=t.getActiveMipmapLevel(),L=t.state;L.setBlending(jc),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const q=b!==fc&&this.type===fc,j=b===fc&&this.type!==fc;for(let V=0,K=C.length;V<K;V++){const W=C[V],J=W.shadow;if(J===void 0){Zt("WebGLShadowMap:",W,"has no shadow.");continue}if(J.autoUpdate===!1&&J.needsUpdate===!1)continue;i.copy(J.mapSize);const ee=J.getFrameExtents();if(i.multiply(ee),a.copy(J.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/ee.x),i.x=a.x*ee.x,J.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/ee.y),i.y=a.y*ee.y,J.mapSize.y=a.y)),J.map===null||q===!0||j===!0){const B=this.type!==fc?{minFilter:Cs,magFilter:Cs}:{};J.map!==null&&J.map.dispose(),J.map=new df(i.x,i.y,B),J.map.texture.name=W.name+".shadowMap",J.camera.updateProjectionMatrix()}t.setRenderTarget(J.map),t.clear();const Z=J.getViewportCount();for(let B=0;B<Z;B++){const G=J.getViewport(B);s.set(a.x*G.x,a.y*G.y,a.x*G.z,a.y*G.w),L.viewport(s),J.updateMatrices(W,B),r=J.getFrustum(),T(N,F,J.camera,W,this.type)}J.isPointLightShadow!==!0&&this.type===fc&&E(J,F),J.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(k,R,I)};function E(C,N){const F=e.update(v);g.defines.VSM_SAMPLES!==C.blurSamples&&(g.defines.VSM_SAMPLES=C.blurSamples,p.defines.VSM_SAMPLES=C.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new df(i.x,i.y)),g.uniforms.shadow_pass.value=C.map.texture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(N,null,F,g,v,null),p.uniforms.shadow_pass.value=C.mapPass.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(N,null,F,p,v,null)}function w(C,N,F,k){let R=null;const I=F.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(I!==void 0)R=I;else if(R=F.isPointLight===!0?c:l,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 L=R.uuid,q=N.uuid;let j=u[L];j===void 0&&(j={},u[L]=j);let V=j[q];V===void 0&&(V=R.clone(),j[q]=V,N.addEventListener("dispose",A)),R=V}if(R.visible=N.visible,R.wireframe=N.wireframe,k===fc?R.side=N.shadowSide!==null?N.shadowSide:N.side:R.side=N.shadowSide!==null?N.shadowSide:f[N.side],R.alphaMap=N.alphaMap,R.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,R.map=N.map,R.clipShadows=N.clipShadows,R.clippingPlanes=N.clippingPlanes,R.clipIntersection=N.clipIntersection,R.displacementMap=N.displacementMap,R.displacementScale=N.displacementScale,R.displacementBias=N.displacementBias,R.wireframeLinewidth=N.wireframeLinewidth,R.linewidth=N.linewidth,F.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const L=t.properties.get(R);L.light=F}return R}function T(C,N,F,k,R){if(C.visible===!1)return;if(C.layers.test(N.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&R===fc)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,C.matrixWorld);const q=e.update(C),j=C.material;if(Array.isArray(j)){const V=q.groups;for(let K=0,W=V.length;K<W;K++){const J=V[K],ee=j[J.materialIndex];if(ee&&ee.visible){const Z=w(C,ee,k,R);C.onBeforeShadow(t,C,N,F,q,Z,J),t.renderBufferDirect(F,null,q,Z,C,J),C.onAfterShadow(t,C,N,F,q,Z,J)}}}else if(j.visible){const V=w(C,j,k,R);C.onBeforeShadow(t,C,N,F,q,V,null),t.renderBufferDirect(F,null,q,V,C,null),C.onAfterShadow(t,C,N,F,q,V,null)}}const L=C.children;for(let q=0,j=L.length;q<j;q++)T(L[q],N,F,k,R)}function A(C){C.target.removeEventListener("dispose",A);for(const F in u){const k=u[F],R=C.target.uuid;R in k&&(k[R].dispose(),delete k[R])}}}const lDe={[oP]:lP,[cP]:hP,[uP]:fP,[Lp]:dP,[lP]:oP,[hP]:cP,[fP]:uP,[dP]:Lp};function cDe(t,e){function n(){let pe=!1;const nt=new li;let ve=null;const He=new li(0,0,0,0);return{setMask:function(je){ve!==je&&!pe&&(t.colorMask(je,je,je,je),ve=je)},setLocked:function(je){pe=je},setClear:function(je,we,Xe,ot,St){St===!0&&(je*=ot,we*=ot,Xe*=ot),nt.set(je,we,Xe,ot),He.equals(nt)===!1&&(t.clearColor(je,we,Xe,ot),He.copy(nt))},reset:function(){pe=!1,ve=null,He.set(-1,0,0,0)}}}function r(){let pe=!1,nt=!1,ve=null,He=null,je=null;return{setReversed:function(we){if(nt!==we){const Xe=e.get("EXT_clip_control");we?Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.ZERO_TO_ONE_EXT):Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.NEGATIVE_ONE_TO_ONE_EXT),nt=we;const ot=je;je=null,this.setClear(ot)}},getReversed:function(){return nt},setTest:function(we){we?xe(t.DEPTH_TEST):Te(t.DEPTH_TEST)},setMask:function(we){ve!==we&&!pe&&(t.depthMask(we),ve=we)},setFunc:function(we){if(nt&&(we=lDe[we]),He!==we){switch(we){case oP:t.depthFunc(t.NEVER);break;case lP:t.depthFunc(t.ALWAYS);break;case cP:t.depthFunc(t.LESS);break;case Lp:t.depthFunc(t.LEQUAL);break;case uP:t.depthFunc(t.EQUAL);break;case dP:t.depthFunc(t.GEQUAL);break;case hP:t.depthFunc(t.GREATER);break;case fP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}He=we}},setLocked:function(we){pe=we},setClear:function(we){je!==we&&(nt&&(we=1-we),t.clearDepth(we),je=we)},reset:function(){pe=!1,ve=null,He=null,je=null,nt=!1}}}function i(){let pe=!1,nt=null,ve=null,He=null,je=null,we=null,Xe=null,ot=null,St=null;return{setTest:function(Dt){pe||(Dt?xe(t.STENCIL_TEST):Te(t.STENCIL_TEST))},setMask:function(Dt){nt!==Dt&&!pe&&(t.stencilMask(Dt),nt=Dt)},setFunc:function(Dt,qt,Ft){(ve!==Dt||He!==qt||je!==Ft)&&(t.stencilFunc(Dt,qt,Ft),ve=Dt,He=qt,je=Ft)},setOp:function(Dt,qt,Ft){(we!==Dt||Xe!==qt||ot!==Ft)&&(t.stencilOp(Dt,qt,Ft),we=Dt,Xe=qt,ot=Ft)},setLocked:function(Dt){pe=Dt},setClear:function(Dt){St!==Dt&&(t.clearStencil(Dt),St=Dt)},reset:function(){pe=!1,nt=null,ve=null,He=null,je=null,we=null,Xe=null,ot=null,St=null}}}const a=new n,s=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,p=[],x=null,v=!1,y=null,b=null,E=null,w=null,T=null,A=null,C=null,N=new Mn(0,0,0),F=0,k=!1,R=null,I=null,L=null,q=null,j=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,W=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?(W=parseFloat(/^WebGL (\d)/.exec(J)[1]),K=W>=1):J.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),K=W>=2);let ee=null,Z={};const B=t.getParameter(t.SCISSOR_BOX),G=t.getParameter(t.VIEWPORT),Q=new li().fromArray(B),te=new li().fromArray(G);function he(pe,nt,ve,He){const je=new Uint8Array(4),we=t.createTexture();t.bindTexture(pe,we),t.texParameteri(pe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(pe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Xe=0;Xe<ve;Xe++)pe===t.TEXTURE_3D||pe===t.TEXTURE_2D_ARRAY?t.texImage3D(nt,0,t.RGBA,1,1,He,0,t.RGBA,t.UNSIGNED_BYTE,je):t.texImage2D(nt+Xe,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,je);return we}const oe={};oe[t.TEXTURE_2D]=he(t.TEXTURE_2D,t.TEXTURE_2D,1),oe[t.TEXTURE_CUBE_MAP]=he(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),oe[t.TEXTURE_2D_ARRAY]=he(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),oe[t.TEXTURE_3D]=he(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),l.setClear(0),xe(t.DEPTH_TEST),s.setFunc(Lp),re(!1),$(lH),xe(t.CULL_FACE),z(jc);function xe(pe){d[pe]!==!0&&(t.enable(pe),d[pe]=!0)}function Te(pe){d[pe]!==!1&&(t.disable(pe),d[pe]=!1)}function me(pe,nt){return f[pe]!==nt?(t.bindFramebuffer(pe,nt),f[pe]=nt,pe===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=nt),pe===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=nt),!0):!1}function ce(pe,nt){let ve=p,He=!1;if(pe){ve=g.get(nt),ve===void 0&&(ve=[],g.set(nt,ve));const je=pe.textures;if(ve.length!==je.length||ve[0]!==t.COLOR_ATTACHMENT0){for(let we=0,Xe=je.length;we<Xe;we++)ve[we]=t.COLOR_ATTACHMENT0+we;ve.length=je.length,He=!0}}else ve[0]!==t.BACK&&(ve[0]=t.BACK,He=!0);He&&t.drawBuffers(ve)}function Ce(pe){return x!==pe?(t.useProgram(pe),x=pe,!0):!1}const fe={[xh]:t.FUNC_ADD,[lCe]:t.FUNC_SUBTRACT,[cCe]:t.FUNC_REVERSE_SUBTRACT};fe[uCe]=t.MIN,fe[dCe]=t.MAX;const Ie={[hCe]:t.ZERO,[fCe]:t.ONE,[mCe]:t.SRC_COLOR,[aP]:t.SRC_ALPHA,[vCe]:t.SRC_ALPHA_SATURATE,[bCe]:t.DST_COLOR,[gCe]:t.DST_ALPHA,[pCe]:t.ONE_MINUS_SRC_COLOR,[sP]:t.ONE_MINUS_SRC_ALPHA,[yCe]:t.ONE_MINUS_DST_COLOR,[xCe]:t.ONE_MINUS_DST_ALPHA,[_Ce]:t.CONSTANT_COLOR,[wCe]:t.ONE_MINUS_CONSTANT_COLOR,[SCe]:t.CONSTANT_ALPHA,[MCe]:t.ONE_MINUS_CONSTANT_ALPHA};function z(pe,nt,ve,He,je,we,Xe,ot,St,Dt){if(pe===jc){v===!0&&(Te(t.BLEND),v=!1);return}if(v===!1&&(xe(t.BLEND),v=!0),pe!==oCe){if(pe!==y||Dt!==k){if((b!==xh||T!==xh)&&(t.blendEquation(t.FUNC_ADD),b=xh,T=xh),Dt)switch(pe){case hp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case cH:t.blendFunc(t.ONE,t.ONE);break;case uH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case dH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Zr("WebGLState: Invalid blending: ",pe);break}else switch(pe){case hp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case cH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case uH:Zr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case dH:Zr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Zr("WebGLState: Invalid blending: ",pe);break}E=null,w=null,A=null,C=null,N.set(0,0,0),F=0,y=pe,k=Dt}return}je=je||nt,we=we||ve,Xe=Xe||He,(nt!==b||je!==T)&&(t.blendEquationSeparate(fe[nt],fe[je]),b=nt,T=je),(ve!==E||He!==w||we!==A||Xe!==C)&&(t.blendFuncSeparate(Ie[ve],Ie[He],Ie[we],Ie[Xe]),E=ve,w=He,A=we,C=Xe),(ot.equals(N)===!1||St!==F)&&(t.blendColor(ot.r,ot.g,ot.b,St),N.copy(ot),F=St),y=pe,k=!1}function H(pe,nt){pe.side===ll?Te(t.CULL_FACE):xe(t.CULL_FACE);let ve=pe.side===es;nt&&(ve=!ve),re(ve),pe.blending===hp&&pe.transparent===!1?z(jc):z(pe.blending,pe.blendEquation,pe.blendSrc,pe.blendDst,pe.blendEquationAlpha,pe.blendSrcAlpha,pe.blendDstAlpha,pe.blendColor,pe.blendAlpha,pe.premultipliedAlpha),s.setFunc(pe.depthFunc),s.setTest(pe.depthTest),s.setMask(pe.depthWrite),a.setMask(pe.colorWrite);const He=pe.stencilWrite;l.setTest(He),He&&(l.setMask(pe.stencilWriteMask),l.setFunc(pe.stencilFunc,pe.stencilRef,pe.stencilFuncMask),l.setOp(pe.stencilFail,pe.stencilZFail,pe.stencilZPass)),se(pe.polygonOffset,pe.polygonOffsetFactor,pe.polygonOffsetUnits),pe.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):Te(t.SAMPLE_ALPHA_TO_COVERAGE)}function re(pe){R!==pe&&(pe?t.frontFace(t.CW):t.frontFace(t.CCW),R=pe)}function $(pe){pe!==iCe?(xe(t.CULL_FACE),pe!==I&&(pe===lH?t.cullFace(t.BACK):pe===aCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Te(t.CULL_FACE),I=pe}function Y(pe){pe!==L&&(K&&t.lineWidth(pe),L=pe)}function se(pe,nt,ve){pe?(xe(t.POLYGON_OFFSET_FILL),(q!==nt||j!==ve)&&(t.polygonOffset(nt,ve),q=nt,j=ve)):Te(t.POLYGON_OFFSET_FILL)}function ue(pe){pe?xe(t.SCISSOR_TEST):Te(t.SCISSOR_TEST)}function Ee(pe){pe===void 0&&(pe=t.TEXTURE0+V-1),ee!==pe&&(t.activeTexture(pe),ee=pe)}function Me(pe,nt,ve){ve===void 0&&(ee===null?ve=t.TEXTURE0+V-1:ve=ee);let He=Z[ve];He===void 0&&(He={type:void 0,texture:void 0},Z[ve]=He),(He.type!==pe||He.texture!==nt)&&(ee!==ve&&(t.activeTexture(ve),ee=ve),t.bindTexture(pe,nt||oe[pe]),He.type=pe,He.texture=nt)}function U(){const pe=Z[ee];pe!==void 0&&pe.type!==void 0&&(t.bindTexture(pe.type,null),pe.type=void 0,pe.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function be(){try{t.texSubImage2D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function ye(){try{t.texSubImage3D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function _e(){try{t.compressedTexSubImage2D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function We(){try{t.compressedTexSubImage3D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function Ve(){try{t.texStorage2D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function Ye(){try{t.texStorage3D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function lt(){try{t.texImage2D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function de(){try{t.texImage3D(...arguments)}catch(pe){pe("WebGLState:",pe)}}function ae(pe){Q.equals(pe)===!1&&(t.scissor(pe.x,pe.y,pe.z,pe.w),Q.copy(pe))}function ze(pe){te.equals(pe)===!1&&(t.viewport(pe.x,pe.y,pe.z,pe.w),te.copy(pe))}function Ue(pe,nt){let ve=u.get(nt);ve===void 0&&(ve=new WeakMap,u.set(nt,ve));let He=ve.get(pe);He===void 0&&(He=t.getUniformBlockIndex(nt,pe.name),ve.set(pe,He))}function et(pe,nt){const He=u.get(nt).get(pe);c.get(nt)!==He&&(t.uniformBlockBinding(nt,He,pe.__bindingPointIndex),c.set(nt,He))}function dt(){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={},ee=null,Z={},f={},g=new WeakMap,p=[],x=null,v=!1,y=null,b=null,E=null,w=null,T=null,A=null,C=null,N=new Mn(0,0,0),F=0,k=!1,R=null,I=null,L=null,q=null,j=null,Q.set(0,0,t.canvas.width,t.canvas.height),te.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),l.reset()}return{buffers:{color:a,depth:s,stencil:l},enable:xe,disable:Te,bindFramebuffer:me,drawBuffers:ce,useProgram:Ce,setBlending:z,setMaterial:H,setFlipSided:re,setCullFace:$,setLineWidth:Y,setPolygonOffset:se,setScissorTest:ue,activeTexture:Ee,bindTexture:Me,unbindTexture:U,compressedTexImage2D:O,compressedTexImage3D:ne,texImage2D:lt,texImage3D:de,updateUBOMapping:Ue,uniformBlockBinding:et,texStorage2D:Ve,texStorage3D:Ye,texSubImage2D:be,texSubImage3D:ye,compressedTexSubImage2D:_e,compressedTexSubImage3D:We,scissor:ae,viewport:ze,reset:dt}}function uDe(t,e,n,r,i,a,s){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new dn,d=new WeakMap;let f;const g=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(U,O){return p?new OffscreenCanvas(U,O):Hw("canvas")}function v(U,O,ne){let be=1;const ye=Me(U);if((ye.width>ne||ye.height>ne)&&(be=ne/Math.max(ye.width,ye.height)),be<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const _e=Math.floor(be*ye.width),We=Math.floor(be*ye.height);f===void 0&&(f=x(_e,We));const Ve=O?x(_e,We):f;return Ve.width=_e,Ve.height=We,Ve.getContext("2d").drawImage(U,0,0,_e,We),Zt("WebGLRenderer: Texture has been resized from ("+ye.width+"x"+ye.height+") to ("+_e+"x"+We+")."),Ve}else return"data"in U&&Zt("WebGLRenderer: Image in DataTexture is too big ("+ye.width+"x"+ye.height+")."),U;return U}function y(U){return U.generateMipmaps}function b(U){t.generateMipmap(U)}function E(U){return U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?t.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(U,O,ne,be,ye=!1){if(U!==null){if(t[U]!==void 0)return t[U];Zt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let _e=O;if(O===t.RED&&(ne===t.FLOAT&&(_e=t.R32F),ne===t.HALF_FLOAT&&(_e=t.R16F),ne===t.UNSIGNED_BYTE&&(_e=t.R8)),O===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(_e=t.R8UI),ne===t.UNSIGNED_SHORT&&(_e=t.R16UI),ne===t.UNSIGNED_INT&&(_e=t.R32UI),ne===t.BYTE&&(_e=t.R8I),ne===t.SHORT&&(_e=t.R16I),ne===t.INT&&(_e=t.R32I)),O===t.RG&&(ne===t.FLOAT&&(_e=t.RG32F),ne===t.HALF_FLOAT&&(_e=t.RG16F),ne===t.UNSIGNED_BYTE&&(_e=t.RG8)),O===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(_e=t.RG8UI),ne===t.UNSIGNED_SHORT&&(_e=t.RG16UI),ne===t.UNSIGNED_INT&&(_e=t.RG32UI),ne===t.BYTE&&(_e=t.RG8I),ne===t.SHORT&&(_e=t.RG16I),ne===t.INT&&(_e=t.RG32I)),O===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(_e=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(_e=t.RGB16UI),ne===t.UNSIGNED_INT&&(_e=t.RGB32UI),ne===t.BYTE&&(_e=t.RGB8I),ne===t.SHORT&&(_e=t.RGB16I),ne===t.INT&&(_e=t.RGB32I)),O===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(_e=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(_e=t.RGBA16UI),ne===t.UNSIGNED_INT&&(_e=t.RGBA32UI),ne===t.BYTE&&(_e=t.RGBA8I),ne===t.SHORT&&(_e=t.RGBA16I),ne===t.INT&&(_e=t.RGBA32I)),O===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(_e=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(_e=t.R11F_G11F_B10F)),O===t.RGBA){const We=ye?zw:Dn.getTransfer(be);ne===t.FLOAT&&(_e=t.RGBA32F),ne===t.HALF_FLOAT&&(_e=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(_e=We===Qn?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(_e=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(_e=t.RGB5_A1)}return(_e===t.R16F||_e===t.R32F||_e===t.RG16F||_e===t.RG32F||_e===t.RGBA16F||_e===t.RGBA32F)&&e.get("EXT_color_buffer_float"),_e}function T(U,O){let ne;return U?O===null||O===cf||O===Z0?ne=t.DEPTH24_STENCIL8:O===Tc?ne=t.DEPTH32F_STENCIL8:O===Y0&&(ne=t.DEPTH24_STENCIL8,Zt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===cf||O===Z0?ne=t.DEPTH_COMPONENT24:O===Tc?ne=t.DEPTH_COMPONENT32F:O===Y0&&(ne=t.DEPTH_COMPONENT16),ne}function A(U,O){return y(U)===!0||U.isFramebufferTexture&&U.minFilter!==Cs&&U.minFilter!==so?Math.log2(Math.max(O.width,O.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?O.mipmaps.length:1}function C(U){const O=U.target;O.removeEventListener("dispose",C),F(O),O.isVideoTexture&&d.delete(O)}function N(U){const O=U.target;O.removeEventListener("dispose",N),R(O)}function F(U){const O=r.get(U);if(O.__webglInit===void 0)return;const ne=U.source,be=g.get(ne);if(be){const ye=be[O.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&k(U),Object.keys(be).length===0&&g.delete(ne)}r.remove(U)}function k(U){const O=r.get(U);t.deleteTexture(O.__webglTexture);const ne=U.source,be=g.get(ne);delete be[O.__cacheKey],s.memory.textures--}function R(U){const O=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(O.__webglFramebuffer[be]))for(let ye=0;ye<O.__webglFramebuffer[be].length;ye++)t.deleteFramebuffer(O.__webglFramebuffer[be][ye]);else t.deleteFramebuffer(O.__webglFramebuffer[be]);O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer[be])}else{if(Array.isArray(O.__webglFramebuffer))for(let be=0;be<O.__webglFramebuffer.length;be++)t.deleteFramebuffer(O.__webglFramebuffer[be]);else t.deleteFramebuffer(O.__webglFramebuffer);if(O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer),O.__webglMultisampledFramebuffer&&t.deleteFramebuffer(O.__webglMultisampledFramebuffer),O.__webglColorRenderbuffer)for(let be=0;be<O.__webglColorRenderbuffer.length;be++)O.__webglColorRenderbuffer[be]&&t.deleteRenderbuffer(O.__webglColorRenderbuffer[be]);O.__webglDepthRenderbuffer&&t.deleteRenderbuffer(O.__webglDepthRenderbuffer)}const ne=U.textures;for(let be=0,ye=ne.length;be<ye;be++){const _e=r.get(ne[be]);_e.__webglTexture&&(t.deleteTexture(_e.__webglTexture),s.memory.textures--),r.remove(ne[be])}r.remove(U)}let I=0;function L(){I=0}function q(){const U=I;return U>=i.maxTextures&&Zt("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),I+=1,U}function j(U){const O=[];return O.push(U.wrapS),O.push(U.wrapT),O.push(U.wrapR||0),O.push(U.magFilter),O.push(U.minFilter),O.push(U.anisotropy),O.push(U.internalFormat),O.push(U.format),O.push(U.type),O.push(U.generateMipmaps),O.push(U.premultiplyAlpha),O.push(U.flipY),O.push(U.unpackAlignment),O.push(U.colorSpace),O.join()}function V(U,O){const ne=r.get(U);if(U.isVideoTexture&&ue(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&ne.__version!==U.version){const be=U.image;if(be===null)Zt("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)Zt("WebGLRenderer: Texture marked for update but image is incomplete");else{oe(ne,U,O);return}}else U.isExternalTexture&&(ne.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+O)}function K(U,O){const ne=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&ne.__version!==U.version){oe(ne,U,O);return}else U.isExternalTexture&&(ne.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+O)}function W(U,O){const ne=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&ne.__version!==U.version){oe(ne,U,O);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+O)}function J(U,O){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){xe(ne,U,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+O)}const ee={[gP]:t.REPEAT,[Ec]:t.CLAMP_TO_EDGE,[xP]:t.MIRRORED_REPEAT},Z={[Cs]:t.NEAREST,[DCe]:t.NEAREST_MIPMAP_NEAREST,[Gv]:t.NEAREST_MIPMAP_LINEAR,[so]:t.LINEAR,[kN]:t.LINEAR_MIPMAP_NEAREST,[Ah]:t.LINEAR_MIPMAP_LINEAR},B={[FCe]:t.NEVER,[VCe]:t.ALWAYS,[UCe]:t.LESS,[_Z]:t.LEQUAL,[zCe]:t.EQUAL,[$Ce]:t.GEQUAL,[BCe]:t.GREATER,[HCe]:t.NOTEQUAL};function G(U,O){if(O.type===Tc&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===so||O.magFilter===kN||O.magFilter===Gv||O.magFilter===Ah||O.minFilter===so||O.minFilter===kN||O.minFilter===Gv||O.minFilter===Ah)&&Zt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(U,t.TEXTURE_WRAP_S,ee[O.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,ee[O.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,ee[O.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,Z[O.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,Z[O.minFilter]),O.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,B[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===Cs||O.minFilter!==Gv&&O.minFilter!==Ah||O.type===Tc&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function Q(U,O){let ne=!1;U.__webglInit===void 0&&(U.__webglInit=!0,O.addEventListener("dispose",C));const be=O.source;let ye=g.get(be);ye===void 0&&(ye={},g.set(be,ye));const _e=j(O);if(_e!==U.__cacheKey){ye[_e]===void 0&&(ye[_e]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),ye[_e].usedTimes++;const We=ye[U.__cacheKey];We!==void 0&&(ye[U.__cacheKey].usedTimes--,We.usedTimes===0&&k(O)),U.__cacheKey=_e,U.__webglTexture=ye[_e].texture}return ne}function te(U,O,ne){return Math.floor(Math.floor(U/ne)/O)}function he(U,O,ne,be){const _e=U.updateRanges;if(_e.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,ne,be,O.data);else{_e.sort((de,ae)=>de.start-ae.start);let We=0;for(let de=1;de<_e.length;de++){const ae=_e[We],ze=_e[de],Ue=ae.start+ae.count,et=te(ze.start,O.width,4),dt=te(ae.start,O.width,4);ze.start<=Ue+1&&et===dt&&te(ze.start+ze.count-1,O.width,4)===et?ae.count=Math.max(ae.count,ze.start+ze.count-ae.start):(++We,_e[We]=ze)}_e.length=We+1;const Ve=t.getParameter(t.UNPACK_ROW_LENGTH),Ye=t.getParameter(t.UNPACK_SKIP_PIXELS),lt=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let de=0,ae=_e.length;de<ae;de++){const ze=_e[de],Ue=Math.floor(ze.start/4),et=Math.ceil(ze.count/4),dt=Ue%O.width,pe=Math.floor(Ue/O.width),nt=et,ve=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,dt),t.pixelStorei(t.UNPACK_SKIP_ROWS,pe),n.texSubImage2D(t.TEXTURE_2D,0,dt,pe,nt,ve,ne,be,O.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ve),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ye),t.pixelStorei(t.UNPACK_SKIP_ROWS,lt)}}function oe(U,O,ne){let be=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(be=t.TEXTURE_3D);const ye=Q(U,O),_e=O.source;n.bindTexture(be,U.__webglTexture,t.TEXTURE0+ne);const We=r.get(_e);if(_e.version!==We.__version||ye===!0){n.activeTexture(t.TEXTURE0+ne);const Ve=Dn.getPrimaries(Dn.workingColorSpace),Ye=O.colorSpace===Ku?null:Dn.getPrimaries(O.colorSpace),lt=O.colorSpace===Ku||Ve===Ye?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,lt);let de=v(O.image,!1,i.maxTextureSize);de=Ee(O,de);const ae=a.convert(O.format,O.colorSpace),ze=a.convert(O.type);let Ue=w(O.internalFormat,ae,ze,O.colorSpace,O.isVideoTexture);G(be,O);let et;const dt=O.mipmaps,pe=O.isVideoTexture!==!0,nt=We.__version===void 0||ye===!0,ve=_e.dataReady,He=A(O,de);if(O.isDepthTexture)Ue=T(O.format===J0,O.type),nt&&(pe?n.texStorage2D(t.TEXTURE_2D,1,Ue,de.width,de.height):n.texImage2D(t.TEXTURE_2D,0,Ue,de.width,de.height,0,ae,ze,null));else if(O.isDataTexture)if(dt.length>0){pe&&nt&&n.texStorage2D(t.TEXTURE_2D,He,Ue,dt[0].width,dt[0].height);for(let je=0,we=dt.length;je<we;je++)et=dt[je],pe?ve&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,et.width,et.height,ae,ze,et.data):n.texImage2D(t.TEXTURE_2D,je,Ue,et.width,et.height,0,ae,ze,et.data);O.generateMipmaps=!1}else pe?(nt&&n.texStorage2D(t.TEXTURE_2D,He,Ue,de.width,de.height),ve&&he(O,de,ae,ze)):n.texImage2D(t.TEXTURE_2D,0,Ue,de.width,de.height,0,ae,ze,de.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){pe&&nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,He,Ue,dt[0].width,dt[0].height,de.depth);for(let je=0,we=dt.length;je<we;je++)if(et=dt[je],O.format!==Lo)if(ae!==null)if(pe){if(ve)if(O.layerUpdates.size>0){const Xe=BH(et.width,et.height,O.format,O.type);for(const ot of O.layerUpdates){const St=et.data.subarray(ot*Xe/et.data.BYTES_PER_ELEMENT,(ot+1)*Xe/et.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,ot,et.width,et.height,1,ae,St)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,et.width,et.height,de.depth,ae,et.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,je,Ue,et.width,et.height,de.depth,0,et.data,0,0);else Zt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else pe?ve&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,et.width,et.height,de.depth,ae,ze,et.data):n.texImage3D(t.TEXTURE_2D_ARRAY,je,Ue,et.width,et.height,de.depth,0,ae,ze,et.data)}else{pe&&nt&&n.texStorage2D(t.TEXTURE_2D,He,Ue,dt[0].width,dt[0].height);for(let je=0,we=dt.length;je<we;je++)et=dt[je],O.format!==Lo?ae!==null?pe?ve&&n.compressedTexSubImage2D(t.TEXTURE_2D,je,0,0,et.width,et.height,ae,et.data):n.compressedTexImage2D(t.TEXTURE_2D,je,Ue,et.width,et.height,0,et.data):Zt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?ve&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,et.width,et.height,ae,ze,et.data):n.texImage2D(t.TEXTURE_2D,je,Ue,et.width,et.height,0,ae,ze,et.data)}else if(O.isDataArrayTexture)if(pe){if(nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,He,Ue,de.width,de.height,de.depth),ve)if(O.layerUpdates.size>0){const je=BH(de.width,de.height,O.format,O.type);for(const we of O.layerUpdates){const Xe=de.data.subarray(we*je/de.data.BYTES_PER_ELEMENT,(we+1)*je/de.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,we,de.width,de.height,1,ae,ze,Xe)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,de.width,de.height,de.depth,ae,ze,de.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ue,de.width,de.height,de.depth,0,ae,ze,de.data);else if(O.isData3DTexture)pe?(nt&&n.texStorage3D(t.TEXTURE_3D,He,Ue,de.width,de.height,de.depth),ve&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,de.width,de.height,de.depth,ae,ze,de.data)):n.texImage3D(t.TEXTURE_3D,0,Ue,de.width,de.height,de.depth,0,ae,ze,de.data);else if(O.isFramebufferTexture){if(nt)if(pe)n.texStorage2D(t.TEXTURE_2D,He,Ue,de.width,de.height);else{let je=de.width,we=de.height;for(let Xe=0;Xe<He;Xe++)n.texImage2D(t.TEXTURE_2D,Xe,Ue,je,we,0,ae,ze,null),je>>=1,we>>=1}}else if(dt.length>0){if(pe&&nt){const je=Me(dt[0]);n.texStorage2D(t.TEXTURE_2D,He,Ue,je.width,je.height)}for(let je=0,we=dt.length;je<we;je++)et=dt[je],pe?ve&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,ae,ze,et):n.texImage2D(t.TEXTURE_2D,je,Ue,ae,ze,et);O.generateMipmaps=!1}else if(pe){if(nt){const je=Me(de);n.texStorage2D(t.TEXTURE_2D,He,Ue,je.width,je.height)}ve&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae,ze,de)}else n.texImage2D(t.TEXTURE_2D,0,Ue,ae,ze,de);y(O)&&b(be),We.__version=_e.version,O.onUpdate&&O.onUpdate(O)}U.__version=O.version}function xe(U,O,ne){if(O.image.length!==6)return;const be=Q(U,O),ye=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+ne);const _e=r.get(ye);if(ye.version!==_e.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const We=Dn.getPrimaries(Dn.workingColorSpace),Ve=O.colorSpace===Ku?null:Dn.getPrimaries(O.colorSpace),Ye=O.colorSpace===Ku||We===Ve?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ye);const lt=O.isCompressedTexture||O.image[0].isCompressedTexture,de=O.image[0]&&O.image[0].isDataTexture,ae=[];for(let we=0;we<6;we++)!lt&&!de?ae[we]=v(O.image[we],!0,i.maxCubemapSize):ae[we]=de?O.image[we].image:O.image[we],ae[we]=Ee(O,ae[we]);const ze=ae[0],Ue=a.convert(O.format,O.colorSpace),et=a.convert(O.type),dt=w(O.internalFormat,Ue,et,O.colorSpace),pe=O.isVideoTexture!==!0,nt=_e.__version===void 0||be===!0,ve=ye.dataReady;let He=A(O,ze);G(t.TEXTURE_CUBE_MAP,O);let je;if(lt){pe&&nt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,He,dt,ze.width,ze.height);for(let we=0;we<6;we++){je=ae[we].mipmaps;for(let Xe=0;Xe<je.length;Xe++){const ot=je[Xe];O.format!==Lo?Ue!==null?pe?ve&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,0,0,ot.width,ot.height,Ue,ot.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,dt,ot.width,ot.height,0,ot.data):Zt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):pe?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,0,0,ot.width,ot.height,Ue,et,ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,dt,ot.width,ot.height,0,Ue,et,ot.data)}}}else{if(je=O.mipmaps,pe&&nt){je.length>0&&He++;const we=Me(ae[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,He,dt,we.width,we.height)}for(let we=0;we<6;we++)if(de){pe?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,ae[we].width,ae[we].height,Ue,et,ae[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,dt,ae[we].width,ae[we].height,0,Ue,et,ae[we].data);for(let Xe=0;Xe<je.length;Xe++){const St=je[Xe].image[we].image;pe?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,0,0,St.width,St.height,Ue,et,St.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,dt,St.width,St.height,0,Ue,et,St.data)}}else{pe?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,Ue,et,ae[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,dt,Ue,et,ae[we]);for(let Xe=0;Xe<je.length;Xe++){const ot=je[Xe];pe?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,0,0,Ue,et,ot.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,dt,Ue,et,ot.image[we])}}}y(O)&&b(t.TEXTURE_CUBE_MAP),_e.__version=ye.version,O.onUpdate&&O.onUpdate(O)}U.__version=O.version}function Te(U,O,ne,be,ye,_e){const We=a.convert(ne.format,ne.colorSpace),Ve=a.convert(ne.type),Ye=w(ne.internalFormat,We,Ve,ne.colorSpace),lt=r.get(O),de=r.get(ne);if(de.__renderTarget=O,!lt.__hasExternalTextures){const ae=Math.max(1,O.width>>_e),ze=Math.max(1,O.height>>_e);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,_e,Ye,ae,ze,O.depth,0,We,Ve,null):n.texImage2D(ye,_e,Ye,ae,ze,0,We,Ve,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),se(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,ye,de.__webglTexture,0,Y(O)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,ye,de.__webglTexture,_e),n.bindFramebuffer(t.FRAMEBUFFER,null)}function me(U,O,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,U),O.depthBuffer){const be=O.depthTexture,ye=be&&be.isDepthTexture?be.type:null,_e=T(O.stencilBuffer,ye),We=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ve=Y(O);se(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,_e,O.width,O.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,_e,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,_e,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,We,t.RENDERBUFFER,U)}else{const be=O.textures;for(let ye=0;ye<be.length;ye++){const _e=be[ye],We=a.convert(_e.format,_e.colorSpace),Ve=a.convert(_e.type),Ye=w(_e.internalFormat,We,Ve,_e.colorSpace),lt=Y(O);ne&&se(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,lt,Ye,O.width,O.height):se(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,lt,Ye,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Ye,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ce(U,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const be=r.get(O.depthTexture);be.__renderTarget=O,(!be.__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),V(O.depthTexture,0);const ye=be.__webglTexture,_e=Y(O);if(O.depthTexture.format===Q0)se(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(O.depthTexture.format===J0)se(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function Ce(U){const O=r.get(U),ne=U.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==U.depthTexture){const be=U.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),be){const ye=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,be.removeEventListener("dispose",ye)};be.addEventListener("dispose",ye),O.__depthDisposeCallback=ye}O.__boundDepthTexture=be}if(U.depthTexture&&!O.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const be=U.texture.mipmaps;be&&be.length>0?ce(O.__webglFramebuffer[0],U):ce(O.__webglFramebuffer,U)}else if(ne){O.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[be]),O.__webglDepthbuffer[be]===void 0)O.__webglDepthbuffer[be]=t.createRenderbuffer(),me(O.__webglDepthbuffer[be],U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,_e=O.__webglDepthbuffer[be];t.bindRenderbuffer(t.RENDERBUFFER,_e),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,_e)}}else{const be=U.texture.mipmaps;if(be&&be.length>0?n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=t.createRenderbuffer(),me(O.__webglDepthbuffer,U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,_e=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,_e),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,_e)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(U,O,ne){const be=r.get(U);O!==void 0&&Te(be.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&Ce(U)}function Ie(U){const O=U.texture,ne=r.get(U),be=r.get(O);U.addEventListener("dispose",N);const ye=U.textures,_e=U.isWebGLCubeRenderTarget===!0,We=ye.length>1;if(We||(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=O.version,s.memory.textures++),_e){ne.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)if(O.mipmaps&&O.mipmaps.length>0){ne.__webglFramebuffer[Ve]=[];for(let Ye=0;Ye<O.mipmaps.length;Ye++)ne.__webglFramebuffer[Ve][Ye]=t.createFramebuffer()}else ne.__webglFramebuffer[Ve]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ve=0;Ve<O.mipmaps.length;Ve++)ne.__webglFramebuffer[Ve]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(We)for(let Ve=0,Ye=ye.length;Ve<Ye;Ve++){const lt=r.get(ye[Ve]);lt.__webglTexture===void 0&&(lt.__webglTexture=t.createTexture(),s.memory.textures++)}if(U.samples>0&&se(U)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Ve=0;Ve<ye.length;Ve++){const Ye=ye[Ve];ne.__webglColorRenderbuffer[Ve]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ve]);const lt=a.convert(Ye.format,Ye.colorSpace),de=a.convert(Ye.type),ae=w(Ye.internalFormat,lt,de,Ye.colorSpace,U.isXRRenderTarget===!0),ze=Y(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,ze,ae,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ve])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),me(ne.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),G(t.TEXTURE_CUBE_MAP,O);for(let Ve=0;Ve<6;Ve++)if(O.mipmaps&&O.mipmaps.length>0)for(let Ye=0;Ye<O.mipmaps.length;Ye++)Te(ne.__webglFramebuffer[Ve][Ye],U,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,Ye);else Te(ne.__webglFramebuffer[Ve],U,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0);y(O)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(We){for(let Ve=0,Ye=ye.length;Ve<Ye;Ve++){const lt=ye[Ve],de=r.get(lt);let ae=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ae=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ae,de.__webglTexture),G(ae,lt),Te(ne.__webglFramebuffer,U,lt,t.COLOR_ATTACHMENT0+Ve,ae,0),y(lt)&&b(ae)}n.unbindTexture()}else{let Ve=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ve=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ve,be.__webglTexture),G(Ve,O),O.mipmaps&&O.mipmaps.length>0)for(let Ye=0;Ye<O.mipmaps.length;Ye++)Te(ne.__webglFramebuffer[Ye],U,O,t.COLOR_ATTACHMENT0,Ve,Ye);else Te(ne.__webglFramebuffer,U,O,t.COLOR_ATTACHMENT0,Ve,0);y(O)&&b(Ve),n.unbindTexture()}U.depthBuffer&&Ce(U)}function z(U){const O=U.textures;for(let ne=0,be=O.length;ne<be;ne++){const ye=O[ne];if(y(ye)){const _e=E(U),We=r.get(ye).__webglTexture;n.bindTexture(_e,We),b(_e),n.unbindTexture()}}}const H=[],re=[];function $(U){if(U.samples>0){if(se(U)===!1){const O=U.textures,ne=U.width,be=U.height;let ye=t.COLOR_BUFFER_BIT;const _e=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,We=r.get(U),Ve=O.length>1;if(Ve)for(let lt=0;lt<O.length;lt++)n.bindFramebuffer(t.FRAMEBUFFER,We.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,We.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,We.__webglMultisampledFramebuffer);const Ye=U.texture.mipmaps;Ye&&Ye.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,We.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,We.__webglFramebuffer);for(let lt=0;lt<O.length;lt++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Ve){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,We.__webglColorRenderbuffer[lt]);const de=r.get(O[lt]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,de,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,ye,t.NEAREST),c===!0&&(H.length=0,re.length=0,H.push(t.COLOR_ATTACHMENT0+lt),U.depthBuffer&&U.resolveDepthBuffer===!1&&(H.push(_e),re.push(_e),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,re)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ve)for(let lt=0;lt<O.length;lt++){n.bindFramebuffer(t.FRAMEBUFFER,We.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,We.__webglColorRenderbuffer[lt]);const de=r.get(O[lt]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,We.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,de,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,We.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&c){const O=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[O])}}}function Y(U){return Math.min(i.maxSamples,U.samples)}function se(U){const O=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ue(U){const O=s.render.frame;d.get(U)!==O&&(d.set(U,O),U.update())}function Ee(U,O){const ne=U.colorSpace,be=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||ne!==Up&&ne!==Ku&&(Dn.getTransfer(ne)===Qn?(be!==Lo||ye!==Sl)&&Zt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Zr("WebGLTextures: Unsupported texture color space:",ne)),O}function Me(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(u.width=U.naturalWidth||U.width,u.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(u.width=U.displayWidth,u.height=U.displayHeight):(u.width=U.width,u.height=U.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=L,this.setTexture2D=V,this.setTexture2DArray=K,this.setTexture3D=W,this.setTextureCube=J,this.rebindTextures=fe,this.setupRenderTarget=Ie,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=$,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=Te,this.useMultisampledRTT=se}function dDe(t,e){function n(r,i=Ku){let a;const s=Dn.getTransfer(i);if(r===Sl)return t.UNSIGNED_BYTE;if(r===MO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===EO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===pZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===gZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===fZ)return t.BYTE;if(r===mZ)return t.SHORT;if(r===Y0)return t.UNSIGNED_SHORT;if(r===SO)return t.INT;if(r===cf)return t.UNSIGNED_INT;if(r===Tc)return t.FLOAT;if(r===xg)return t.HALF_FLOAT;if(r===xZ)return t.ALPHA;if(r===bZ)return t.RGB;if(r===Lo)return t.RGBA;if(r===Q0)return t.DEPTH_COMPONENT;if(r===J0)return t.DEPTH_STENCIL;if(r===yZ)return t.RED;if(r===TO)return t.RED_INTEGER;if(r===AO)return t.RG;if(r===NO)return t.RG_INTEGER;if(r===CO)return t.RGBA_INTEGER;if(r===x1||r===b1||r===y1||r===v1)if(s===Qn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===x1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===b1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===y1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===v1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===x1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===b1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===y1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===v1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===bP||r===yP||r===vP||r===_P)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===bP)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===yP)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===vP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===_P)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===wP||r===SP||r===MP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===wP||r===SP)return s===Qn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===MP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===EP||r===TP||r===AP||r===NP||r===CP||r===kP||r===PP||r===jP||r===RP||r===DP||r===OP||r===LP||r===IP||r===FP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===EP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===TP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===AP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===NP)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===kP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===PP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===jP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===RP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===DP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===OP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===LP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===IP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===FP)return s===Qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===UP||r===zP||r===BP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===UP)return s===Qn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===zP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===BP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===HP||r===$P||r===VP||r===GP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===HP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===$P)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===VP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===GP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Z0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const hDe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,fDe=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class mDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new zZ(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,r=new qc({vertexShader:hDe,fragmentShader:fDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Ml(new OO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let pDe=class extends Sf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const v=typeof XRWebGLBinding<"u",y=new mDe,b={},E=n.getContextAttributes();let w=null,T=null;const A=[],C=[],N=new dn;let F=null;const k=new eo;k.viewport=new li;const R=new eo;R.viewport=new li;const I=[k,R],L=new jke;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(oe){let xe=A[oe];return xe===void 0&&(xe=new QN,A[oe]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(oe){let xe=A[oe];return xe===void 0&&(xe=new QN,A[oe]=xe),xe.getGripSpace()},this.getHand=function(oe){let xe=A[oe];return xe===void 0&&(xe=new QN,A[oe]=xe),xe.getHandSpace()};function V(oe){const xe=C.indexOf(oe.inputSource);if(xe===-1)return;const Te=A[xe];Te!==void 0&&(Te.update(oe.inputSource,oe.frame,u||s),Te.dispatchEvent({type:oe.type,data:oe.inputSource}))}function K(){i.removeEventListener("select",V),i.removeEventListener("selectstart",V),i.removeEventListener("selectend",V),i.removeEventListener("squeeze",V),i.removeEventListener("squeezestart",V),i.removeEventListener("squeezeend",V),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",W);for(let oe=0;oe<A.length;oe++){const xe=C[oe];xe!==null&&(C[oe]=null,A[oe].disconnect(xe))}q=null,j=null,y.reset();for(const oe in b)delete b[oe];e.setRenderTarget(w),p=null,g=null,f=null,i=null,T=null,he.stop(),r.isPresenting=!1,e.setPixelRatio(F),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(oe){a=oe,r.isPresenting===!0&&Zt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(oe){l=oe,r.isPresenting===!0&&Zt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(oe){u=oe},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(oe){if(i=oe,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",V),i.addEventListener("selectstart",V),i.addEventListener("selectend",V),i.addEventListener("squeeze",V),i.addEventListener("squeezestart",V),i.addEventListener("squeezeend",V),i.addEventListener("end",K),i.addEventListener("inputsourceschange",W),E.xrCompatible!==!0&&await n.makeXRCompatible(),F=e.getPixelRatio(),e.getSize(N),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Te=null,me=null,ce=null;E.depth&&(ce=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Te=E.stencil?J0:Q0,me=E.stencil?Z0:cf);const Ce={colorFormat:n.RGBA8,depthFormat:ce,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(Ce),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),T=new df(g.textureWidth,g.textureHeight,{format:Lo,type:Sl,depthTexture:new UZ(g.textureWidth,g.textureHeight,me,void 0,void 0,void 0,void 0,void 0,void 0,Te),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Te={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Te),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),T=new df(p.framebufferWidth,p.framebufferHeight,{format:Lo,type:Sl,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(l),he.setContext(i),he.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function W(oe){for(let xe=0;xe<oe.removed.length;xe++){const Te=oe.removed[xe],me=C.indexOf(Te);me>=0&&(C[me]=null,A[me].disconnect(Te))}for(let xe=0;xe<oe.added.length;xe++){const Te=oe.added[xe];let me=C.indexOf(Te);if(me===-1){for(let Ce=0;Ce<A.length;Ce++)if(Ce>=C.length){C.push(Te),me=Ce;break}else if(C[Ce]===null){C[Ce]=Te,me=Ce;break}if(me===-1)break}const ce=A[me];ce&&ce.connect(Te)}}const J=new it,ee=new it;function Z(oe,xe,Te){J.setFromMatrixPosition(xe.matrixWorld),ee.setFromMatrixPosition(Te.matrixWorld);const me=J.distanceTo(ee),ce=xe.projectionMatrix.elements,Ce=Te.projectionMatrix.elements,fe=ce[14]/(ce[10]-1),Ie=ce[14]/(ce[10]+1),z=(ce[9]+1)/ce[5],H=(ce[9]-1)/ce[5],re=(ce[8]-1)/ce[0],$=(Ce[8]+1)/Ce[0],Y=fe*re,se=fe*$,ue=me/(-re+$),Ee=ue*-re;if(xe.matrixWorld.decompose(oe.position,oe.quaternion,oe.scale),oe.translateX(Ee),oe.translateZ(ue),oe.matrixWorld.compose(oe.position,oe.quaternion,oe.scale),oe.matrixWorldInverse.copy(oe.matrixWorld).invert(),ce[10]===-1)oe.projectionMatrix.copy(xe.projectionMatrix),oe.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const Me=fe+ue,U=Ie+ue,O=Y-Ee,ne=se+(me-Ee),be=z*Ie/U*Me,ye=H*Ie/U*Me;oe.projectionMatrix.makePerspective(O,ne,be,ye,Me,U),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert()}}function B(oe,xe){xe===null?oe.matrixWorld.copy(oe.matrix):oe.matrixWorld.multiplyMatrices(xe.matrixWorld,oe.matrix),oe.matrixWorldInverse.copy(oe.matrixWorld).invert()}this.updateCamera=function(oe){if(i===null)return;let xe=oe.near,Te=oe.far;y.texture!==null&&(y.depthNear>0&&(xe=y.depthNear),y.depthFar>0&&(Te=y.depthFar)),L.near=R.near=k.near=xe,L.far=R.far=k.far=Te,(q!==L.near||j!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),q=L.near,j=L.far),L.layers.mask=oe.layers.mask|6,k.layers.mask=L.layers.mask&3,R.layers.mask=L.layers.mask&5;const me=oe.parent,ce=L.cameras;B(L,me);for(let Ce=0;Ce<ce.length;Ce++)B(ce[Ce],me);ce.length===2?Z(L,k,R):L.projectionMatrix.copy(k.projectionMatrix),G(oe,L,me)};function G(oe,xe,Te){Te===null?oe.matrix.copy(xe.matrixWorld):(oe.matrix.copy(Te.matrixWorld),oe.matrix.invert(),oe.matrix.multiply(xe.matrixWorld)),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.updateMatrixWorld(!0),oe.projectionMatrix.copy(xe.projectionMatrix),oe.projectionMatrixInverse.copy(xe.projectionMatrixInverse),oe.isPerspectiveCamera&&(oe.fov=WP*2*Math.atan(1/oe.projectionMatrix.elements[5]),oe.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(oe){c=oe,g!==null&&(g.fixedFoveation=oe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=oe)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(L)},this.getCameraTexture=function(oe){return b[oe]};let Q=null;function te(oe,xe){if(d=xe.getViewerPose(u||s),x=xe,d!==null){const Te=d.views;p!==null&&(e.setRenderTargetFramebuffer(T,p.framebuffer),e.setRenderTarget(T));let me=!1;Te.length!==L.cameras.length&&(L.cameras.length=0,me=!0);for(let Ie=0;Ie<Te.length;Ie++){const z=Te[Ie];let H=null;if(p!==null)H=p.getViewport(z);else{const $=f.getViewSubImage(g,z);H=$.viewport,Ie===0&&(e.setRenderTargetTextures(T,$.colorTexture,$.depthStencilTexture),e.setRenderTarget(T))}let re=I[Ie];re===void 0&&(re=new eo,re.layers.enable(Ie),re.viewport=new li,I[Ie]=re),re.matrix.fromArray(z.transform.matrix),re.matrix.decompose(re.position,re.quaternion,re.scale),re.projectionMatrix.fromArray(z.projectionMatrix),re.projectionMatrixInverse.copy(re.projectionMatrix).invert(),re.viewport.set(H.x,H.y,H.width,H.height),Ie===0&&(L.matrix.copy(re.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),me===!0&&L.cameras.push(re)}const ce=i.enabledFeatures;if(ce&&ce.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const Ie=f.getDepthInformation(Te[0]);Ie&&Ie.isValid&&Ie.texture&&y.init(Ie,i.renderState)}if(ce&&ce.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let Ie=0;Ie<Te.length;Ie++){const z=Te[Ie].camera;if(z){let H=b[z];H||(H=new zZ,b[z]=H);const re=f.getCameraImage(z);H.sourceTexture=re}}}}for(let Te=0;Te<A.length;Te++){const me=C[Te],ce=A[Te];me!==null&&ce!==void 0&&ce.update(me,xe,u||s)}Q&&Q(oe,xe),xe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:xe}),x=null}const he=new VZ;he.setAnimationLoop(te),this.setAnimationLoop=function(oe){Q=oe},this.dispose=function(){}}};const rh=new Sd,gDe=new hi;function xDe(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,OZ(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,E,w,T){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&p(y,b,T)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&l(y,b)):b.isPointsMaterial?c(y,b,E,w):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===es&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===es&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const E=e.get(b),w=E.envMap,T=E.envMapRotation;w&&(y.envMap.value=w,rh.copy(T),rh.x*=-1,rh.y*=-1,rh.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(rh.y*=-1,rh.z*=-1),y.envMapRotation.value.setFromMatrix4(gDe.makeRotationFromEuler(rh)),y.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap&&(y.lightMap.value=b.lightMap,y.lightMapIntensity.value=b.lightMapIntensity,n(b.lightMap,y.lightMapTransform)),b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function l(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,E,w){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*E,y.scale.value=w*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),b.envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function p(y,b,E){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===es&&y.clearcoatNormalScale.value.negate())),b.dispersion>0&&(y.dispersion.value=b.dispersion),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=E.texture,y.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const E=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(E.matrixWorld),y.nearDistance.value=E.shadow.camera.near,y.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function bDe(t,e,n,r){let i={},a={},s=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(E,w){const T=w.program;r.uniformBlockBinding(E,T)}function u(E,w){let T=i[E.id];T===void 0&&(x(E),T=d(E),i[E.id]=T,E.addEventListener("dispose",y));const A=w.program;r.updateUBOMapping(E,A);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const T=t.createBuffer(),A=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,A,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,T),T}function f(){for(let E=0;E<l;E++)if(s.indexOf(E)===-1)return s.push(E),E;return Zr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],T=E.uniforms,A=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,N=T.length;C<N;C++){const F=Array.isArray(T[C])?T[C]:[T[C]];for(let k=0,R=F.length;k<R;k++){const I=F[k];if(p(I,C,k,A)===!0){const L=I.__offset,q=Array.isArray(I.value)?I.value:[I.value];let j=0;for(let V=0;V<q.length;V++){const K=q[V],W=v(K);typeof K=="number"||typeof K=="boolean"?(I.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,L+j,I.__data)):K.isMatrix3?(I.__data[0]=K.elements[0],I.__data[1]=K.elements[1],I.__data[2]=K.elements[2],I.__data[3]=0,I.__data[4]=K.elements[3],I.__data[5]=K.elements[4],I.__data[6]=K.elements[5],I.__data[7]=0,I.__data[8]=K.elements[6],I.__data[9]=K.elements[7],I.__data[10]=K.elements[8],I.__data[11]=0):(K.toArray(I.__data,j),j+=W.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,I.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,T,A){const C=E.value,N=w+"_"+T;if(A[N]===void 0)return typeof C=="number"||typeof C=="boolean"?A[N]=C:A[N]=C.clone(),!0;{const F=A[N];if(typeof C=="number"||typeof C=="boolean"){if(F!==C)return A[N]=C,!0}else if(F.equals(C)===!1)return F.copy(C),!0}return!1}function x(E){const w=E.uniforms;let T=0;const A=16;for(let N=0,F=w.length;N<F;N++){const k=Array.isArray(w[N])?w[N]:[w[N]];for(let R=0,I=k.length;R<I;R++){const L=k[R],q=Array.isArray(L.value)?L.value:[L.value];for(let j=0,V=q.length;j<V;j++){const K=q[j],W=v(K),J=T%A,ee=J%W.boundary,Z=J+ee;T+=ee,Z!==0&&A-Z<W.storage&&(T+=A-Z),L.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=T,T+=W.storage}}}const C=T%A;return C>0&&(T+=A-C),E.__size=T,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?Zt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Zt("WebGLRenderer: Unsupported uniform value type.",E),w}function y(E){const w=E.target;w.removeEventListener("dispose",y);const T=s.indexOf(w.__bindingPointIndex);s.splice(T,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}const yDe=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 ic=null;function vDe(){return ic===null&&(ic=new vke(yDe,32,32,AO,xg),ic.minFilter=so,ic.magFilter=so,ic.wrapS=Ec,ic.wrapT=Ec,ic.generateMipmaps=!1,ic.needsUpdate=!0),ic}let _De=class{constructor(e={}){const{canvas:n=GCe(),context:r=null,depth:i=!0,stencil:a=!1,alpha:s=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=s;const x=new Set([CO,NO,TO]),v=new Set([Sl,cf,Y0,Z0,MO,EO]),y=new Uint32Array(4),b=new Int32Array(4);let E=null,w=null;const T=[],A=[];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=sd,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let N=!1;this._outputColorSpace=Zs;let F=0,k=0,R=null,I=-1,L=null;const q=new li,j=new li;let V=null;const K=new Mn(0);let W=0,J=n.width,ee=n.height,Z=1,B=null,G=null;const Q=new li(0,0,J,ee),te=new li(0,0,J,ee);let he=!1;const oe=new DO;let xe=!1,Te=!1;const me=new hi,ce=new it,Ce=new li,fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ie=!1;function z(){return R===null?Z:1}let H=r;function re(ie,Ae){return n.getContext(ie,Ae)}try{const ie={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${_O}`),n.addEventListener("webglcontextlost",je,!1),n.addEventListener("webglcontextrestored",we,!1),n.addEventListener("webglcontextcreationerror",Xe,!1),H===null){const Ae="webgl2";if(H=re(Ae,ie),H===null)throw re(Ae)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ie){throw ie("WebGLRenderer: "+ie.message),ie}let $,Y,se,ue,Ee,Me,U,O,ne,be,ye,_e,We,Ve,Ye,lt,de,ae,ze,Ue,et,dt,pe,nt;function ve(){$=new Cje(H),$.init(),dt=new dDe(H,$),Y=new vje(H,$,e,dt),se=new cDe(H,$),Y.reversedDepthBuffer&&g&&se.buffers.depth.setReversed(!0),ue=new jje(H),Ee=new YRe,Me=new uDe(H,$,se,Ee,Y,dt,ue),U=new wje(C),O=new Nje(C),ne=new Lke(H),pe=new bje(H,ne),be=new kje(H,ne,ue,pe),ye=new Dje(H,be,ne,ue),ze=new Rje(H,Y,Me),lt=new _je(Ee),_e=new XRe(C,U,O,$,Y,pe,lt),We=new xDe(C,Ee),Ve=new QRe,Ye=new iDe($),ae=new xje(C,U,O,se,ye,p,c),de=new oDe(C,ye,Y),nt=new bDe(H,ue,Y,se),Ue=new yje(H,$,ue),et=new Pje(H,$,ue),ue.programs=_e.programs,C.capabilities=Y,C.extensions=$,C.properties=Ee,C.renderLists=Ve,C.shadowMap=de,C.state=se,C.info=ue}ve();const He=new pDe(C,H);this.xr=He,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const ie=$.get("WEBGL_lose_context");ie&&ie.loseContext()},this.forceContextRestore=function(){const ie=$.get("WEBGL_lose_context");ie&&ie.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(ie){ie!==void 0&&(Z=ie,this.setSize(J,ee,!1))},this.getSize=function(ie){return ie.set(J,ee)},this.setSize=function(ie,Ae,Fe=!0){if(He.isPresenting){Zt("WebGLRenderer: Can't change size while VR device is presenting.");return}J=ie,ee=Ae,n.width=Math.floor(ie*Z),n.height=Math.floor(Ae*Z),Fe===!0&&(n.style.width=ie+"px",n.style.height=Ae+"px"),this.setViewport(0,0,ie,Ae)},this.getDrawingBufferSize=function(ie){return ie.set(J*Z,ee*Z).floor()},this.setDrawingBufferSize=function(ie,Ae,Fe){J=ie,ee=Ae,Z=Fe,n.width=Math.floor(ie*Fe),n.height=Math.floor(Ae*Fe),this.setViewport(0,0,ie,Ae)},this.getCurrentViewport=function(ie){return ie.copy(q)},this.getViewport=function(ie){return ie.copy(Q)},this.setViewport=function(ie,Ae,Fe,Le){ie.isVector4?Q.set(ie.x,ie.y,ie.z,ie.w):Q.set(ie,Ae,Fe,Le),se.viewport(q.copy(Q).multiplyScalar(Z).round())},this.getScissor=function(ie){return ie.copy(te)},this.setScissor=function(ie,Ae,Fe,Le){ie.isVector4?te.set(ie.x,ie.y,ie.z,ie.w):te.set(ie,Ae,Fe,Le),se.scissor(j.copy(te).multiplyScalar(Z).round())},this.getScissorTest=function(){return he},this.setScissorTest=function(ie){se.setScissorTest(he=ie)},this.setOpaqueSort=function(ie){B=ie},this.setTransparentSort=function(ie){G=ie},this.getClearColor=function(ie){return ie.copy(ae.getClearColor())},this.setClearColor=function(){ae.setClearColor(...arguments)},this.getClearAlpha=function(){return ae.getClearAlpha()},this.setClearAlpha=function(){ae.setClearAlpha(...arguments)},this.clear=function(ie=!0,Ae=!0,Fe=!0){let Le=0;if(ie){let Pe=!1;if(R!==null){const ct=R.texture.format;Pe=x.has(ct)}if(Pe){const ct=R.texture.type,mt=v.has(ct),Mt=ae.getClearColor(),_t=ae.getClearAlpha(),Lt=Mt.r,Ct=Mt.g,bt=Mt.b;mt?(y[0]=Lt,y[1]=Ct,y[2]=bt,y[3]=_t,H.clearBufferuiv(H.COLOR,0,y)):(b[0]=Lt,b[1]=Ct,b[2]=bt,b[3]=_t,H.clearBufferiv(H.COLOR,0,b))}else Le|=H.COLOR_BUFFER_BIT}Ae&&(Le|=H.DEPTH_BUFFER_BIT),Fe&&(Le|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(Le)},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",je,!1),n.removeEventListener("webglcontextrestored",we,!1),n.removeEventListener("webglcontextcreationerror",Xe,!1),ae.dispose(),Ve.dispose(),Ye.dispose(),Ee.dispose(),U.dispose(),O.dispose(),ye.dispose(),pe.dispose(),nt.dispose(),_e.dispose(),He.dispose(),He.removeEventListener("sessionstart",Nn),He.removeEventListener("sessionend",Lr),Er.stop()};function je(ie){ie.preventDefault(),gH("WebGLRenderer: Context Lost."),N=!0}function we(){gH("WebGLRenderer: Context Restored."),N=!1;const ie=ue.autoReset,Ae=de.enabled,Fe=de.autoUpdate,Le=de.needsUpdate,Pe=de.type;ve(),ue.autoReset=ie,de.enabled=Ae,de.autoUpdate=Fe,de.needsUpdate=Le,de.type=Pe}function Xe(ie){Zr("WebGLRenderer: A WebGL context could not be created. Reason: ",ie.statusMessage)}function ot(ie){const Ae=ie.target;Ae.removeEventListener("dispose",ot),St(Ae)}function St(ie){Dt(ie),Ee.remove(ie)}function Dt(ie){const Ae=Ee.get(ie).programs;Ae!==void 0&&(Ae.forEach(function(Fe){_e.releaseProgram(Fe)}),ie.isShaderMaterial&&_e.releaseShaderCache(ie))}this.renderBufferDirect=function(ie,Ae,Fe,Le,Pe,ct){Ae===null&&(Ae=fe);const mt=Pe.isMesh&&Pe.matrixWorld.determinant()<0,Mt=ge(ie,Ae,Fe,Le,Pe);se.setMaterial(Le,mt);let _t=Fe.index,Lt=1;if(Le.wireframe===!0){if(_t=be.getWireframeAttribute(Fe),_t===void 0)return;Lt=2}const Ct=Fe.drawRange,bt=Fe.attributes.position;let Yt=Ct.start*Lt,zt=(Ct.start+Ct.count)*Lt;ct!==null&&(Yt=Math.max(Yt,ct.start*Lt),zt=Math.min(zt,(ct.start+ct.count)*Lt)),_t!==null?(Yt=Math.max(Yt,0),zt=Math.min(zt,_t.count)):bt!=null&&(Yt=Math.max(Yt,0),zt=Math.min(zt,bt.count));const on=zt-Yt;if(on<0||on===1/0)return;pe.setup(Pe,Le,Mt,Fe,_t);let pn,_n=Ue;if(_t!==null&&(pn=ne.get(_t),_n=et,_n.setIndex(pn)),Pe.isMesh)Le.wireframe===!0?(se.setLineWidth(Le.wireframeLinewidth*z()),_n.setMode(H.LINES)):_n.setMode(H.TRIANGLES);else if(Pe.isLine){let Ut=Le.linewidth;Ut===void 0&&(Ut=1),se.setLineWidth(Ut*z()),Pe.isLineSegments?_n.setMode(H.LINES):Pe.isLineLoop?_n.setMode(H.LINE_LOOP):_n.setMode(H.LINE_STRIP)}else Pe.isPoints?_n.setMode(H.POINTS):Pe.isSprite&&_n.setMode(H.TRIANGLES);if(Pe.isBatchedMesh)if(Pe._multiDrawInstances!==null)eb("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),_n.renderMultiDrawInstances(Pe._multiDrawStarts,Pe._multiDrawCounts,Pe._multiDrawCount,Pe._multiDrawInstances);else if($.get("WEBGL_multi_draw"))_n.renderMultiDraw(Pe._multiDrawStarts,Pe._multiDrawCounts,Pe._multiDrawCount);else{const Ut=Pe._multiDrawStarts,en=Pe._multiDrawCounts,nn=Pe._multiDrawCount,Ir=_t?ne.get(_t).bytesPerElement:1,Wr=Ee.get(Le).currentProgram.getUniforms();for(let Fn=0;Fn<nn;Fn++)Wr.setValue(H,"_gl_DrawID",Fn),_n.render(Ut[Fn]/Ir,en[Fn])}else if(Pe.isInstancedMesh)_n.renderInstances(Yt,on,Pe.count);else if(Fe.isInstancedBufferGeometry){const Ut=Fe._maxInstanceCount!==void 0?Fe._maxInstanceCount:1/0,en=Math.min(Fe.instanceCount,Ut);_n.renderInstances(Yt,on,en)}else _n.render(Yt,on)};function qt(ie,Ae,Fe){ie.transparent===!0&&ie.side===ll&&ie.forceSinglePass===!1?(ie.side=es,ie.needsUpdate=!0,Oe(ie,Ae,Fe),ie.side=wd,ie.needsUpdate=!0,Oe(ie,Ae,Fe),ie.side=ll):Oe(ie,Ae,Fe)}this.compile=function(ie,Ae,Fe=null){Fe===null&&(Fe=ie),w=Ye.get(Fe),w.init(Ae),A.push(w),Fe.traverseVisible(function(Pe){Pe.isLight&&Pe.layers.test(Ae.layers)&&(w.pushLight(Pe),Pe.castShadow&&w.pushShadow(Pe))}),ie!==Fe&&ie.traverseVisible(function(Pe){Pe.isLight&&Pe.layers.test(Ae.layers)&&(w.pushLight(Pe),Pe.castShadow&&w.pushShadow(Pe))}),w.setupLights();const Le=new Set;return ie.traverse(function(Pe){if(!(Pe.isMesh||Pe.isPoints||Pe.isLine||Pe.isSprite))return;const ct=Pe.material;if(ct)if(Array.isArray(ct))for(let mt=0;mt<ct.length;mt++){const Mt=ct[mt];qt(Mt,Fe,Pe),Le.add(Mt)}else qt(ct,Fe,Pe),Le.add(ct)}),w=A.pop(),Le},this.compileAsync=function(ie,Ae,Fe=null){const Le=this.compile(ie,Ae,Fe);return new Promise(Pe=>{function ct(){if(Le.forEach(function(mt){Ee.get(mt).currentProgram.isReady()&&Le.delete(mt)}),Le.size===0){Pe(ie);return}setTimeout(ct,10)}$.get("KHR_parallel_shader_compile")!==null?ct():setTimeout(ct,10)})};let Ft=null;function kn(ie){Ft&&Ft(ie)}function Nn(){Er.stop()}function Lr(){Er.start()}const Er=new VZ;Er.setAnimationLoop(kn),typeof self<"u"&&Er.setContext(self),this.setAnimationLoop=function(ie){Ft=ie,He.setAnimationLoop(ie),ie===null?Er.stop():Er.start()},He.addEventListener("sessionstart",Nn),He.addEventListener("sessionend",Lr),this.render=function(ie,Ae){if(Ae!==void 0&&Ae.isCamera!==!0){Zr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(ie.matrixWorldAutoUpdate===!0&&ie.updateMatrixWorld(),Ae.parent===null&&Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),He.enabled===!0&&He.isPresenting===!0&&(He.cameraAutoUpdate===!0&&He.updateCamera(Ae),Ae=He.getCamera()),ie.isScene===!0&&ie.onBeforeRender(C,ie,Ae,R),w=Ye.get(ie,A.length),w.init(Ae),A.push(w),me.multiplyMatrices(Ae.projectionMatrix,Ae.matrixWorldInverse),oe.setFromProjectionMatrix(me,hl,Ae.reversedDepth),Te=this.localClippingEnabled,xe=lt.init(this.clippingPlanes,Te),E=Ve.get(ie,T.length),E.init(),T.push(E),He.enabled===!0&&He.isPresenting===!0){const ct=C.xr.getDepthSensingMesh();ct!==null&&br(ct,Ae,-1/0,C.sortObjects)}br(ie,Ae,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(B,G),Ie=He.enabled===!1||He.isPresenting===!1||He.hasDepthSensing()===!1,Ie&&ae.addToRenderList(E,ie),this.info.render.frame++,xe===!0&<.beginShadows();const Fe=w.state.shadowsArray;de.render(Fe,ie,Ae),xe===!0&<.endShadows(),this.info.autoReset===!0&&this.info.reset();const Le=E.opaque,Pe=E.transmissive;if(w.setupLights(),Ae.isArrayCamera){const ct=Ae.cameras;if(Pe.length>0)for(let mt=0,Mt=ct.length;mt<Mt;mt++){const _t=ct[mt];ei(Le,Pe,ie,_t)}Ie&&ae.render(ie);for(let mt=0,Mt=ct.length;mt<Mt;mt++){const _t=ct[mt];Tr(E,ie,_t,_t.viewport)}}else Pe.length>0&&ei(Le,Pe,ie,Ae),Ie&&ae.render(ie),Tr(E,ie,Ae);R!==null&&k===0&&(Me.updateMultisampleRenderTarget(R),Me.updateRenderTargetMipmap(R)),ie.isScene===!0&&ie.onAfterRender(C,ie,Ae),pe.resetDefaultState(),I=-1,L=null,A.pop(),A.length>0?(w=A[A.length-1],xe===!0&<.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?E=T[T.length-1]:E=null};function br(ie,Ae,Fe,Le){if(ie.visible===!1)return;if(ie.layers.test(Ae.layers)){if(ie.isGroup)Fe=ie.renderOrder;else if(ie.isLOD)ie.autoUpdate===!0&&ie.update(Ae);else if(ie.isLight)w.pushLight(ie),ie.castShadow&&w.pushShadow(ie);else if(ie.isSprite){if(!ie.frustumCulled||oe.intersectsSprite(ie)){Le&&Ce.setFromMatrixPosition(ie.matrixWorld).applyMatrix4(me);const mt=ye.update(ie),Mt=ie.material;Mt.visible&&E.push(ie,mt,Mt,Fe,Ce.z,null)}}else if((ie.isMesh||ie.isLine||ie.isPoints)&&(!ie.frustumCulled||oe.intersectsObject(ie))){const mt=ye.update(ie),Mt=ie.material;if(Le&&(ie.boundingSphere!==void 0?(ie.boundingSphere===null&&ie.computeBoundingSphere(),Ce.copy(ie.boundingSphere.center)):(mt.boundingSphere===null&&mt.computeBoundingSphere(),Ce.copy(mt.boundingSphere.center)),Ce.applyMatrix4(ie.matrixWorld).applyMatrix4(me)),Array.isArray(Mt)){const _t=mt.groups;for(let Lt=0,Ct=_t.length;Lt<Ct;Lt++){const bt=_t[Lt],Yt=Mt[bt.materialIndex];Yt&&Yt.visible&&E.push(ie,mt,Yt,Fe,Ce.z,bt)}}else Mt.visible&&E.push(ie,mt,Mt,Fe,Ce.z,null)}}const ct=ie.children;for(let mt=0,Mt=ct.length;mt<Mt;mt++)br(ct[mt],Ae,Fe,Le)}function Tr(ie,Ae,Fe,Le){const{opaque:Pe,transmissive:ct,transparent:mt}=ie;w.setupLightsView(Fe),xe===!0&<.setGlobalState(C.clippingPlanes,Fe),Le&&se.viewport(q.copy(Le)),Pe.length>0&&Ar(Pe,Ae,Fe),ct.length>0&&Ar(ct,Ae,Fe),mt.length>0&&Ar(mt,Ae,Fe),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function ei(ie,Ae,Fe,Le){if((Fe.isScene===!0?Fe.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Le.id]===void 0&&(w.state.transmissionRenderTarget[Le.id]=new df(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?xg:Sl,minFilter:Ah,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Dn.workingColorSpace}));const ct=w.state.transmissionRenderTarget[Le.id],mt=Le.viewport||q;ct.setSize(mt.z*C.transmissionResolutionScale,mt.w*C.transmissionResolutionScale);const Mt=C.getRenderTarget(),_t=C.getActiveCubeFace(),Lt=C.getActiveMipmapLevel();C.setRenderTarget(ct),C.getClearColor(K),W=C.getClearAlpha(),W<1&&C.setClearColor(16777215,.5),C.clear(),Ie&&ae.render(Fe);const Ct=C.toneMapping;C.toneMapping=sd;const bt=Le.viewport;if(Le.viewport!==void 0&&(Le.viewport=void 0),w.setupLightsView(Le),xe===!0&<.setGlobalState(C.clippingPlanes,Le),Ar(ie,Fe,Le),Me.updateMultisampleRenderTarget(ct),Me.updateRenderTargetMipmap(ct),$.has("WEBGL_multisampled_render_to_texture")===!1){let Yt=!1;for(let zt=0,on=Ae.length;zt<on;zt++){const pn=Ae[zt],{object:_n,geometry:Ut,material:en,group:nn}=pn;if(en.side===ll&&_n.layers.test(Le.layers)){const Ir=en.side;en.side=es,en.needsUpdate=!0,rn(_n,Fe,Le,Ut,en,nn),en.side=Ir,en.needsUpdate=!0,Yt=!0}}Yt===!0&&(Me.updateMultisampleRenderTarget(ct),Me.updateRenderTargetMipmap(ct))}C.setRenderTarget(Mt,_t,Lt),C.setClearColor(K,W),bt!==void 0&&(Le.viewport=bt),C.toneMapping=Ct}function Ar(ie,Ae,Fe){const Le=Ae.isScene===!0?Ae.overrideMaterial:null;for(let Pe=0,ct=ie.length;Pe<ct;Pe++){const mt=ie[Pe],{object:Mt,geometry:_t,group:Lt}=mt;let Ct=mt.material;Ct.allowOverride===!0&&Le!==null&&(Ct=Le),Mt.layers.test(Fe.layers)&&rn(Mt,Ae,Fe,_t,Ct,Lt)}}function rn(ie,Ae,Fe,Le,Pe,ct){ie.onBeforeRender(C,Ae,Fe,Le,Pe,ct),ie.modelViewMatrix.multiplyMatrices(Fe.matrixWorldInverse,ie.matrixWorld),ie.normalMatrix.getNormalMatrix(ie.modelViewMatrix),Pe.onBeforeRender(C,Ae,Fe,Le,ie,ct),Pe.transparent===!0&&Pe.side===ll&&Pe.forceSinglePass===!1?(Pe.side=es,Pe.needsUpdate=!0,C.renderBufferDirect(Fe,Ae,Le,Pe,ie,ct),Pe.side=wd,Pe.needsUpdate=!0,C.renderBufferDirect(Fe,Ae,Le,Pe,ie,ct),Pe.side=ll):C.renderBufferDirect(Fe,Ae,Le,Pe,ie,ct),ie.onAfterRender(C,Ae,Fe,Le,Pe,ct)}function Oe(ie,Ae,Fe){Ae.isScene!==!0&&(Ae=fe);const Le=Ee.get(ie),Pe=w.state.lights,ct=w.state.shadowsArray,mt=Pe.state.version,Mt=_e.getParameters(ie,Pe.state,ct,Ae,Fe),_t=_e.getProgramCacheKey(Mt);let Lt=Le.programs;Le.environment=ie.isMeshStandardMaterial?Ae.environment:null,Le.fog=Ae.fog,Le.envMap=(ie.isMeshStandardMaterial?O:U).get(ie.envMap||Le.environment),Le.envMapRotation=Le.environment!==null&&ie.envMap===null?Ae.environmentRotation:ie.envMapRotation,Lt===void 0&&(ie.addEventListener("dispose",ot),Lt=new Map,Le.programs=Lt);let Ct=Lt.get(_t);if(Ct!==void 0){if(Le.currentProgram===Ct&&Le.lightsStateVersion===mt)return Gr(ie,Mt),Ct}else Mt.uniforms=_e.getUniforms(ie),ie.onBeforeCompile(Mt,C),Ct=_e.acquireProgram(Mt,_t),Lt.set(_t,Ct),Le.uniforms=Mt.uniforms;const bt=Le.uniforms;return(!ie.isShaderMaterial&&!ie.isRawShaderMaterial||ie.clipping===!0)&&(bt.clippingPlanes=lt.uniform),Gr(ie,Mt),Le.needsLights=rt(ie),Le.lightsStateVersion=mt,Le.needsLights&&(bt.ambientLightColor.value=Pe.state.ambient,bt.lightProbe.value=Pe.state.probe,bt.directionalLights.value=Pe.state.directional,bt.directionalLightShadows.value=Pe.state.directionalShadow,bt.spotLights.value=Pe.state.spot,bt.spotLightShadows.value=Pe.state.spotShadow,bt.rectAreaLights.value=Pe.state.rectArea,bt.ltc_1.value=Pe.state.rectAreaLTC1,bt.ltc_2.value=Pe.state.rectAreaLTC2,bt.pointLights.value=Pe.state.point,bt.pointLightShadows.value=Pe.state.pointShadow,bt.hemisphereLights.value=Pe.state.hemi,bt.directionalShadowMap.value=Pe.state.directionalShadowMap,bt.directionalShadowMatrix.value=Pe.state.directionalShadowMatrix,bt.spotShadowMap.value=Pe.state.spotShadowMap,bt.spotLightMatrix.value=Pe.state.spotLightMatrix,bt.spotLightMap.value=Pe.state.spotLightMap,bt.pointShadowMap.value=Pe.state.pointShadowMap,bt.pointShadowMatrix.value=Pe.state.pointShadowMatrix),Le.currentProgram=Ct,Le.uniformsList=null,Ct}function Jt(ie){if(ie.uniformsList===null){const Ae=ie.currentProgram.getUniforms();ie.uniformsList=M1.seqWithValue(Ae.seq,ie.uniforms)}return ie.uniformsList}function Gr(ie,Ae){const Fe=Ee.get(ie);Fe.outputColorSpace=Ae.outputColorSpace,Fe.batching=Ae.batching,Fe.batchingColor=Ae.batchingColor,Fe.instancing=Ae.instancing,Fe.instancingColor=Ae.instancingColor,Fe.instancingMorph=Ae.instancingMorph,Fe.skinning=Ae.skinning,Fe.morphTargets=Ae.morphTargets,Fe.morphNormals=Ae.morphNormals,Fe.morphColors=Ae.morphColors,Fe.morphTargetsCount=Ae.morphTargetsCount,Fe.numClippingPlanes=Ae.numClippingPlanes,Fe.numIntersection=Ae.numClipIntersection,Fe.vertexAlphas=Ae.vertexAlphas,Fe.vertexTangents=Ae.vertexTangents,Fe.toneMapping=Ae.toneMapping}function ge(ie,Ae,Fe,Le,Pe){Ae.isScene!==!0&&(Ae=fe),Me.resetTextureUnits();const ct=Ae.fog,mt=Le.isMeshStandardMaterial?Ae.environment:null,Mt=R===null?C.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Up,_t=(Le.isMeshStandardMaterial?O:U).get(Le.envMap||mt),Lt=Le.vertexColors===!0&&!!Fe.attributes.color&&Fe.attributes.color.itemSize===4,Ct=!!Fe.attributes.tangent&&(!!Le.normalMap||Le.anisotropy>0),bt=!!Fe.morphAttributes.position,Yt=!!Fe.morphAttributes.normal,zt=!!Fe.morphAttributes.color;let on=sd;Le.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(on=C.toneMapping);const pn=Fe.morphAttributes.position||Fe.morphAttributes.normal||Fe.morphAttributes.color,_n=pn!==void 0?pn.length:0,Ut=Ee.get(Le),en=w.state.lights;if(xe===!0&&(Te===!0||ie!==L)){const Pi=ie===L&&Le.id===I;lt.setState(Le,ie,Pi)}let nn=!1;Le.version===Ut.__version?(Ut.needsLights&&Ut.lightsStateVersion!==en.state.version||Ut.outputColorSpace!==Mt||Pe.isBatchedMesh&&Ut.batching===!1||!Pe.isBatchedMesh&&Ut.batching===!0||Pe.isBatchedMesh&&Ut.batchingColor===!0&&Pe.colorTexture===null||Pe.isBatchedMesh&&Ut.batchingColor===!1&&Pe.colorTexture!==null||Pe.isInstancedMesh&&Ut.instancing===!1||!Pe.isInstancedMesh&&Ut.instancing===!0||Pe.isSkinnedMesh&&Ut.skinning===!1||!Pe.isSkinnedMesh&&Ut.skinning===!0||Pe.isInstancedMesh&&Ut.instancingColor===!0&&Pe.instanceColor===null||Pe.isInstancedMesh&&Ut.instancingColor===!1&&Pe.instanceColor!==null||Pe.isInstancedMesh&&Ut.instancingMorph===!0&&Pe.morphTexture===null||Pe.isInstancedMesh&&Ut.instancingMorph===!1&&Pe.morphTexture!==null||Ut.envMap!==_t||Le.fog===!0&&Ut.fog!==ct||Ut.numClippingPlanes!==void 0&&(Ut.numClippingPlanes!==lt.numPlanes||Ut.numIntersection!==lt.numIntersection)||Ut.vertexAlphas!==Lt||Ut.vertexTangents!==Ct||Ut.morphTargets!==bt||Ut.morphNormals!==Yt||Ut.morphColors!==zt||Ut.toneMapping!==on||Ut.morphTargetsCount!==_n)&&(nn=!0):(nn=!0,Ut.__version=Le.version);let Ir=Ut.currentProgram;nn===!0&&(Ir=Oe(Le,Ae,Pe));let Wr=!1,Fn=!1,vo=!1;const zn=Ir.getUniforms(),ki=Ut.uniforms;if(se.useProgram(Ir.program)&&(Wr=!0,Fn=!0,vo=!0),Le.id!==I&&(I=Le.id,Fn=!0),Wr||L!==ie){se.buffers.depth.getReversed()&&ie.reversedDepth!==!0&&(ie._reversedDepth=!0,ie.updateProjectionMatrix()),zn.setValue(H,"projectionMatrix",ie.projectionMatrix),zn.setValue(H,"viewMatrix",ie.matrixWorldInverse);const Wi=zn.map.cameraPosition;Wi!==void 0&&Wi.setValue(H,ce.setFromMatrixPosition(ie.matrixWorld)),Y.logarithmicDepthBuffer&&zn.setValue(H,"logDepthBufFC",2/(Math.log(ie.far+1)/Math.LN2)),(Le.isMeshPhongMaterial||Le.isMeshToonMaterial||Le.isMeshLambertMaterial||Le.isMeshBasicMaterial||Le.isMeshStandardMaterial||Le.isShaderMaterial)&&zn.setValue(H,"isOrthographic",ie.isOrthographicCamera===!0),L!==ie&&(L=ie,Fn=!0,vo=!0)}if(Pe.isSkinnedMesh){zn.setOptional(H,Pe,"bindMatrix"),zn.setOptional(H,Pe,"bindMatrixInverse");const Pi=Pe.skeleton;Pi&&(Pi.boneTexture===null&&Pi.computeBoneTexture(),zn.setValue(H,"boneTexture",Pi.boneTexture,Me))}Pe.isBatchedMesh&&(zn.setOptional(H,Pe,"batchingTexture"),zn.setValue(H,"batchingTexture",Pe._matricesTexture,Me),zn.setOptional(H,Pe,"batchingIdTexture"),zn.setValue(H,"batchingIdTexture",Pe._indirectTexture,Me),zn.setOptional(H,Pe,"batchingColorTexture"),Pe._colorsTexture!==null&&zn.setValue(H,"batchingColorTexture",Pe._colorsTexture,Me));const mi=Fe.morphAttributes;if((mi.position!==void 0||mi.normal!==void 0||mi.color!==void 0)&&ze.update(Pe,Fe,Ir),(Fn||Ut.receiveShadow!==Pe.receiveShadow)&&(Ut.receiveShadow=Pe.receiveShadow,zn.setValue(H,"receiveShadow",Pe.receiveShadow)),Le.isMeshGouraudMaterial&&Le.envMap!==null&&(ki.envMap.value=_t,ki.flipEnvMap.value=_t.isCubeTexture&&_t.isRenderTargetTexture===!1?-1:1),Le.isMeshStandardMaterial&&Le.envMap===null&&Ae.environment!==null&&(ki.envMapIntensity.value=Ae.environmentIntensity),ki.dfgLUT!==void 0&&(ki.dfgLUT.value=vDe()),Fn&&(zn.setValue(H,"toneMappingExposure",C.toneMappingExposure),Ut.needsLights&&Ge(ki,vo),ct&&Le.fog===!0&&We.refreshFogUniforms(ki,ct),We.refreshMaterialUniforms(ki,Le,Z,ee,w.state.transmissionRenderTarget[ie.id]),M1.upload(H,Jt(Ut),ki,Me)),Le.isShaderMaterial&&Le.uniformsNeedUpdate===!0&&(M1.upload(H,Jt(Ut),ki,Me),Le.uniformsNeedUpdate=!1),Le.isSpriteMaterial&&zn.setValue(H,"center",Pe.center),zn.setValue(H,"modelViewMatrix",Pe.modelViewMatrix),zn.setValue(H,"normalMatrix",Pe.normalMatrix),zn.setValue(H,"modelMatrix",Pe.matrixWorld),Le.isShaderMaterial||Le.isRawShaderMaterial){const Pi=Le.uniformsGroups;for(let Wi=0,Ko=Pi.length;Wi<Ko;Wi++){const Ol=Pi[Wi];nt.update(Ol,Ir),nt.bind(Ol,Ir)}}return Ir}function Ge(ie,Ae){ie.ambientLightColor.needsUpdate=Ae,ie.lightProbe.needsUpdate=Ae,ie.directionalLights.needsUpdate=Ae,ie.directionalLightShadows.needsUpdate=Ae,ie.pointLights.needsUpdate=Ae,ie.pointLightShadows.needsUpdate=Ae,ie.spotLights.needsUpdate=Ae,ie.spotLightShadows.needsUpdate=Ae,ie.rectAreaLights.needsUpdate=Ae,ie.hemisphereLights.needsUpdate=Ae}function rt(ie){return ie.isMeshLambertMaterial||ie.isMeshToonMaterial||ie.isMeshPhongMaterial||ie.isMeshStandardMaterial||ie.isShadowMaterial||ie.isShaderMaterial&&ie.lights===!0}this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(ie,Ae,Fe){const Le=Ee.get(ie);Le.__autoAllocateDepthBuffer=ie.resolveDepthBuffer===!1,Le.__autoAllocateDepthBuffer===!1&&(Le.__useRenderToTexture=!1),Ee.get(ie.texture).__webglTexture=Ae,Ee.get(ie.depthTexture).__webglTexture=Le.__autoAllocateDepthBuffer?void 0:Fe,Le.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ie,Ae){const Fe=Ee.get(ie);Fe.__webglFramebuffer=Ae,Fe.__useDefaultFramebuffer=Ae===void 0};const Ke=H.createFramebuffer();this.setRenderTarget=function(ie,Ae=0,Fe=0){R=ie,F=Ae,k=Fe;let Le=!0,Pe=null,ct=!1,mt=!1;if(ie){const _t=Ee.get(ie);if(_t.__useDefaultFramebuffer!==void 0)se.bindFramebuffer(H.FRAMEBUFFER,null),Le=!1;else if(_t.__webglFramebuffer===void 0)Me.setupRenderTarget(ie);else if(_t.__hasExternalTextures)Me.rebindTextures(ie,Ee.get(ie.texture).__webglTexture,Ee.get(ie.depthTexture).__webglTexture);else if(ie.depthBuffer){const bt=ie.depthTexture;if(_t.__boundDepthTexture!==bt){if(bt!==null&&Ee.has(bt)&&(ie.width!==bt.image.width||ie.height!==bt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Me.setupDepthRenderbuffer(ie)}}const Lt=ie.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(mt=!0);const Ct=Ee.get(ie).__webglFramebuffer;ie.isWebGLCubeRenderTarget?(Array.isArray(Ct[Ae])?Pe=Ct[Ae][Fe]:Pe=Ct[Ae],ct=!0):ie.samples>0&&Me.useMultisampledRTT(ie)===!1?Pe=Ee.get(ie).__webglMultisampledFramebuffer:Array.isArray(Ct)?Pe=Ct[Fe]:Pe=Ct,q.copy(ie.viewport),j.copy(ie.scissor),V=ie.scissorTest}else q.copy(Q).multiplyScalar(Z).floor(),j.copy(te).multiplyScalar(Z).floor(),V=he;if(Fe!==0&&(Pe=Ke),se.bindFramebuffer(H.FRAMEBUFFER,Pe)&&Le&&se.drawBuffers(ie,Pe),se.viewport(q),se.scissor(j),se.setScissorTest(V),ct){const _t=Ee.get(ie.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,_t.__webglTexture,Fe)}else if(mt){const _t=Ae;for(let Lt=0;Lt<ie.textures.length;Lt++){const Ct=Ee.get(ie.textures[Lt]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+Lt,Ct.__webglTexture,Fe,_t)}}else if(ie!==null&&Fe!==0){const _t=Ee.get(ie.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,_t.__webglTexture,Fe)}I=-1},this.readRenderTargetPixels=function(ie,Ae,Fe,Le,Pe,ct,mt,Mt=0){if(!(ie&&ie.isWebGLRenderTarget)){Zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _t=Ee.get(ie).__webglFramebuffer;if(ie.isWebGLCubeRenderTarget&&mt!==void 0&&(_t=_t[mt]),_t){se.bindFramebuffer(H.FRAMEBUFFER,_t);try{const Lt=ie.textures[Mt],Ct=Lt.format,bt=Lt.type;if(!Y.textureFormatReadable(Ct)){Zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Y.textureTypeReadable(bt)){Zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ae>=0&&Ae<=ie.width-Le&&Fe>=0&&Fe<=ie.height-Pe&&(ie.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Mt),H.readPixels(Ae,Fe,Le,Pe,dt.convert(Ct),dt.convert(bt),ct))}finally{const Lt=R!==null?Ee.get(R).__webglFramebuffer:null;se.bindFramebuffer(H.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(ie,Ae,Fe,Le,Pe,ct,mt,Mt=0){if(!(ie&&ie.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let _t=Ee.get(ie).__webglFramebuffer;if(ie.isWebGLCubeRenderTarget&&mt!==void 0&&(_t=_t[mt]),_t)if(Ae>=0&&Ae<=ie.width-Le&&Fe>=0&&Fe<=ie.height-Pe){se.bindFramebuffer(H.FRAMEBUFFER,_t);const Lt=ie.textures[Mt],Ct=Lt.format,bt=Lt.type;if(!Y.textureFormatReadable(Ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Y.textureTypeReadable(bt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Yt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,Yt),H.bufferData(H.PIXEL_PACK_BUFFER,ct.byteLength,H.STREAM_READ),ie.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Mt),H.readPixels(Ae,Fe,Le,Pe,dt.convert(Ct),dt.convert(bt),0);const zt=R!==null?Ee.get(R).__webglFramebuffer:null;se.bindFramebuffer(H.FRAMEBUFFER,zt);const on=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await WCe(H,on,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,Yt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,ct),H.deleteBuffer(Yt),H.deleteSync(on),ct}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ie,Ae=null,Fe=0){const Le=Math.pow(2,-Fe),Pe=Math.floor(ie.image.width*Le),ct=Math.floor(ie.image.height*Le),mt=Ae!==null?Ae.x:0,Mt=Ae!==null?Ae.y:0;Me.setTexture2D(ie,0),H.copyTexSubImage2D(H.TEXTURE_2D,Fe,0,0,mt,Mt,Pe,ct),se.unbindTexture()};const at=H.createFramebuffer(),At=H.createFramebuffer();this.copyTextureToTexture=function(ie,Ae,Fe=null,Le=null,Pe=0,ct=null){ct===null&&(Pe!==0?(eb("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ct=Pe,Pe=0):ct=0);let mt,Mt,_t,Lt,Ct,bt,Yt,zt,on;const pn=ie.isCompressedTexture?ie.mipmaps[ct]:ie.image;if(Fe!==null)mt=Fe.max.x-Fe.min.x,Mt=Fe.max.y-Fe.min.y,_t=Fe.isBox3?Fe.max.z-Fe.min.z:1,Lt=Fe.min.x,Ct=Fe.min.y,bt=Fe.isBox3?Fe.min.z:0;else{const mi=Math.pow(2,-Pe);mt=Math.floor(pn.width*mi),Mt=Math.floor(pn.height*mi),ie.isDataArrayTexture?_t=pn.depth:ie.isData3DTexture?_t=Math.floor(pn.depth*mi):_t=1,Lt=0,Ct=0,bt=0}Le!==null?(Yt=Le.x,zt=Le.y,on=Le.z):(Yt=0,zt=0,on=0);const _n=dt.convert(Ae.format),Ut=dt.convert(Ae.type);let en;Ae.isData3DTexture?(Me.setTexture3D(Ae,0),en=H.TEXTURE_3D):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?(Me.setTexture2DArray(Ae,0),en=H.TEXTURE_2D_ARRAY):(Me.setTexture2D(Ae,0),en=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Ae.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ae.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Ae.unpackAlignment);const nn=H.getParameter(H.UNPACK_ROW_LENGTH),Ir=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Wr=H.getParameter(H.UNPACK_SKIP_PIXELS),Fn=H.getParameter(H.UNPACK_SKIP_ROWS),vo=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,pn.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,pn.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Lt),H.pixelStorei(H.UNPACK_SKIP_ROWS,Ct),H.pixelStorei(H.UNPACK_SKIP_IMAGES,bt);const zn=ie.isDataArrayTexture||ie.isData3DTexture,ki=Ae.isDataArrayTexture||Ae.isData3DTexture;if(ie.isDepthTexture){const mi=Ee.get(ie),Pi=Ee.get(Ae),Wi=Ee.get(mi.__renderTarget),Ko=Ee.get(Pi.__renderTarget);se.bindFramebuffer(H.READ_FRAMEBUFFER,Wi.__webglFramebuffer),se.bindFramebuffer(H.DRAW_FRAMEBUFFER,Ko.__webglFramebuffer);for(let Ol=0;Ol<_t;Ol++)zn&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ee.get(ie).__webglTexture,Pe,bt+Ol),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ee.get(Ae).__webglTexture,ct,on+Ol)),H.blitFramebuffer(Lt,Ct,mt,Mt,Yt,zt,mt,Mt,H.DEPTH_BUFFER_BIT,H.NEAREST);se.bindFramebuffer(H.READ_FRAMEBUFFER,null),se.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(Pe!==0||ie.isRenderTargetTexture||Ee.has(ie)){const mi=Ee.get(ie),Pi=Ee.get(Ae);se.bindFramebuffer(H.READ_FRAMEBUFFER,at),se.bindFramebuffer(H.DRAW_FRAMEBUFFER,At);for(let Wi=0;Wi<_t;Wi++)zn?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,mi.__webglTexture,Pe,bt+Wi):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,mi.__webglTexture,Pe),ki?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Pi.__webglTexture,ct,on+Wi):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Pi.__webglTexture,ct),Pe!==0?H.blitFramebuffer(Lt,Ct,mt,Mt,Yt,zt,mt,Mt,H.COLOR_BUFFER_BIT,H.NEAREST):ki?H.copyTexSubImage3D(en,ct,Yt,zt,on+Wi,Lt,Ct,mt,Mt):H.copyTexSubImage2D(en,ct,Yt,zt,Lt,Ct,mt,Mt);se.bindFramebuffer(H.READ_FRAMEBUFFER,null),se.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else ki?ie.isDataTexture||ie.isData3DTexture?H.texSubImage3D(en,ct,Yt,zt,on,mt,Mt,_t,_n,Ut,pn.data):Ae.isCompressedArrayTexture?H.compressedTexSubImage3D(en,ct,Yt,zt,on,mt,Mt,_t,_n,pn.data):H.texSubImage3D(en,ct,Yt,zt,on,mt,Mt,_t,_n,Ut,pn):ie.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,ct,Yt,zt,mt,Mt,_n,Ut,pn.data):ie.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,ct,Yt,zt,pn.width,pn.height,_n,pn.data):H.texSubImage2D(H.TEXTURE_2D,ct,Yt,zt,mt,Mt,_n,Ut,pn);H.pixelStorei(H.UNPACK_ROW_LENGTH,nn),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Ir),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Wr),H.pixelStorei(H.UNPACK_SKIP_ROWS,Fn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,vo),ct===0&&Ae.generateMipmaps&&H.generateMipmap(en),se.unbindTexture()},this.initRenderTarget=function(ie){Ee.get(ie).__webglFramebuffer===void 0&&Me.setupRenderTarget(ie)},this.initTexture=function(ie){ie.isCubeTexture?Me.setTextureCube(ie,0):ie.isData3DTexture?Me.setTexture3D(ie,0):ie.isDataArrayTexture||ie.isCompressedArrayTexture?Me.setTexture2DArray(ie,0):Me.setTexture2D(ie,0),se.unbindTexture()},this.resetState=function(){F=0,k=0,R=null,se.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Dn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Dn._getUnpackColorSpace()}};const d$={type:"change"},LO={type:"start"},XZ={type:"end"},f_=new PO,h$=new Bu,wDe=Math.cos(70*KCe.DEG2RAD),gi=new it,Ka=2*Math.PI,tr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},oC=1e-6;class SDe extends Dke{constructor(e,n=null){super(e,n),this.state=tr.NONE,this.target=new it,this.cursor=new it,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:dp.ROTATE,MIDDLE:dp.DOLLY,RIGHT:dp.PAN},this.touches={ONE:ip.ROTATE,TWO:ip.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new it,this._lastQuaternion=new uf,this._lastTargetPosition=new it,this._quat=new uf().setFromUnitVectors(e.up,new it(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new zH,this._sphericalDelta=new zH,this._scale=1,this._panOffset=new it,this._rotateStart=new dn,this._rotateEnd=new dn,this._rotateDelta=new dn,this._panStart=new dn,this._panEnd=new dn,this._panDelta=new dn,this._dollyStart=new dn,this._dollyEnd=new dn,this._dollyDelta=new dn,this._dollyDirection=new it,this._mouse=new dn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=EDe.bind(this),this._onPointerDown=MDe.bind(this),this._onPointerUp=TDe.bind(this),this._onContextMenu=RDe.bind(this),this._onMouseWheel=CDe.bind(this),this._onKeyDown=kDe.bind(this),this._onTouchStart=PDe.bind(this),this._onTouchMove=jDe.bind(this),this._onMouseDown=ADe.bind(this),this._onMouseMove=NDe.bind(this),this._interceptControlDown=DDe.bind(this),this._interceptControlUp=ODe.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(d$),this.update(),this.state=tr.NONE}update(e=null){const n=this.object.position;gi.copy(n).sub(this.target),gi.applyQuaternion(this._quat),this._spherical.setFromVector3(gi),this.autoRotate&&this.state===tr.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+=Ka:r>Math.PI&&(r-=Ka),i<-Math.PI?i+=Ka:i>Math.PI&&(i-=Ka),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(gi.setFromSpherical(this._spherical),gi.applyQuaternion(this._quatInverse),n.copy(this.target).add(gi),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 l=gi.length();s=this._clampDistance(l*this._scale);const c=l-s;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new it(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new it(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),s=gi.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):(f_.origin.copy(this.object.position),f_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(f_.direction))<wDe?this.object.lookAt(this.target):(h$.setFromNormalAndCoplanarPoint(this.object.up,this.target),f_.intersectPlane(h$,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)>oC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>oC||this._lastTargetPosition.distanceToSquared(this.target)>oC?(this.dispatchEvent(d$),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ka/60*this.autoRotateSpeed*e:Ka/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){gi.setFromMatrixColumn(n,0),gi.multiplyScalar(-e),this._panOffset.add(gi)}_panUp(e,n){this.screenSpacePanning===!0?gi.setFromMatrixColumn(n,1):(gi.setFromMatrixColumn(n,0),gi.crossVectors(this.object.up,gi)),gi.multiplyScalar(e),this._panOffset.add(gi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;gi.copy(i).sub(this.target);let a=gi.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,l=r.height;this._mouse.x=i/s*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ka*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ka*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(Ka*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(-Ka*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(Ka*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(-Ka*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(Ka*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ka*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,l=(e.pageY+n.y)*.5;this._updateZoomParameters(s,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new dn,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 MDe(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 EDe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function TDe(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(XZ),this.state=tr.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 ADe(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 dp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=tr.DOLLY;break;case dp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=tr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=tr.ROTATE}break;case dp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=tr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=tr.PAN}break;default:this.state=tr.NONE}this.state!==tr.NONE&&this.dispatchEvent(LO)}function NDe(t){switch(this.state){case tr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case tr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case tr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function CDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==tr.NONE||(t.preventDefault(),this.dispatchEvent(LO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(XZ))}function kDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function PDe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case ip.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=tr.TOUCH_ROTATE;break;case ip.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=tr.TOUCH_PAN;break;default:this.state=tr.NONE}break;case 2:switch(this.touches.TWO){case ip.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=tr.TOUCH_DOLLY_PAN;break;case ip.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=tr.TOUCH_DOLLY_ROTATE;break;default:this.state=tr.NONE}break;default:this.state=tr.NONE}this.state!==tr.NONE&&this.dispatchEvent(LO)}function jDe(t){switch(this._trackPointer(t),this.state){case tr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case tr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case tr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case tr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=tr.NONE}}function RDe(t){this.enabled!==!1&&t.preventDefault()}function DDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ODe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function LDe(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={},l=t[0].morphTargetsRelative,c=new Dl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;s[p]===void 0&&(s[p]=[]),s[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const p=t[g].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[g].attributes.position.count}c.setIndex(f)}for(const d in a){const f=f$(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 p=[];for(let v=0;v<s[d].length;++v)p.push(s[d][v][g]);const x=f$(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function f$(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),l=new co(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,p=d.count;g<p;g++)for(let x=0;x<n;x++){const v=d.getComponent(g,x);l.setComponent(g+f,x,v)}}else s.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function m_(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var lC={exports:{}};var m$;function IDe(){return m$||(m$=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 m_=="function"&&m_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var v=r[u][1][x];return s(v||x)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof m_=="function"&&m_,c=0;c<a.length;c++)s(a[c]);return s})({1:[function(n,r,i){var a=n("./utils"),s=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,p,x,v,y=[],b=0,E=c.length,w=E,T=a.getTypeOf(c)!=="string";b<c.length;)w=E-b,f=T?(u=c[b++],d=b<E?c[b++]:0,b<E?c[b++]:0):(u=c.charCodeAt(b++),d=b<E?c.charCodeAt(b++):0,b<E?c.charCodeAt(b++):0),g=u>>2,p=(3&u)<<4|d>>4,x=1<w?(15&d)<<2|f>>6:64,v=2<w?63&f:64,y.push(l.charAt(g)+l.charAt(p)+l.charAt(x)+l.charAt(v));return y.join("")},i.decode=function(c){var u,d,f,g,p,x,v=0,y=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var E,w=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&w--,c.charAt(c.length-2)===l.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=s.uint8array?new Uint8Array(0|w):new Array(0|w);v<c.length;)u=l.indexOf(c.charAt(v++))<<2|(g=l.indexOf(c.charAt(v++)))>>4,d=(15&g)<<4|(p=l.indexOf(c.charAt(v++)))>>2,f=(3&p)<<6|(x=l.indexOf(c.charAt(v++))),E[y++]=u,p!==64&&(E[y++]=d),x!==64&&(E[y++]=f);return E}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),s=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,g,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new 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 l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),s=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?(function(u,d,f,g){var p=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^p[255&(u^d[v])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,g){var p=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^p[255&(u^d.charCodeAt(v))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new 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(p,x){var v,y="";for(v=0;v<x;v++)y+=String.fromCharCode(255&p),p>>>=8;return y}function s(p,x,v,y,b,E){var w,T,A=p.file,C=p.compression,N=E!==u.utf8encode,F=l.transformTo("string",E(A.name)),k=l.transformTo("string",u.utf8encode(A.name)),R=A.comment,I=l.transformTo("string",E(R)),L=l.transformTo("string",u.utf8encode(R)),q=k.length!==A.name.length,j=L.length!==R.length,V="",K="",W="",J=A.dir,ee=A.date,Z={crc32:0,compressedSize:0,uncompressedSize:0};x&&!v||(Z.crc32=p.crc32,Z.compressedSize=p.compressedSize,Z.uncompressedSize=p.uncompressedSize);var B=0;x&&(B|=8),N||!q&&!j||(B|=2048);var G=0,Q=0;J&&(G|=16),b==="UNIX"?(Q=798,G|=(function(he,oe){var xe=he;return he||(xe=oe?16893:33204),(65535&xe)<<16})(A.unixPermissions,J)):(Q=20,G|=(function(he){return 63&(he||0)})(A.dosPermissions)),w=ee.getUTCHours(),w<<=6,w|=ee.getUTCMinutes(),w<<=5,w|=ee.getUTCSeconds()/2,T=ee.getUTCFullYear()-1980,T<<=4,T|=ee.getUTCMonth()+1,T<<=5,T|=ee.getUTCDate(),q&&(K=a(1,1)+a(d(F),4)+k,V+="up"+a(K.length,2)+K),j&&(W=a(1,1)+a(d(I),4)+L,V+="uc"+a(W.length,2)+W);var te="";return te+=`
- \0`,te+=a(B,2),te+=C.magic,te+=a(w,2),te+=a(T,2),te+=a(Z.crc32,4),te+=a(Z.compressedSize,4),te+=a(Z.uncompressedSize,4),te+=a(F.length,2),te+=a(V.length,2),{fileRecord:f.LOCAL_FILE_HEADER+te+F+V,dirRecord:f.CENTRAL_FILE_HEADER+a(Q,2)+te+a(I.length,2)+"\0\0\0\0"+a(G,4)+a(y,4)+F+V+I}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(p,x,v,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=v,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(g,c),g.prototype.push=function(p){var x=p.meta.percent||0,v=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:v?(x+100*(v-y-1))/v:100}}))},g.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var v=s(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,v=s(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),x)this.push({data:(function(y){return f.DATA_DESCRIPTOR+a(y.crc32,4)+a(y.compressedSize,4)+a(y.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var v=this.bytesWritten-p,y=(function(b,E,w,T,A){var C=l.transformTo("string",A(T));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(b,2)+a(b,2)+a(E,4)+a(w,4)+a(C.length,2)+C})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(v){x.processChunk(v)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(v){x.error(v)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var v=0;v<x.length;v++)try{x[v].error(p)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new s(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(g,p){f++;var x=(function(E,w){var T=E||w,A=a[T];if(!A)throw new Error(T+" is not a valid compression method !");return A})(p.options.compression,c.compression),v=p.options.compressionOptions||c.compressionOptions||{},y=p.dir,b=p.date;p._compressWorker(x,v).withStreamInfo("file",{name:g,dir:y,date:b,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var l in this)typeof this[l]!="function"&&(s[l]=this[l]);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,l){return new a().loadAsync(s,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),s=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new s.Promise(function(p,x){var v=g.decompressed.getContentWorker().pipe(new u);v.on("error",function(y){x(y)}).on("end",function(){v.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(g,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,p.optimizedBinaryString,p.base64).then(function(v){var y=new c(p);return y.load(v),y}).then(function(v){var y=[s.Promise.resolve(v)],b=v.files;if(p.checkCRC32)for(var E=0;E<b.length;E++)y.push(f(b[E]));return s.Promise.all(y)}).then(function(v){for(var y=v.shift(),b=y.files,E=0;E<b.length;E++){var w=b[E],T=w.fileNameStr,A=a.resolve(w.fileNameStr);x.file(A,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:p.createFolders}),w.dir||(x.file(A).unsafeOriginalName=T)}return y.zipComment.length&&(x.comment=y.zipComment),x})}},{"./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 l(c,u){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,s),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function s(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(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(A,C,N){var F,k=l.getTypeOf(C),R=l.extend(N||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(A=b(A)),R.createFolders&&(F=y(A))&&E.call(this,F,!0);var I=k==="string"&&R.binary===!1&&R.base64===!1;N&&N.binary!==void 0||(R.binary=!I),(C instanceof f&&C.uncompressedSize===0||R.dir||!C||C.length===0)&&(R.base64=!1,R.binary=!0,C="",R.compression="STORE",k="string");var L=null;L=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new v(A,C):l.prepareContent(A,C,R.binary,R.optimizedBinaryString,R.base64);var q=new g(A,L,R);this.files[A]=q}var s=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),y=function(A){A.slice(-1)==="/"&&(A=A.substring(0,A.length-1));var C=A.lastIndexOf("/");return 0<C?A.substring(0,C):""},b=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},E=function(A,C){return C=C!==void 0?C:d.createFolders,A=b(A),this.files[A]||a.call(this,A,null,{dir:!0,createFolders:C}),this.files[A]};function w(A){return Object.prototype.toString.call(A)==="[object RegExp]"}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var C,N,F;for(C in this.files)F=this.files[C],(N=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&A(N,F)},filter:function(A){var C=[];return this.forEach(function(N,F){A(N,F)&&C.push(F)}),C},file:function(A,C,N){if(arguments.length!==1)return A=this.root+A,a.call(this,A,C,N),this;if(w(A)){var F=A;return this.filter(function(R,I){return!I.dir&&F.test(R)})}var k=this.files[this.root+A];return k&&!k.dir?k:null},folder:function(A){if(!A)return this;if(w(A))return this.filter(function(k,R){return R.dir&&A.test(k)});var C=this.root+A,N=E.call(this,C),F=this.clone();return F.root=N.name,F},remove:function(A){A=this.root+A;var C=this.files[A];if(C||(A.slice(-1)!=="/"&&(A+="/"),C=this.files[A]),C&&!C.dir)delete this.files[A];else for(var N=this.filter(function(k,R){return R.name.slice(0,A.length)===A}),F=0;F<N.length;F++)delete this.files[N[F].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(A){var C,N={};try{if((N=l.extend(A||{},{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.");l.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 F=N.comment||this.comment||"";C=p.generateWorker(this,N,F)}catch(k){(C=new c("error")).error(k)}return new u(C,N.type||"string",N.mimeType)},generateAsync:function(A,C){return this.generateInternalStream(A).accumulate(C)},generateNodeStream:function(A,C){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(C)}};r.exports=T},{"./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(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(s,a),s.prototype.byteAt=function(l){return this.data[this.zero+l]},s.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),g=this.readData(4);return c===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},s.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function s(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function s(l){a.call(this,l)}n("../utils").inherits(s,a),s.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function s(l){a.call(this,l)}n("../utils").inherits(s,a),s.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},s.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},s.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},s.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function s(l){a.call(this,l)}n("../utils").inherits(s,a),s.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),s=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=a.getTypeOf(f);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new u(f):s.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),s=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),s=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function l(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,s),l.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=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function l(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(l,s),l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(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,l){return this._listeners[s].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,l){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,l)},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 l=this;return s.on("data",function(c){l.processChunk(c)}),s.on("end",function(){l.end()}),s.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var 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,l){return this.extraStreamInfo[s]=l,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"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,v){return new d.Promise(function(y,b){var E=[],w=x._internalType,T=x._outputType,A=x._mimeType;x.on("data",function(C,N){E.push(C),v&&v(N)}).on("error",function(C){E=[],b(C)}).on("end",function(){try{var C=(function(N,F,k){switch(N){case"blob":return a.newBlob(a.transformTo("arraybuffer",F),k);case"base64":return c.encode(F);default:return a.transformTo(N,F)}})(T,(function(N,F){var k,R=0,I=null,L=0;for(k=0;k<F.length;k++)L+=F[k].length;switch(N){case"string":return F.join("");case"array":return Array.prototype.concat.apply([],F);case"uint8array":for(I=new Uint8Array(L),k=0;k<F.length;k++)I.set(F[k],R),R+=F[k].length;return I;case"nodebuffer":return Buffer.concat(F);default:throw new Error("concat : unsupported type '"+N+"'")}})(w,E),A);y(C)}catch(N){b(N)}E=[]}).resume()})}function p(x,v,y){var b=v;switch(v){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=v,this._mimeType=y,a.checkSupport(b),this._worker=x.pipe(new s(b)),x.lock()}catch(E){this._worker=new l("error"),this._worker.error(E)}}p.prototype={accumulate:function(x){return g(this,x)},on:function(x,v){var y=this;return x==="data"?this._worker.on(x,function(b){v.call(y,b.data,b.meta)}):this._worker.on(x,function(){a.delay(v,arguments,y)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var 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"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return s.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var v,y,b,E,w,T=x.length,A=0;for(E=0;E<T;E++)(64512&(y=x.charCodeAt(E)))==55296&&E+1<T&&(64512&(b=x.charCodeAt(E+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),E++),A+=y<128?1:y<2048?2:y<65536?3:4;for(v=s.uint8array?new Uint8Array(A):new Array(A),E=w=0;w<A;E++)(64512&(y=x.charCodeAt(E)))==55296&&E+1<T&&(64512&(b=x.charCodeAt(E+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),E++),y<128?v[w++]=y:(y<2048?v[w++]=192|y>>>6:(y<65536?v[w++]=224|y>>>12:(v[w++]=240|y>>>18,v[w++]=128|y>>>12&63),v[w++]=128|y>>>6&63),v[w++]=128|63&y);return v})(p)},i.utf8decode=function(p){return s.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var v,y,b,E,w=x.length,T=new Array(2*w);for(v=y=0;v<w;)if((b=x[v++])<128)T[y++]=b;else if(4<(E=u[b]))T[y++]=65533,v+=E-1;else{for(b&=E===2?31:E===3?15:7;1<E&&v<w;)b=b<<6|63&x[v++],E--;1<E?T[y++]=65533:b<65536?T[y++]=b:(b-=65536,T[y++]=55296|b>>10&1023,T[y++]=56320|1023&b)}return T.length!==y&&(T.subarray?T=T.subarray(0,y):T.length=y),a.applyFromCharCode(T)})(p=a.transformTo(s.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var x=a.transformTo(s.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=x;(x=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),x.set(v,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var y=(function(E,w){var T;for((w=w||E.length)>E.length&&(w=E.length),T=w-1;0<=T&&(192&E[T])==128;)T--;return T<0||T===0?w:T+u[E[T]]>w?T:w})(x),b=x;y!==x.length&&(s.uint8array?(b=x.subarray(0,y),this.leftOver=x.subarray(y,x.length)):(b=x.slice(0,y),this.leftOver=x.slice(y,x.length))),this.push({data:i.utf8decode(b),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(g,c),g.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),s=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(v){return v}function d(v,y){for(var b=0;b<v.length;++b)y[b]=255&v.charCodeAt(b);return y}n("setimmediate"),i.newBlob=function(v,y){i.checkSupport("blob");try{return new Blob([v],{type:y})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(v),b.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,y,b){var E=[],w=0,T=v.length;if(T<=b)return String.fromCharCode.apply(null,v);for(;w<T;)y==="array"||y==="nodebuffer"?E.push(String.fromCharCode.apply(null,v.slice(w,Math.min(w+b,T)))):E.push(String.fromCharCode.apply(null,v.subarray(w,Math.min(w+b,T)))),w+=b;return E.join("")},stringifyByChar:function(v){for(var y="",b=0;b<v.length;b++)y+=String.fromCharCode(v[b]);return y},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function g(v){var y=65536,b=i.getTypeOf(v),E=!0;if(b==="uint8array"?E=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<y;)try{return f.stringifyByChunk(v,b,y)}catch{y=Math.floor(y/2)}return f.stringifyByChar(v)}function p(v,y){for(var b=0;b<v.length;b++)y[b]=v[b];return y}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return x.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,l.allocBuffer(v.length))}},x.array={string:g,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(v)}},x.arraybuffer={string:function(v){return g(new Uint8Array(v))},array:function(v){return p(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(new Uint8Array(v))}},x.uint8array={string:g,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return l.newBufferFrom(v)}},x.nodebuffer={string:g,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return x.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,y){if(y=y||"",!v)return y;i.checkSupport(v);var b=i.getTypeOf(y);return x[b][v](y)},i.resolve=function(v){for(var y=v.split("/"),b=[],E=0;E<y.length;E++){var w=y[E];w==="."||w===""&&E!==0&&E!==y.length-1||(w===".."?b.pop():b.push(w))}return b.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var y,b,E="";for(b=0;b<(v||"").length;b++)E+="\\x"+((y=v.charCodeAt(b))<16?"0":"")+y.toString(16).toUpperCase();return E},i.delay=function(v,y,b){setImmediate(function(){v.apply(b||null,y||[])})},i.inherits=function(v,y){function b(){}b.prototype=y.prototype,v.prototype=new b},i.extend=function(){var v,y,b={};for(v=0;v<arguments.length;v++)for(y in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],y)&&b[y]===void 0&&(b[y]=arguments[v][y]);return b},i.prepareContent=function(v,y,b,E,w){return c.Promise.resolve(y).then(function(T){return a.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new c.Promise(function(A,C){var N=new FileReader;N.onload=function(F){A(F.target.result)},N.onerror=function(F){C(F.target.error)},N.readAsArrayBuffer(T)}):T}).then(function(T){var A=i.getTypeOf(T);return A?(A==="arraybuffer"?T=i.transformTo("uint8array",T):A==="string"&&(w?T=s.decode(T):b&&E!==!0&&(T=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(T))),T):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(f)+")")}},isSignature:function(f,g){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===g;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",p=s.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),g=this.reader.readInt(4),p=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===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(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=g-p;if(0<x)this.isSignature(g,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(p,x){this.options=p,this.loadOptions=x}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,v;if(p.skip(22),this.fileNameLength=p.readInt(2),v=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(y){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===y)return d[b];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 l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,v,y,b=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<b;)x=p.readInt(2),v=p.readInt(2),y=p.readData(v),this.extraFields[x]={id:x,length:v,value:y};p.setIndex(b)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var v=s.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var b=s.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,v,y){this.name=x,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=v,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var s=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var v=null,y="string";try{if(!x)throw new Error("No output type specified.");var b=(y=x.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),v=this._decompressWorker();var E=!this._dataBinary;E&&!b&&(v=v.pipe(new c.Utf8EncodeWorker)),!E&&b&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(w){(v=new d("error")).error(w)}return new s(v,y,"")},async:function(x,v){return this.internalStream(x).accumulate(v)},nodeStream:function(x,v){return this.internalStream(x||"nodebuffer").toNodejsStream(v)},_compressWorker:function(x,v){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,x,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)a.prototype[f[p]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var s,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),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 v=a.document.createElement("script");v.onreadystatechange=function(){x(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(x,0)};else{var g=new a.MessageChannel;g.port1.onmessage=x,s=function(){g.port2.postMessage(0)}}var p=[];function x(){var v,y;l=!0;for(var b=p.length;b;){for(y=p,p=[],v=-1;++v<b;)y[v]();b=p.length}l=!1}r.exports=function(v){p.push(v)!==1||l||s()}}).call(this,typeof wv<"u"?wv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function s(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==s&&v(this,b)}function g(b,E,w){this.promise=b,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(b,E,w){a(function(){var T;try{T=E(w)}catch(A){return l.reject(b,A)}T===b?l.reject(b,new TypeError("Cannot resolve promise with itself")):l.resolve(b,T)})}function x(b){var E=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof E=="function")return function(){E.apply(b,arguments)}}function v(b,E){var w=!1;function T(N){w||(w=!0,l.reject(b,N))}function A(N){w||(w=!0,l.resolve(b,N))}var C=y(function(){E(A,T)});C.status==="error"&&T(C.value)}function y(b,E){var w={};try{w.value=b(E),w.status="success"}catch(T){w.status="error",w.value=T}return w}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(b()).then(function(){return w})},function(w){return E.resolve(b()).then(function(){throw w})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,E){if(typeof b!="function"&&this.state===u||typeof E!="function"&&this.state===c)return this;var w=new this.constructor(s);return this.state!==d?p(w,this.state===u?b:E,this.outcome):this.queue.push(new g(w,b,E)),w},g.prototype.callFulfilled=function(b){l.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){p(this.promise,this.onFulfilled,b)},g.prototype.callRejected=function(b){l.reject(this.promise,b)},g.prototype.otherCallRejected=function(b){p(this.promise,this.onRejected,b)},l.resolve=function(b,E){var w=y(x,E);if(w.status==="error")return l.reject(b,w.value);var T=w.value;if(T)v(b,T);else{b.state=u,b.outcome=E;for(var A=-1,C=b.queue.length;++A<C;)b.queue[A].callFulfilled(E)}return b},l.reject=function(b,E){b.state=c,b.outcome=E;for(var w=-1,T=b.queue.length;++w<T;)b.queue[w].callRejected(E);return b},f.resolve=function(b){return b instanceof this?b:l.resolve(new this(s),b)},f.reject=function(b){var E=new this(s);return l.reject(E,b)},f.all=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=b.length,T=!1;if(!w)return this.resolve([]);for(var A=new Array(w),C=0,N=-1,F=new this(s);++N<w;)k(b[N],N);return F;function k(R,I){E.resolve(R).then(function(L){A[I]=L,++C!==w||T||(T=!0,l.resolve(F,A))},function(L){T||(T=!0,l.reject(F,L))})}},f.race=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=b.length,T=!1;if(!w)return this.resolve([]);for(var A=-1,C=new this(s);++A<w;)N=b[A],E.resolve(N).then(function(F){T||(T=!0,l.resolve(C,F))},function(F){T||(T=!0,l.reject(C,F))});var N;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),s=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,p=0,x=8;function v(b){if(!(this instanceof v))return new v(b);this.options=s.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},b||{});var E=this.options;E.raw&&0<E.windowBits?E.windowBits=-E.windowBits:E.gzip&&0<E.windowBits&&E.windowBits<16&&(E.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(w!==f)throw new Error(c[w]);if(E.header&&a.deflateSetHeader(this.strm,E.header),E.dictionary){var T;if(T=typeof E.dictionary=="string"?l.string2buf(E.dictionary):d.call(E.dictionary)==="[object ArrayBuffer]"?new Uint8Array(E.dictionary):E.dictionary,(w=a.deflateSetDictionary(this.strm,T))!==f)throw new Error(c[w]);this._dict_set=!0}}function y(b,E){var w=new v(E);if(w.push(b,!0),w.err)throw w.msg||c[w.err];return w.result}v.prototype.push=function(b,E){var w,T,A=this.strm,C=this.options.chunkSize;if(this.ended)return!1;T=E===~~E?E:E===!0?4:0,typeof b=="string"?A.input=l.string2buf(b):d.call(b)==="[object ArrayBuffer]"?A.input=new Uint8Array(b):A.input=b,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new s.Buf8(C),A.next_out=0,A.avail_out=C),(w=a.deflate(A,T))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);A.avail_out!==0&&(A.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(s.shrinkBuf(A.output,A.next_out))):this.onData(s.shrinkBuf(A.output,A.next_out)))}while((0<A.avail_in||A.avail_out===0)&&w!==1);return T===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):T!==2||(this.onEnd(f),!(A.avail_out=0))},v.prototype.onData=function(b){this.chunks.push(b)},v.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Deflate=v,i.deflate=y,i.deflateRaw=function(b,E){return(E=E||{}).raw=!0,y(b,E)},i.gzip=function(b,E){return(E=E||{}).gzip=!0,y(b,E)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),s=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function p(v){if(!(this instanceof p))return new p(v);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},v||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||v&&v.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=a.inflateInit2(this.strm,y.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(v,y){var b=new p(y);if(b.push(v,!0),b.err)throw b.msg||u[b.err];return b.result}p.prototype.push=function(v,y){var b,E,w,T,A,C,N=this.strm,F=this.options.chunkSize,k=this.options.dictionary,R=!1;if(this.ended)return!1;E=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?N.input=l.binstring2buf(v):g.call(v)==="[object ArrayBuffer]"?N.input=new Uint8Array(v):N.input=v,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new s.Buf8(F),N.next_out=0,N.avail_out=F),(b=a.inflate(N,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&k&&(C=typeof k=="string"?l.string2buf(k):g.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,b=a.inflateSetDictionary(this.strm,C)),b===c.Z_BUF_ERROR&&R===!0&&(b=c.Z_OK,R=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&b!==c.Z_STREAM_END&&(N.avail_in!==0||E!==c.Z_FINISH&&E!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=l.utf8border(N.output,N.next_out),T=N.next_out-w,A=l.buf2string(N.output,w),N.next_out=T,N.avail_out=F-T,T&&s.arraySet(N.output,N.output,w,T,0),this.onData(A)):this.onData(s.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(R=!0)}while((0<N.avail_in||N.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(b=a.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):E!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(N.avail_out=0))},p.prototype.onData=function(v){this.chunks.push(v)},p.prototype.onEnd=function(v){v===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Inflate=p,i.inflate=x,i.inflateRaw=function(v,y){return(y=y||{}).raw=!0,x(v,y)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var s={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){var u,d,f,g,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)p=c[u],x.set(p,g),g+=p.length;return x}},l={arraySet:function(c,u,d,f,g){for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),s=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&l||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var p="",x=0;x<g;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var g,p,x,v,y,b=f.length,E=0;for(v=0;v<b;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),E+=p<128?1:p<2048?2:p<65536?3:4;for(g=new a.Buf8(E),v=y=0;y<E;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),p<128?g[y++]=p:(p<2048?g[y++]=192|p>>>6:(p<65536?g[y++]=224|p>>>12:(g[y++]=240|p>>>18,g[y++]=128|p>>>12&63),g[y++]=128|p>>>6&63),g[y++]=128|63&p);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new a.Buf8(f.length),p=0,x=g.length;p<x;p++)g[p]=f.charCodeAt(p);return g},i.buf2string=function(f,g){var p,x,v,y,b=g||f.length,E=new Array(2*b);for(p=x=0;p<b;)if((v=f[p++])<128)E[x++]=v;else if(4<(y=c[v]))E[x++]=65533,p+=y-1;else{for(v&=y===2?31:y===3?15:7;1<y&&p<b;)v=v<<6|63&f[p++],y--;1<y?E[x++]=65533:v<65536?E[x++]=v:(v-=65536,E[x++]=55296|v>>10&1023,E[x++]=56320|1023&v)}return d(E,x)},i.utf8border=function(f,g){var p;for((g=g||f.length)>f.length&&(g=f.length),p=g-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?g:p+c[f[p]]>g?p:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,s,l,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+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,l=[],c=0;c<256;c++){s=c;for(var u=0;u<8;u++)s=1&s?3988292384^s>>>1:s>>>1;l[c]=s}return l})();r.exports=function(s,l,c,u){var d=a,f=u+c;s^=-1;for(var g=u;g<f;g++)s=s>>>8^d[255&(s^l[g])];return-1^s}},{}],46:[function(n,r,i){var a,s=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,p=0,x=-2,v=-1,y=4,b=2,E=8,w=9,T=286,A=30,C=19,N=2*T+1,F=15,k=3,R=258,I=R+k+1,L=42,q=113,j=1,V=2,K=3,W=4;function J(z,H){return z.msg=d[H],H}function ee(z){return(z<<1)-(4<z?9:0)}function Z(z){for(var H=z.length;0<=--H;)z[H]=0}function B(z){var H=z.state,re=H.pending;re>z.avail_out&&(re=z.avail_out),re!==0&&(s.arraySet(z.output,H.pending_buf,H.pending_out,re,z.next_out),z.next_out+=re,H.pending_out+=re,z.total_out+=re,z.avail_out-=re,H.pending-=re,H.pending===0&&(H.pending_out=0))}function G(z,H){l._tr_flush_block(z,0<=z.block_start?z.block_start:-1,z.strstart-z.block_start,H),z.block_start=z.strstart,B(z.strm)}function Q(z,H){z.pending_buf[z.pending++]=H}function te(z,H){z.pending_buf[z.pending++]=H>>>8&255,z.pending_buf[z.pending++]=255&H}function he(z,H){var re,$,Y=z.max_chain_length,se=z.strstart,ue=z.prev_length,Ee=z.nice_match,Me=z.strstart>z.w_size-I?z.strstart-(z.w_size-I):0,U=z.window,O=z.w_mask,ne=z.prev,be=z.strstart+R,ye=U[se+ue-1],_e=U[se+ue];z.prev_length>=z.good_match&&(Y>>=2),Ee>z.lookahead&&(Ee=z.lookahead);do if(U[(re=H)+ue]===_e&&U[re+ue-1]===ye&&U[re]===U[se]&&U[++re]===U[se+1]){se+=2,re++;do;while(U[++se]===U[++re]&&U[++se]===U[++re]&&U[++se]===U[++re]&&U[++se]===U[++re]&&U[++se]===U[++re]&&U[++se]===U[++re]&&U[++se]===U[++re]&&U[++se]===U[++re]&&se<be);if($=R-(be-se),se=be-R,ue<$){if(z.match_start=H,Ee<=(ue=$))break;ye=U[se+ue-1],_e=U[se+ue]}}while((H=ne[H&O])>Me&&--Y!=0);return ue<=z.lookahead?ue:z.lookahead}function oe(z){var H,re,$,Y,se,ue,Ee,Me,U,O,ne=z.w_size;do{if(Y=z.window_size-z.lookahead-z.strstart,z.strstart>=ne+(ne-I)){for(s.arraySet(z.window,z.window,ne,ne,0),z.match_start-=ne,z.strstart-=ne,z.block_start-=ne,H=re=z.hash_size;$=z.head[--H],z.head[H]=ne<=$?$-ne:0,--re;);for(H=re=ne;$=z.prev[--H],z.prev[H]=ne<=$?$-ne:0,--re;);Y+=ne}if(z.strm.avail_in===0)break;if(ue=z.strm,Ee=z.window,Me=z.strstart+z.lookahead,U=Y,O=void 0,O=ue.avail_in,U<O&&(O=U),re=O===0?0:(ue.avail_in-=O,s.arraySet(Ee,ue.input,ue.next_in,O,Me),ue.state.wrap===1?ue.adler=c(ue.adler,Ee,O,Me):ue.state.wrap===2&&(ue.adler=u(ue.adler,Ee,O,Me)),ue.next_in+=O,ue.total_in+=O,O),z.lookahead+=re,z.lookahead+z.insert>=k)for(se=z.strstart-z.insert,z.ins_h=z.window[se],z.ins_h=(z.ins_h<<z.hash_shift^z.window[se+1])&z.hash_mask;z.insert&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[se+k-1])&z.hash_mask,z.prev[se&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=se,se++,z.insert--,!(z.lookahead+z.insert<k)););}while(z.lookahead<I&&z.strm.avail_in!==0)}function xe(z,H){for(var re,$;;){if(z.lookahead<I){if(oe(z),z.lookahead<I&&H===f)return j;if(z.lookahead===0)break}if(re=0,z.lookahead>=k&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,re=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),re!==0&&z.strstart-re<=z.w_size-I&&(z.match_length=he(z,re)),z.match_length>=k)if($=l._tr_tally(z,z.strstart-z.match_start,z.match_length-k),z.lookahead-=z.match_length,z.match_length<=z.max_lazy_match&&z.lookahead>=k){for(z.match_length--;z.strstart++,z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,re=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart,--z.match_length!=0;);z.strstart++}else z.strstart+=z.match_length,z.match_length=0,z.ins_h=z.window[z.strstart],z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+1])&z.hash_mask;else $=l._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++;if($&&(G(z,!1),z.strm.avail_out===0))return j}return z.insert=z.strstart<k-1?z.strstart:k-1,H===g?(G(z,!0),z.strm.avail_out===0?K:W):z.last_lit&&(G(z,!1),z.strm.avail_out===0)?j:V}function Te(z,H){for(var re,$,Y;;){if(z.lookahead<I){if(oe(z),z.lookahead<I&&H===f)return j;if(z.lookahead===0)break}if(re=0,z.lookahead>=k&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,re=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),z.prev_length=z.match_length,z.prev_match=z.match_start,z.match_length=k-1,re!==0&&z.prev_length<z.max_lazy_match&&z.strstart-re<=z.w_size-I&&(z.match_length=he(z,re),z.match_length<=5&&(z.strategy===1||z.match_length===k&&4096<z.strstart-z.match_start)&&(z.match_length=k-1)),z.prev_length>=k&&z.match_length<=z.prev_length){for(Y=z.strstart+z.lookahead-k,$=l._tr_tally(z,z.strstart-1-z.prev_match,z.prev_length-k),z.lookahead-=z.prev_length-1,z.prev_length-=2;++z.strstart<=Y&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,re=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),--z.prev_length!=0;);if(z.match_available=0,z.match_length=k-1,z.strstart++,$&&(G(z,!1),z.strm.avail_out===0))return j}else if(z.match_available){if(($=l._tr_tally(z,0,z.window[z.strstart-1]))&&G(z,!1),z.strstart++,z.lookahead--,z.strm.avail_out===0)return j}else z.match_available=1,z.strstart++,z.lookahead--}return z.match_available&&($=l._tr_tally(z,0,z.window[z.strstart-1]),z.match_available=0),z.insert=z.strstart<k-1?z.strstart:k-1,H===g?(G(z,!0),z.strm.avail_out===0?K:W):z.last_lit&&(G(z,!1),z.strm.avail_out===0)?j:V}function me(z,H,re,$,Y){this.good_length=z,this.max_lazy=H,this.nice_length=re,this.max_chain=$,this.func=Y}function ce(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=E,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*N),this.dyn_dtree=new s.Buf16(2*(2*A+1)),this.bl_tree=new s.Buf16(2*(2*C+1)),Z(this.dyn_ltree),Z(this.dyn_dtree),Z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(F+1),this.heap=new s.Buf16(2*T+1),Z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*T+1),Z(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 Ce(z){var H;return z&&z.state?(z.total_in=z.total_out=0,z.data_type=b,(H=z.state).pending=0,H.pending_out=0,H.wrap<0&&(H.wrap=-H.wrap),H.status=H.wrap?L:q,z.adler=H.wrap===2?0:1,H.last_flush=f,l._tr_init(H),p):J(z,x)}function fe(z){var H=Ce(z);return H===p&&(function(re){re.window_size=2*re.w_size,Z(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=k-1,re.match_available=0,re.ins_h=0})(z.state),H}function Ie(z,H,re,$,Y,se){if(!z)return x;var ue=1;if(H===v&&(H=6),$<0?(ue=0,$=-$):15<$&&(ue=2,$-=16),Y<1||w<Y||re!==E||$<8||15<$||H<0||9<H||se<0||y<se)return J(z,x);$===8&&($=9);var Ee=new ce;return(z.state=Ee).strm=z,Ee.wrap=ue,Ee.gzhead=null,Ee.w_bits=$,Ee.w_size=1<<Ee.w_bits,Ee.w_mask=Ee.w_size-1,Ee.hash_bits=Y+7,Ee.hash_size=1<<Ee.hash_bits,Ee.hash_mask=Ee.hash_size-1,Ee.hash_shift=~~((Ee.hash_bits+k-1)/k),Ee.window=new s.Buf8(2*Ee.w_size),Ee.head=new s.Buf16(Ee.hash_size),Ee.prev=new s.Buf16(Ee.w_size),Ee.lit_bufsize=1<<Y+6,Ee.pending_buf_size=4*Ee.lit_bufsize,Ee.pending_buf=new s.Buf8(Ee.pending_buf_size),Ee.d_buf=1*Ee.lit_bufsize,Ee.l_buf=3*Ee.lit_bufsize,Ee.level=H,Ee.strategy=se,Ee.method=re,fe(z)}a=[new me(0,0,0,0,function(z,H){var re=65535;for(re>z.pending_buf_size-5&&(re=z.pending_buf_size-5);;){if(z.lookahead<=1){if(oe(z),z.lookahead===0&&H===f)return j;if(z.lookahead===0)break}z.strstart+=z.lookahead,z.lookahead=0;var $=z.block_start+re;if((z.strstart===0||z.strstart>=$)&&(z.lookahead=z.strstart-$,z.strstart=$,G(z,!1),z.strm.avail_out===0)||z.strstart-z.block_start>=z.w_size-I&&(G(z,!1),z.strm.avail_out===0))return j}return z.insert=0,H===g?(G(z,!0),z.strm.avail_out===0?K:W):(z.strstart>z.block_start&&(G(z,!1),z.strm.avail_out),j)}),new me(4,4,8,4,xe),new me(4,5,16,8,xe),new me(4,6,32,32,xe),new me(4,4,16,16,Te),new me(8,16,32,32,Te),new me(8,16,128,128,Te),new me(8,32,128,256,Te),new me(32,128,258,1024,Te),new me(32,258,258,4096,Te)],i.deflateInit=function(z,H){return Ie(z,H,E,15,8,0)},i.deflateInit2=Ie,i.deflateReset=fe,i.deflateResetKeep=Ce,i.deflateSetHeader=function(z,H){return z&&z.state?z.state.wrap!==2?x:(z.state.gzhead=H,p):x},i.deflate=function(z,H){var re,$,Y,se;if(!z||!z.state||5<H||H<0)return z?J(z,x):x;if($=z.state,!z.output||!z.input&&z.avail_in!==0||$.status===666&&H!==g)return J(z,z.avail_out===0?-5:x);if($.strm=z,re=$.last_flush,$.last_flush=H,$.status===L)if($.wrap===2)z.adler=0,Q($,31),Q($,139),Q($,8),$.gzhead?(Q($,($.gzhead.text?1:0)+($.gzhead.hcrc?2:0)+($.gzhead.extra?4:0)+($.gzhead.name?8:0)+($.gzhead.comment?16:0)),Q($,255&$.gzhead.time),Q($,$.gzhead.time>>8&255),Q($,$.gzhead.time>>16&255),Q($,$.gzhead.time>>24&255),Q($,$.level===9?2:2<=$.strategy||$.level<2?4:0),Q($,255&$.gzhead.os),$.gzhead.extra&&$.gzhead.extra.length&&(Q($,255&$.gzhead.extra.length),Q($,$.gzhead.extra.length>>8&255)),$.gzhead.hcrc&&(z.adler=u(z.adler,$.pending_buf,$.pending,0)),$.gzindex=0,$.status=69):(Q($,0),Q($,0),Q($,0),Q($,0),Q($,0),Q($,$.level===9?2:2<=$.strategy||$.level<2?4:0),Q($,3),$.status=q);else{var ue=E+($.w_bits-8<<4)<<8;ue|=(2<=$.strategy||$.level<2?0:$.level<6?1:$.level===6?2:3)<<6,$.strstart!==0&&(ue|=32),ue+=31-ue%31,$.status=q,te($,ue),$.strstart!==0&&(te($,z.adler>>>16),te($,65535&z.adler)),z.adler=1}if($.status===69)if($.gzhead.extra){for(Y=$.pending;$.gzindex<(65535&$.gzhead.extra.length)&&($.pending!==$.pending_buf_size||($.gzhead.hcrc&&$.pending>Y&&(z.adler=u(z.adler,$.pending_buf,$.pending-Y,Y)),B(z),Y=$.pending,$.pending!==$.pending_buf_size));)Q($,255&$.gzhead.extra[$.gzindex]),$.gzindex++;$.gzhead.hcrc&&$.pending>Y&&(z.adler=u(z.adler,$.pending_buf,$.pending-Y,Y)),$.gzindex===$.gzhead.extra.length&&($.gzindex=0,$.status=73)}else $.status=73;if($.status===73)if($.gzhead.name){Y=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>Y&&(z.adler=u(z.adler,$.pending_buf,$.pending-Y,Y)),B(z),Y=$.pending,$.pending===$.pending_buf_size)){se=1;break}se=$.gzindex<$.gzhead.name.length?255&$.gzhead.name.charCodeAt($.gzindex++):0,Q($,se)}while(se!==0);$.gzhead.hcrc&&$.pending>Y&&(z.adler=u(z.adler,$.pending_buf,$.pending-Y,Y)),se===0&&($.gzindex=0,$.status=91)}else $.status=91;if($.status===91)if($.gzhead.comment){Y=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>Y&&(z.adler=u(z.adler,$.pending_buf,$.pending-Y,Y)),B(z),Y=$.pending,$.pending===$.pending_buf_size)){se=1;break}se=$.gzindex<$.gzhead.comment.length?255&$.gzhead.comment.charCodeAt($.gzindex++):0,Q($,se)}while(se!==0);$.gzhead.hcrc&&$.pending>Y&&(z.adler=u(z.adler,$.pending_buf,$.pending-Y,Y)),se===0&&($.status=103)}else $.status=103;if($.status===103&&($.gzhead.hcrc?($.pending+2>$.pending_buf_size&&B(z),$.pending+2<=$.pending_buf_size&&(Q($,255&z.adler),Q($,z.adler>>8&255),z.adler=0,$.status=q)):$.status=q),$.pending!==0){if(B(z),z.avail_out===0)return $.last_flush=-1,p}else if(z.avail_in===0&&ee(H)<=ee(re)&&H!==g)return J(z,-5);if($.status===666&&z.avail_in!==0)return J(z,-5);if(z.avail_in!==0||$.lookahead!==0||H!==f&&$.status!==666){var Ee=$.strategy===2?(function(Me,U){for(var O;;){if(Me.lookahead===0&&(oe(Me),Me.lookahead===0)){if(U===f)return j;break}if(Me.match_length=0,O=l._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++,O&&(G(Me,!1),Me.strm.avail_out===0))return j}return Me.insert=0,U===g?(G(Me,!0),Me.strm.avail_out===0?K:W):Me.last_lit&&(G(Me,!1),Me.strm.avail_out===0)?j:V})($,H):$.strategy===3?(function(Me,U){for(var O,ne,be,ye,_e=Me.window;;){if(Me.lookahead<=R){if(oe(Me),Me.lookahead<=R&&U===f)return j;if(Me.lookahead===0)break}if(Me.match_length=0,Me.lookahead>=k&&0<Me.strstart&&(ne=_e[be=Me.strstart-1])===_e[++be]&&ne===_e[++be]&&ne===_e[++be]){ye=Me.strstart+R;do;while(ne===_e[++be]&&ne===_e[++be]&&ne===_e[++be]&&ne===_e[++be]&&ne===_e[++be]&&ne===_e[++be]&&ne===_e[++be]&&ne===_e[++be]&&be<ye);Me.match_length=R-(ye-be),Me.match_length>Me.lookahead&&(Me.match_length=Me.lookahead)}if(Me.match_length>=k?(O=l._tr_tally(Me,1,Me.match_length-k),Me.lookahead-=Me.match_length,Me.strstart+=Me.match_length,Me.match_length=0):(O=l._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++),O&&(G(Me,!1),Me.strm.avail_out===0))return j}return Me.insert=0,U===g?(G(Me,!0),Me.strm.avail_out===0?K:W):Me.last_lit&&(G(Me,!1),Me.strm.avail_out===0)?j:V})($,H):a[$.level].func($,H);if(Ee!==K&&Ee!==W||($.status=666),Ee===j||Ee===K)return z.avail_out===0&&($.last_flush=-1),p;if(Ee===V&&(H===1?l._tr_align($):H!==5&&(l._tr_stored_block($,0,0,!1),H===3&&(Z($.head),$.lookahead===0&&($.strstart=0,$.block_start=0,$.insert=0))),B(z),z.avail_out===0))return $.last_flush=-1,p}return H!==g?p:$.wrap<=0?1:($.wrap===2?(Q($,255&z.adler),Q($,z.adler>>8&255),Q($,z.adler>>16&255),Q($,z.adler>>24&255),Q($,255&z.total_in),Q($,z.total_in>>8&255),Q($,z.total_in>>16&255),Q($,z.total_in>>24&255)):(te($,z.adler>>>16),te($,65535&z.adler)),B(z),0<$.wrap&&($.wrap=-$.wrap),$.pending!==0?p:1)},i.deflateEnd=function(z){var H;return z&&z.state?(H=z.state.status)!==L&&H!==69&&H!==73&&H!==91&&H!==103&&H!==q&&H!==666?J(z,x):(z.state=null,H===q?J(z,-3):p):x},i.deflateSetDictionary=function(z,H){var re,$,Y,se,ue,Ee,Me,U,O=H.length;if(!z||!z.state||(se=(re=z.state).wrap)===2||se===1&&re.status!==L||re.lookahead)return x;for(se===1&&(z.adler=c(z.adler,H,O,0)),re.wrap=0,O>=re.w_size&&(se===0&&(Z(re.head),re.strstart=0,re.block_start=0,re.insert=0),U=new s.Buf8(re.w_size),s.arraySet(U,H,O-re.w_size,re.w_size,0),H=U,O=re.w_size),ue=z.avail_in,Ee=z.next_in,Me=z.input,z.avail_in=O,z.next_in=0,z.input=H,oe(re);re.lookahead>=k;){for($=re.strstart,Y=re.lookahead-(k-1);re.ins_h=(re.ins_h<<re.hash_shift^re.window[$+k-1])&re.hash_mask,re.prev[$&re.w_mask]=re.head[re.ins_h],re.head[re.ins_h]=$,$++,--Y;);re.strstart=$,re.lookahead=k-1,oe(re)}return re.strstart+=re.lookahead,re.block_start=re.strstart,re.insert=re.lookahead,re.lookahead=0,re.match_length=re.prev_length=k-1,re.match_available=0,z.next_in=Ee,z.input=Me,z.avail_in=ue,re.wrap=se,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,s){var l,c,u,d,f,g,p,x,v,y,b,E,w,T,A,C,N,F,k,R,I,L,q,j,V;l=a.state,c=a.next_in,j=a.input,u=c+(a.avail_in-5),d=a.next_out,V=a.output,f=d-(s-a.avail_out),g=d+(a.avail_out-257),p=l.dmax,x=l.wsize,v=l.whave,y=l.wnext,b=l.window,E=l.hold,w=l.bits,T=l.lencode,A=l.distcode,C=(1<<l.lenbits)-1,N=(1<<l.distbits)-1;e:do{w<15&&(E+=j[c++]<<w,w+=8,E+=j[c++]<<w,w+=8),F=T[E&C];t:for(;;){if(E>>>=k=F>>>24,w-=k,(k=F>>>16&255)===0)V[d++]=65535&F;else{if(!(16&k)){if((64&k)==0){F=T[(65535&F)+(E&(1<<k)-1)];continue t}if(32&k){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&F,(k&=15)&&(w<k&&(E+=j[c++]<<w,w+=8),R+=E&(1<<k)-1,E>>>=k,w-=k),w<15&&(E+=j[c++]<<w,w+=8,E+=j[c++]<<w,w+=8),F=A[E&N];n:for(;;){if(E>>>=k=F>>>24,w-=k,!(16&(k=F>>>16&255))){if((64&k)==0){F=A[(65535&F)+(E&(1<<k)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(I=65535&F,w<(k&=15)&&(E+=j[c++]<<w,(w+=8)<k&&(E+=j[c++]<<w,w+=8)),p<(I+=E&(1<<k)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(E>>>=k,w-=k,(k=d-f)<I){if(v<(k=I-k)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(q=b,(L=0)===y){if(L+=x-k,k<R){for(R-=k;V[d++]=b[L++],--k;);L=d-I,q=V}}else if(y<k){if(L+=x+y-k,(k-=y)<R){for(R-=k;V[d++]=b[L++],--k;);if(L=0,y<R){for(R-=k=y;V[d++]=b[L++],--k;);L=d-I,q=V}}}else if(L+=y-k,k<R){for(R-=k;V[d++]=b[L++],--k;);L=d-I,q=V}for(;2<R;)V[d++]=q[L++],V[d++]=q[L++],V[d++]=q[L++],R-=3;R&&(V[d++]=q[L++],1<R&&(V[d++]=q[L++]))}else{for(L=d-I;V[d++]=V[L++],V[d++]=V[L++],V[d++]=V[L++],2<(R-=3););R&&(V[d++]=V[L++],1<R&&(V[d++]=V[L++]))}break}}break}}while(c<u&&d<g);c-=R=w>>3,E&=(1<<(w-=R<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<g?g-d+257:257-(d-g),l.hold=E,l.bits=w}},{}],49:[function(n,r,i){var a=n("../utils/common"),s=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,p=-2,x=1,v=852,y=592;function b(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function E(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(L){var q;return L&&L.state?(q=L.state,L.total_in=L.total_out=q.total=0,L.msg="",q.wrap&&(L.adler=1&q.wrap),q.mode=x,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(v),q.distcode=q.distdyn=new a.Buf32(y),q.sane=1,q.back=-1,g):p}function T(L){var q;return L&&L.state?((q=L.state).wsize=0,q.whave=0,q.wnext=0,w(L)):p}function A(L,q){var j,V;return L&&L.state?(V=L.state,q<0?(j=0,q=-q):(j=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(V.window!==null&&V.wbits!==q&&(V.window=null),V.wrap=j,V.wbits=q,T(L))):p}function C(L,q){var j,V;return L?(V=new E,(L.state=V).window=null,(j=A(L,q))!==g&&(L.state=null),j):p}var N,F,k=!0;function R(L){if(k){var q;for(N=new a.Buf32(512),F=new a.Buf32(32),q=0;q<144;)L.lens[q++]=8;for(;q<256;)L.lens[q++]=9;for(;q<280;)L.lens[q++]=7;for(;q<288;)L.lens[q++]=8;for(u(d,L.lens,0,288,N,0,L.work,{bits:9}),q=0;q<32;)L.lens[q++]=5;u(f,L.lens,0,32,F,0,L.work,{bits:5}),k=!1}L.lencode=N,L.lenbits=9,L.distcode=F,L.distbits=5}function I(L,q,j,V){var K,W=L.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new a.Buf8(W.wsize)),V>=W.wsize?(a.arraySet(W.window,q,j-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(V<(K=W.wsize-W.wnext)&&(K=V),a.arraySet(W.window,q,j-V,K,W.wnext),(V-=K)?(a.arraySet(W.window,q,j-V,V,0),W.wnext=V,W.whave=W.wsize):(W.wnext+=K,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=K))),0}i.inflateReset=T,i.inflateReset2=A,i.inflateResetKeep=w,i.inflateInit=function(L){return C(L,15)},i.inflateInit2=C,i.inflate=function(L,q){var j,V,K,W,J,ee,Z,B,G,Q,te,he,oe,xe,Te,me,ce,Ce,fe,Ie,z,H,re,$,Y=0,se=new a.Buf8(4),ue=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return p;(j=L.state).mode===12&&(j.mode=13),J=L.next_out,K=L.output,Z=L.avail_out,W=L.next_in,V=L.input,ee=L.avail_in,B=j.hold,G=j.bits,Q=ee,te=Z,H=g;e:for(;;)switch(j.mode){case x:if(j.wrap===0){j.mode=13;break}for(;G<16;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(2&j.wrap&&B===35615){se[j.check=0]=255&B,se[1]=B>>>8&255,j.check=l(j.check,se,2,0),G=B=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&B)<<8)+(B>>8))%31){L.msg="incorrect header check",j.mode=30;break}if((15&B)!=8){L.msg="unknown compression method",j.mode=30;break}if(G-=4,z=8+(15&(B>>>=4)),j.wbits===0)j.wbits=z;else if(z>j.wbits){L.msg="invalid window size",j.mode=30;break}j.dmax=1<<z,L.adler=j.check=1,j.mode=512&B?10:12,G=B=0;break;case 2:for(;G<16;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(j.flags=B,(255&j.flags)!=8){L.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){L.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=B>>8&1),512&j.flags&&(se[0]=255&B,se[1]=B>>>8&255,j.check=l(j.check,se,2,0)),G=B=0,j.mode=3;case 3:for(;G<32;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}j.head&&(j.head.time=B),512&j.flags&&(se[0]=255&B,se[1]=B>>>8&255,se[2]=B>>>16&255,se[3]=B>>>24&255,j.check=l(j.check,se,4,0)),G=B=0,j.mode=4;case 4:for(;G<16;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}j.head&&(j.head.xflags=255&B,j.head.os=B>>8),512&j.flags&&(se[0]=255&B,se[1]=B>>>8&255,j.check=l(j.check,se,2,0)),G=B=0,j.mode=5;case 5:if(1024&j.flags){for(;G<16;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}j.length=B,j.head&&(j.head.extra_len=B),512&j.flags&&(se[0]=255&B,se[1]=B>>>8&255,j.check=l(j.check,se,2,0)),G=B=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(ee<(he=j.length)&&(he=ee),he&&(j.head&&(z=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,V,W,he,z)),512&j.flags&&(j.check=l(j.check,V,he,W)),ee-=he,W+=he,j.length-=he),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(ee===0)break e;for(he=0;z=V[W+he++],j.head&&z&&j.length<65536&&(j.head.name+=String.fromCharCode(z)),z&&he<ee;);if(512&j.flags&&(j.check=l(j.check,V,he,W)),ee-=he,W+=he,z)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(ee===0)break e;for(he=0;z=V[W+he++],j.head&&z&&j.length<65536&&(j.head.comment+=String.fromCharCode(z)),z&&he<ee;);if(512&j.flags&&(j.check=l(j.check,V,he,W)),ee-=he,W+=he,z)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;G<16;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(B!==(65535&j.check)){L.msg="header crc mismatch",j.mode=30;break}G=B=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),L.adler=j.check=0,j.mode=12;break;case 10:for(;G<32;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}L.adler=j.check=b(B),G=B=0,j.mode=11;case 11:if(j.havedict===0)return L.next_out=J,L.avail_out=Z,L.next_in=W,L.avail_in=ee,j.hold=B,j.bits=G,2;L.adler=j.check=1,j.mode=12;case 12:if(q===5||q===6)break e;case 13:if(j.last){B>>>=7&G,G-=7&G,j.mode=27;break}for(;G<3;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}switch(j.last=1&B,G-=1,3&(B>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,q!==6)break;B>>>=2,G-=2;break e;case 2:j.mode=17;break;case 3:L.msg="invalid block type",j.mode=30}B>>>=2,G-=2;break;case 14:for(B>>>=7&G,G-=7&G;G<32;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if((65535&B)!=(B>>>16^65535)){L.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&B,G=B=0,j.mode=15,q===6)break e;case 15:j.mode=16;case 16:if(he=j.length){if(ee<he&&(he=ee),Z<he&&(he=Z),he===0)break e;a.arraySet(K,V,W,he,J),ee-=he,W+=he,Z-=he,J+=he,j.length-=he;break}j.mode=12;break;case 17:for(;G<14;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(j.nlen=257+(31&B),B>>>=5,G-=5,j.ndist=1+(31&B),B>>>=5,G-=5,j.ncode=4+(15&B),B>>>=4,G-=4,286<j.nlen||30<j.ndist){L.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;G<3;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}j.lens[ue[j.have++]]=7&B,B>>>=3,G-=3}for(;j.have<19;)j.lens[ue[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,re={bits:j.lenbits},H=u(0,j.lens,0,19,j.lencode,0,j.work,re),j.lenbits=re.bits,H){L.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;me=(Y=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,ce=65535&Y,!((Te=Y>>>24)<=G);){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(ce<16)B>>>=Te,G-=Te,j.lens[j.have++]=ce;else{if(ce===16){for($=Te+2;G<$;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(B>>>=Te,G-=Te,j.have===0){L.msg="invalid bit length repeat",j.mode=30;break}z=j.lens[j.have-1],he=3+(3&B),B>>>=2,G-=2}else if(ce===17){for($=Te+3;G<$;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}G-=Te,z=0,he=3+(7&(B>>>=Te)),B>>>=3,G-=3}else{for($=Te+7;G<$;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}G-=Te,z=0,he=11+(127&(B>>>=Te)),B>>>=7,G-=7}if(j.have+he>j.nlen+j.ndist){L.msg="invalid bit length repeat",j.mode=30;break}for(;he--;)j.lens[j.have++]=z}}if(j.mode===30)break;if(j.lens[256]===0){L.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,re={bits:j.lenbits},H=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,re),j.lenbits=re.bits,H){L.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,re={bits:j.distbits},H=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,re),j.distbits=re.bits,H){L.msg="invalid distances set",j.mode=30;break}if(j.mode=20,q===6)break e;case 20:j.mode=21;case 21:if(6<=ee&&258<=Z){L.next_out=J,L.avail_out=Z,L.next_in=W,L.avail_in=ee,j.hold=B,j.bits=G,c(L,te),J=L.next_out,K=L.output,Z=L.avail_out,W=L.next_in,V=L.input,ee=L.avail_in,B=j.hold,G=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;me=(Y=j.lencode[B&(1<<j.lenbits)-1])>>>16&255,ce=65535&Y,!((Te=Y>>>24)<=G);){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(me&&(240&me)==0){for(Ce=Te,fe=me,Ie=ce;me=(Y=j.lencode[Ie+((B&(1<<Ce+fe)-1)>>Ce)])>>>16&255,ce=65535&Y,!(Ce+(Te=Y>>>24)<=G);){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}B>>>=Ce,G-=Ce,j.back+=Ce}if(B>>>=Te,G-=Te,j.back+=Te,j.length=ce,me===0){j.mode=26;break}if(32&me){j.back=-1,j.mode=12;break}if(64&me){L.msg="invalid literal/length code",j.mode=30;break}j.extra=15&me,j.mode=22;case 22:if(j.extra){for($=j.extra;G<$;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}j.length+=B&(1<<j.extra)-1,B>>>=j.extra,G-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;me=(Y=j.distcode[B&(1<<j.distbits)-1])>>>16&255,ce=65535&Y,!((Te=Y>>>24)<=G);){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if((240&me)==0){for(Ce=Te,fe=me,Ie=ce;me=(Y=j.distcode[Ie+((B&(1<<Ce+fe)-1)>>Ce)])>>>16&255,ce=65535&Y,!(Ce+(Te=Y>>>24)<=G);){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}B>>>=Ce,G-=Ce,j.back+=Ce}if(B>>>=Te,G-=Te,j.back+=Te,64&me){L.msg="invalid distance code",j.mode=30;break}j.offset=ce,j.extra=15&me,j.mode=24;case 24:if(j.extra){for($=j.extra;G<$;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}j.offset+=B&(1<<j.extra)-1,B>>>=j.extra,G-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){L.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(Z===0)break e;if(he=te-Z,j.offset>he){if((he=j.offset-he)>j.whave&&j.sane){L.msg="invalid distance too far back",j.mode=30;break}oe=he>j.wnext?(he-=j.wnext,j.wsize-he):j.wnext-he,he>j.length&&(he=j.length),xe=j.window}else xe=K,oe=J-j.offset,he=j.length;for(Z<he&&(he=Z),Z-=he,j.length-=he;K[J++]=xe[oe++],--he;);j.length===0&&(j.mode=21);break;case 26:if(Z===0)break e;K[J++]=j.length,Z--,j.mode=21;break;case 27:if(j.wrap){for(;G<32;){if(ee===0)break e;ee--,B|=V[W++]<<G,G+=8}if(te-=Z,L.total_out+=te,j.total+=te,te&&(L.adler=j.check=j.flags?l(j.check,K,te,J-te):s(j.check,K,te,J-te)),te=Z,(j.flags?B:b(B))!==j.check){L.msg="incorrect data check",j.mode=30;break}G=B=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;G<32;){if(ee===0)break e;ee--,B+=V[W++]<<G,G+=8}if(B!==(4294967295&j.total)){L.msg="incorrect length check",j.mode=30;break}G=B=0}j.mode=29;case 29:H=1;break e;case 30:H=-3;break e;case 31:return-4;case 32:default:return p}return L.next_out=J,L.avail_out=Z,L.next_in=W,L.avail_in=ee,j.hold=B,j.bits=G,(j.wsize||te!==L.avail_out&&j.mode<30&&(j.mode<27||q!==4))&&I(L,L.output,L.next_out,te-L.avail_out)?(j.mode=31,-4):(Q-=L.avail_in,te-=L.avail_out,L.total_in+=Q,L.total_out+=te,j.total+=te,j.wrap&&te&&(L.adler=j.check=j.flags?l(j.check,K,te,L.next_out-te):s(j.check,K,te,L.next_out-te)),L.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(Q==0&&te===0||q===4)&&H===g&&(H=-5),H)},i.inflateEnd=function(L){if(!L||!L.state)return p;var q=L.state;return q.window&&(q.window=null),L.state=null,g},i.inflateGetHeader=function(L,q){var j;return L&&L.state?(2&(j=L.state).wrap)==0?p:((j.head=q).done=!1,g):p},i.inflateSetDictionary=function(L,q){var j,V=q.length;return L&&L.state?(j=L.state).wrap!==0&&j.mode!==11?p:j.mode===11&&s(1,q,V,0)!==j.check?-3:I(L,q,V,V)?(j.mode=31,-4):(j.havedict=1,g):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),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],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,p,x,v,y,b){var E,w,T,A,C,N,F,k,R,I=b.bits,L=0,q=0,j=0,V=0,K=0,W=0,J=0,ee=0,Z=0,B=0,G=null,Q=0,te=new a.Buf16(16),he=new a.Buf16(16),oe=null,xe=0;for(L=0;L<=15;L++)te[L]=0;for(q=0;q<p;q++)te[f[g+q]]++;for(K=I,V=15;1<=V&&te[V]===0;V--);if(V<K&&(K=V),V===0)return x[v++]=20971520,x[v++]=20971520,b.bits=1,0;for(j=1;j<V&&te[j]===0;j++);for(K<j&&(K=j),L=ee=1;L<=15;L++)if(ee<<=1,(ee-=te[L])<0)return-1;if(0<ee&&(d===0||V!==1))return-1;for(he[1]=0,L=1;L<15;L++)he[L+1]=he[L]+te[L];for(q=0;q<p;q++)f[g+q]!==0&&(y[he[f[g+q]]++]=q);if(N=d===0?(G=oe=y,19):d===1?(G=s,Q-=257,oe=l,xe-=257,256):(G=c,oe=u,-1),L=j,C=v,J=q=B=0,T=-1,A=(Z=1<<(W=K))-1,d===1&&852<Z||d===2&&592<Z)return 1;for(;;){for(F=L-J,R=y[q]<N?(k=0,y[q]):y[q]>N?(k=oe[xe+y[q]],G[Q+y[q]]):(k=96,0),E=1<<L-J,j=w=1<<W;x[C+(B>>J)+(w-=E)]=F<<24|k<<16|R|0,w!==0;);for(E=1<<L-1;B&E;)E>>=1;if(E!==0?(B&=E-1,B+=E):B=0,q++,--te[L]==0){if(L===V)break;L=f[g+y[q]]}if(K<L&&(B&A)!==T){for(J===0&&(J=K),C+=j,ee=1<<(W=L-J);W+J<V&&!((ee-=te[W+J])<=0);)W++,ee<<=1;if(Z+=1<<W,d===1&&852<Z||d===2&&592<Z)return 1;x[T=B&A]=K<<24|W<<16|C-v|0}}return B!==0&&(x[C+B]=L-J<<24|64<<16|0),b.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,l=1;function c(Y){for(var se=Y.length;0<=--se;)Y[se]=0}var u=0,d=29,f=256,g=f+1+d,p=30,x=19,v=2*g+1,y=15,b=16,E=7,w=256,T=16,A=17,C=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],F=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],I=new Array(2*(g+2));c(I);var L=new Array(2*p);c(L);var q=new Array(512);c(q);var j=new Array(256);c(j);var V=new Array(d);c(V);var K,W,J,ee=new Array(p);function Z(Y,se,ue,Ee,Me){this.static_tree=Y,this.extra_bits=se,this.extra_base=ue,this.elems=Ee,this.max_length=Me,this.has_stree=Y&&Y.length}function B(Y,se){this.dyn_tree=Y,this.max_code=0,this.stat_desc=se}function G(Y){return Y<256?q[Y]:q[256+(Y>>>7)]}function Q(Y,se){Y.pending_buf[Y.pending++]=255&se,Y.pending_buf[Y.pending++]=se>>>8&255}function te(Y,se,ue){Y.bi_valid>b-ue?(Y.bi_buf|=se<<Y.bi_valid&65535,Q(Y,Y.bi_buf),Y.bi_buf=se>>b-Y.bi_valid,Y.bi_valid+=ue-b):(Y.bi_buf|=se<<Y.bi_valid&65535,Y.bi_valid+=ue)}function he(Y,se,ue){te(Y,ue[2*se],ue[2*se+1])}function oe(Y,se){for(var ue=0;ue|=1&Y,Y>>>=1,ue<<=1,0<--se;);return ue>>>1}function xe(Y,se,ue){var Ee,Me,U=new Array(y+1),O=0;for(Ee=1;Ee<=y;Ee++)U[Ee]=O=O+ue[Ee-1]<<1;for(Me=0;Me<=se;Me++){var ne=Y[2*Me+1];ne!==0&&(Y[2*Me]=oe(U[ne]++,ne))}}function Te(Y){var se;for(se=0;se<g;se++)Y.dyn_ltree[2*se]=0;for(se=0;se<p;se++)Y.dyn_dtree[2*se]=0;for(se=0;se<x;se++)Y.bl_tree[2*se]=0;Y.dyn_ltree[2*w]=1,Y.opt_len=Y.static_len=0,Y.last_lit=Y.matches=0}function me(Y){8<Y.bi_valid?Q(Y,Y.bi_buf):0<Y.bi_valid&&(Y.pending_buf[Y.pending++]=Y.bi_buf),Y.bi_buf=0,Y.bi_valid=0}function ce(Y,se,ue,Ee){var Me=2*se,U=2*ue;return Y[Me]<Y[U]||Y[Me]===Y[U]&&Ee[se]<=Ee[ue]}function Ce(Y,se,ue){for(var Ee=Y.heap[ue],Me=ue<<1;Me<=Y.heap_len&&(Me<Y.heap_len&&ce(se,Y.heap[Me+1],Y.heap[Me],Y.depth)&&Me++,!ce(se,Ee,Y.heap[Me],Y.depth));)Y.heap[ue]=Y.heap[Me],ue=Me,Me<<=1;Y.heap[ue]=Ee}function fe(Y,se,ue){var Ee,Me,U,O,ne=0;if(Y.last_lit!==0)for(;Ee=Y.pending_buf[Y.d_buf+2*ne]<<8|Y.pending_buf[Y.d_buf+2*ne+1],Me=Y.pending_buf[Y.l_buf+ne],ne++,Ee===0?he(Y,Me,se):(he(Y,(U=j[Me])+f+1,se),(O=N[U])!==0&&te(Y,Me-=V[U],O),he(Y,U=G(--Ee),ue),(O=F[U])!==0&&te(Y,Ee-=ee[U],O)),ne<Y.last_lit;);he(Y,w,se)}function Ie(Y,se){var ue,Ee,Me,U=se.dyn_tree,O=se.stat_desc.static_tree,ne=se.stat_desc.has_stree,be=se.stat_desc.elems,ye=-1;for(Y.heap_len=0,Y.heap_max=v,ue=0;ue<be;ue++)U[2*ue]!==0?(Y.heap[++Y.heap_len]=ye=ue,Y.depth[ue]=0):U[2*ue+1]=0;for(;Y.heap_len<2;)U[2*(Me=Y.heap[++Y.heap_len]=ye<2?++ye:0)]=1,Y.depth[Me]=0,Y.opt_len--,ne&&(Y.static_len-=O[2*Me+1]);for(se.max_code=ye,ue=Y.heap_len>>1;1<=ue;ue--)Ce(Y,U,ue);for(Me=be;ue=Y.heap[1],Y.heap[1]=Y.heap[Y.heap_len--],Ce(Y,U,1),Ee=Y.heap[1],Y.heap[--Y.heap_max]=ue,Y.heap[--Y.heap_max]=Ee,U[2*Me]=U[2*ue]+U[2*Ee],Y.depth[Me]=(Y.depth[ue]>=Y.depth[Ee]?Y.depth[ue]:Y.depth[Ee])+1,U[2*ue+1]=U[2*Ee+1]=Me,Y.heap[1]=Me++,Ce(Y,U,1),2<=Y.heap_len;);Y.heap[--Y.heap_max]=Y.heap[1],(function(_e,We){var Ve,Ye,lt,de,ae,ze,Ue=We.dyn_tree,et=We.max_code,dt=We.stat_desc.static_tree,pe=We.stat_desc.has_stree,nt=We.stat_desc.extra_bits,ve=We.stat_desc.extra_base,He=We.stat_desc.max_length,je=0;for(de=0;de<=y;de++)_e.bl_count[de]=0;for(Ue[2*_e.heap[_e.heap_max]+1]=0,Ve=_e.heap_max+1;Ve<v;Ve++)He<(de=Ue[2*Ue[2*(Ye=_e.heap[Ve])+1]+1]+1)&&(de=He,je++),Ue[2*Ye+1]=de,et<Ye||(_e.bl_count[de]++,ae=0,ve<=Ye&&(ae=nt[Ye-ve]),ze=Ue[2*Ye],_e.opt_len+=ze*(de+ae),pe&&(_e.static_len+=ze*(dt[2*Ye+1]+ae)));if(je!==0){do{for(de=He-1;_e.bl_count[de]===0;)de--;_e.bl_count[de]--,_e.bl_count[de+1]+=2,_e.bl_count[He]--,je-=2}while(0<je);for(de=He;de!==0;de--)for(Ye=_e.bl_count[de];Ye!==0;)et<(lt=_e.heap[--Ve])||(Ue[2*lt+1]!==de&&(_e.opt_len+=(de-Ue[2*lt+1])*Ue[2*lt],Ue[2*lt+1]=de),Ye--)}})(Y,se),xe(U,ye,Y.bl_count)}function z(Y,se,ue){var Ee,Me,U=-1,O=se[1],ne=0,be=7,ye=4;for(O===0&&(be=138,ye=3),se[2*(ue+1)+1]=65535,Ee=0;Ee<=ue;Ee++)Me=O,O=se[2*(Ee+1)+1],++ne<be&&Me===O||(ne<ye?Y.bl_tree[2*Me]+=ne:Me!==0?(Me!==U&&Y.bl_tree[2*Me]++,Y.bl_tree[2*T]++):ne<=10?Y.bl_tree[2*A]++:Y.bl_tree[2*C]++,U=Me,ye=(ne=0)===O?(be=138,3):Me===O?(be=6,3):(be=7,4))}function H(Y,se,ue){var Ee,Me,U=-1,O=se[1],ne=0,be=7,ye=4;for(O===0&&(be=138,ye=3),Ee=0;Ee<=ue;Ee++)if(Me=O,O=se[2*(Ee+1)+1],!(++ne<be&&Me===O)){if(ne<ye)for(;he(Y,Me,Y.bl_tree),--ne!=0;);else Me!==0?(Me!==U&&(he(Y,Me,Y.bl_tree),ne--),he(Y,T,Y.bl_tree),te(Y,ne-3,2)):ne<=10?(he(Y,A,Y.bl_tree),te(Y,ne-3,3)):(he(Y,C,Y.bl_tree),te(Y,ne-11,7));U=Me,ye=(ne=0)===O?(be=138,3):Me===O?(be=6,3):(be=7,4)}}c(ee);var re=!1;function $(Y,se,ue,Ee){te(Y,(u<<1)+(Ee?1:0),3),(function(Me,U,O,ne){me(Me),Q(Me,O),Q(Me,~O),a.arraySet(Me.pending_buf,Me.window,U,O,Me.pending),Me.pending+=O})(Y,se,ue)}i._tr_init=function(Y){re||((function(){var se,ue,Ee,Me,U,O=new Array(y+1);for(Me=Ee=0;Me<d-1;Me++)for(V[Me]=Ee,se=0;se<1<<N[Me];se++)j[Ee++]=Me;for(j[Ee-1]=Me,Me=U=0;Me<16;Me++)for(ee[Me]=U,se=0;se<1<<F[Me];se++)q[U++]=Me;for(U>>=7;Me<p;Me++)for(ee[Me]=U<<7,se=0;se<1<<F[Me]-7;se++)q[256+U++]=Me;for(ue=0;ue<=y;ue++)O[ue]=0;for(se=0;se<=143;)I[2*se+1]=8,se++,O[8]++;for(;se<=255;)I[2*se+1]=9,se++,O[9]++;for(;se<=279;)I[2*se+1]=7,se++,O[7]++;for(;se<=287;)I[2*se+1]=8,se++,O[8]++;for(xe(I,g+1,O),se=0;se<p;se++)L[2*se+1]=5,L[2*se]=oe(se,5);K=new Z(I,N,f+1,g,y),W=new Z(L,F,0,p,y),J=new Z(new Array(0),k,0,x,E)})(),re=!0),Y.l_desc=new B(Y.dyn_ltree,K),Y.d_desc=new B(Y.dyn_dtree,W),Y.bl_desc=new B(Y.bl_tree,J),Y.bi_buf=0,Y.bi_valid=0,Te(Y)},i._tr_stored_block=$,i._tr_flush_block=function(Y,se,ue,Ee){var Me,U,O=0;0<Y.level?(Y.strm.data_type===2&&(Y.strm.data_type=(function(ne){var be,ye=4093624447;for(be=0;be<=31;be++,ye>>>=1)if(1&ye&&ne.dyn_ltree[2*be]!==0)return s;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return l;for(be=32;be<f;be++)if(ne.dyn_ltree[2*be]!==0)return l;return s})(Y)),Ie(Y,Y.l_desc),Ie(Y,Y.d_desc),O=(function(ne){var be;for(z(ne,ne.dyn_ltree,ne.l_desc.max_code),z(ne,ne.dyn_dtree,ne.d_desc.max_code),Ie(ne,ne.bl_desc),be=x-1;3<=be&&ne.bl_tree[2*R[be]+1]===0;be--);return ne.opt_len+=3*(be+1)+5+5+4,be})(Y),Me=Y.opt_len+3+7>>>3,(U=Y.static_len+3+7>>>3)<=Me&&(Me=U)):Me=U=ue+5,ue+4<=Me&&se!==-1?$(Y,se,ue,Ee):Y.strategy===4||U===Me?(te(Y,2+(Ee?1:0),3),fe(Y,I,L)):(te(Y,4+(Ee?1:0),3),(function(ne,be,ye,_e){var We;for(te(ne,be-257,5),te(ne,ye-1,5),te(ne,_e-4,4),We=0;We<_e;We++)te(ne,ne.bl_tree[2*R[We]+1],3);H(ne,ne.dyn_ltree,be-1),H(ne,ne.dyn_dtree,ye-1)})(Y,Y.l_desc.max_code+1,Y.d_desc.max_code+1,O+1),fe(Y,Y.dyn_ltree,Y.dyn_dtree)),Te(Y),Ee&&me(Y)},i._tr_tally=function(Y,se,ue){return Y.pending_buf[Y.d_buf+2*Y.last_lit]=se>>>8&255,Y.pending_buf[Y.d_buf+2*Y.last_lit+1]=255&se,Y.pending_buf[Y.l_buf+Y.last_lit]=255&ue,Y.last_lit++,se===0?Y.dyn_ltree[2*ue]++:(Y.matches++,se--,Y.dyn_ltree[2*(j[ue]+f+1)]++,Y.dyn_dtree[2*G(se)]++),Y.last_lit===Y.lit_bufsize-1},i._tr_align=function(Y){te(Y,2,3),he(Y,w,I),(function(se){se.bi_valid===16?(Q(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)})(Y)}},{"../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,l){if(!s.setImmediate){var c,u,d,f,g=1,p={},x=!1,v=s.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(s);y=y&&y.setTimeout?y:s,c={}.toString.call(s.process)==="[object process]"?function(T){process.nextTick(function(){E(T)})}:(function(){if(s.postMessage&&!s.importScripts){var T=!0,A=s.onmessage;return s.onmessage=function(){T=!1},s.postMessage("","*"),s.onmessage=A,T}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(T){s.postMessage(f+T,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){E(T.data)},function(T){d.port2.postMessage(T)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(T){var A=v.createElement("script");A.onreadystatechange=function(){E(T),A.onreadystatechange=null,u.removeChild(A),A=null},u.appendChild(A)}):function(T){setTimeout(E,0,T)},y.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var A=new Array(arguments.length-1),C=0;C<A.length;C++)A[C]=arguments[C+1];var N={callback:T,args:A};return p[g]=N,c(g),g++},y.clearImmediate=b}function b(T){delete p[T]}function E(T){if(x)setTimeout(E,0,T);else{var A=p[T];if(A){x=!0;try{(function(C){var N=C.callback,F=C.args;switch(F.length){case 0:N();break;case 1:N(F[0]);break;case 2:N(F[0],F[1]);break;case 3:N(F[0],F[1],F[2]);break;default:N.apply(l,F)}})(A)}finally{b(T),x=!1}}}}function w(T){T.source===s&&typeof T.data=="string"&&T.data.indexOf(f)===0&&E(+T.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof wv<"u"?wv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(lC)),lC.exports}var FDe=IDe();const UDe=bo(FDe);function zDe(t){const e=new hi;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 p$=zDe;async function g$(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],a=[],s=[],l=i.getElementsByTagName("vertex");for(let u=0;u<l.length;u++){const d=l[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 BDe(t){const e=await UDe.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 p=await g.async("string");return i.parseFromString(p,"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 g$(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const l=await a(s);if(!l)return{objects:n,buildItems:r};const c=l.getElementsByTagName("object");for(let d=0;d<c.length;d++){const f=c[d],g=f.getAttribute("id");if(!g)continue;const p=[],x=f.getElementsByTagName("mesh");for(let y=0;y<x.length;y++){const b=x[y],E=[],w=[],T=b.getElementsByTagName("vertex");for(let C=0;C<T.length;C++){const N=T[C];E.push(parseFloat(N.getAttribute("x")||"0"),parseFloat(N.getAttribute("y")||"0"),parseFloat(N.getAttribute("z")||"0"))}const A=b.getElementsByTagName("triangle");for(let C=0;C<A.length;C++){const N=A[C];w.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}E.length>0&&w.length>0&&p.push({vertices:E,triangles:w})}const v=f.getElementsByTagName("component");for(let y=0;y<v.length;y++){const b=v[y],E=b.getAttribute("p:path")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(E){const w=await a(E);if(w){const T=await g$(w),A=b.getAttribute("transform"),C=p$(A);for(const N of T)if(A){const F=[];for(let k=0;k<N.vertices.length;k+=3){const R=new it(N.vertices[k],N.vertices[k+1],N.vertices[k+2]);R.applyMatrix4(C),F.push(R.x,R.y,R.z)}p.push({vertices:F,triangles:N.triangles})}else p.push(N)}}}p.length>0&&n.set(g,{id:g,meshes:p})}const u=l.getElementsByTagName("build");if(u.length>0){const d=u[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const g=d[f],p=g.getAttribute("objectid");if(!p)continue;const x=p$(g.getAttribute("transform"));r.push({objectId:p,transform:x})}}return{objects:n,buildItems:r}}function x$(t){const e=new Dl,n=new Float32Array(t.vertices.length);for(let r=0;r<t.vertices.length;r+=3)n[r]=t.vertices[r],n[r+1]=t.vertices[r+2],n[r+2]=t.vertices[r+1];return e.setAttribute("position",new co(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function HDe({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=M.useRef(null),i=M.useRef(null),a=M.useRef(null),s=M.useRef(null),l=M.useRef(null),[c,u]=M.useState(!0),[d,f]=M.useState(null);M.useEffect(()=>{if(!r.current)return;const x=r.current,v=x.clientWidth,y=x.clientHeight,b=new yke;b.background=new Mn(1710618),a.current=b;const E=new eo(45,v/y,.1,1e4);E.position.set(150,150,150),s.current=E;const w=new _De({antialias:!0});w.setSize(v,y),w.setPixelRatio(window.devicePixelRatio),x.appendChild(w.domElement),i.current=w;const T=new SDe(E,w.domElement);T.enableDamping=!0,T.dampingFactor=.05,l.current=T;const A=new Pke(16777215,.6);b.add(A);const C=new UH(16777215,.8);C.position.set(100,100,100),b.add(C);const N=new UH(16777215,.4);N.position.set(-100,50,-100),b.add(N);const F=Math.max(e.x,e.y),k=Math.ceil(F/16),R=new Rke(F,k,4473924,3355443);b.add(R);const I=new OO(e.x,e.y),L=new jO({color:44610,transparent:!0,opacity:.15,side:ll}),q=new Ml(I,L);q.rotation.x=-Math.PI/2,q.position.y=-.5,b.add(q);let j;const V=()=>{j=requestAnimationFrame(V),T.update(),w.render(b,E)};V(),fetch(t).then(W=>{if(!W.ok)throw new Error("Failed to load file");return W.arrayBuffer()}).then(BDe).then(({objects:W,buildItems:J})=>{if(W.size===0)throw new Error("No meshes found in 3MF file");const ee=new Tke({color:44610,shininess:30,flatShading:!1}),Z=new qx,B=[];if(J.length>0)for(const me of J){const ce=W.get(me.objectId);if(ce)for(const Ce of ce.meshes){const fe=[];for(let z=0;z<Ce.vertices.length;z+=3){const H=new it(Ce.vertices[z],Ce.vertices[z+1],Ce.vertices[z+2]);H.applyMatrix4(me.transform),fe.push(H.x,H.y,H.z)}const Ie=x$({vertices:fe,triangles:Ce.triangles});B.push(Ie)}}else for(const me of W.values())for(const ce of me.meshes){const Ce=x$(ce);B.push(Ce)}if(B.length>0){const me=B.length===1?B[0]:LDe(B,!1);if(me){const ce=new Ml(me,ee);Z.add(ce)}if(B.length>1)for(const ce of B)ce.dispose()}const G=new hf().setFromObject(Z),Q=G.getCenter(new it);Z.position.y=-G.min.y,J.length===0&&(Z.position.x=-Q.x,Z.position.z=-Q.z),b.add(Z);const te=new hf().setFromObject(Z),he=te.getCenter(new it),oe=te.getSize(new it),Te=Math.max(oe.x,oe.y,oe.z)*1.8;E.position.set(he.x+Te*.7,he.y+Te*.5,he.z+Te*.7),T.target.copy(he),T.update(),u(!1)}).catch(W=>{f(W.message),u(!1)});const K=()=>{if(!x)return;const W=x.clientWidth,J=x.clientHeight;E.aspect=W/J,E.updateProjectionMatrix(),w.setSize(W,J)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(j),T.dispose(),w.dispose(),x.removeChild(w.domElement)}},[t,e]);const g=()=>{s.current&&l.current&&(s.current.position.set(150,150,150),l.current.target.set(0,50,0),l.current.update())},p=x=>{s.current&&s.current.position.multiplyScalar(x)};return o.jsxs("div",{className:`relative ${n}`,children:[o.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),c&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsx("p",{className:"text-red-400",children:d})}),!c&&!d&&o.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>p(.8),children:o.jsx(_de,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>p(1.25),children:o.jsx(Mde,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:g,children:o.jsx(ig,{className:"w-4 h-4"})})]})]})}const eE="159",Mm={ROTATE:0,DOLLY:1,PAN:2},Em={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},$De=0,b$=1,VDe=2,YZ=1,GDe=2,mc=3,Md=0,ts=1,vc=2,od=0,mp=1,y$=2,v$=3,_$=4,WDe=5,yh=100,qDe=101,KDe=102,w$=103,S$=104,XDe=200,YDe=201,ZDe=202,QDe=203,XP=204,YP=205,JDe=206,eOe=207,tOe=208,nOe=209,rOe=210,iOe=211,aOe=212,sOe=213,oOe=214,lOe=0,cOe=1,uOe=2,Gw=3,dOe=4,hOe=5,fOe=6,mOe=7,IO=0,pOe=1,gOe=2,ld=0,xOe=1,bOe=2,yOe=3,vOe=4,_Oe=5,ZZ=300,Bp=301,Hp=302,ZP=303,QP=304,tE=306,JP=1e3,Do=1001,ej=1002,na=1003,M$=1004,cC=1005,to=1006,wOe=1007,tb=1008,cd=1009,SOe=1010,MOe=1011,FO=1012,QZ=1013,Ju=1014,Ac=1015,nb=1016,JZ=1017,eQ=1018,Uh=1020,EOe=1021,no=1023,TOe=1024,AOe=1025,zh=1026,$p=1027,NOe=1028,tQ=1029,COe=1030,nQ=1031,rQ=1033,uC=33776,dC=33777,hC=33778,fC=33779,E$=35840,T$=35841,A$=35842,N$=35843,iQ=36196,C$=37492,k$=37496,P$=37808,j$=37809,R$=37810,D$=37811,O$=37812,L$=37813,I$=37814,F$=37815,U$=37816,z$=37817,B$=37818,H$=37819,$$=37820,V$=37821,mC=36492,G$=36494,W$=36495,kOe=36283,q$=36284,K$=36285,X$=36286,aQ=3e3,Bh=3001,POe=3200,jOe=3201,sQ=0,ROe=1,ro="",ra="srgb",Kc="srgb-linear",UO="display-p3",nE="display-p3-linear",Ww="linear",mr="srgb",qw="rec709",Kw="p3",Tm=7680,Y$=519,DOe=512,OOe=513,LOe=514,oQ=515,IOe=516,FOe=517,UOe=518,zOe=519,tj=35044,Z$="300 es",nj=1035,fl=2e3,rb=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 ha=["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 Q$=1234567;const a0=Math.PI/180,ib=180/Math.PI;function Dc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ha[t&255]+ha[t>>8&255]+ha[t>>16&255]+ha[t>>24&255]+"-"+ha[e&255]+ha[e>>8&255]+"-"+ha[e>>16&15|64]+ha[e>>24&255]+"-"+ha[n&63|128]+ha[n>>8&255]+"-"+ha[n>>16&255]+ha[n>>24&255]+ha[r&255]+ha[r>>8&255]+ha[r>>16&255]+ha[r>>24&255]).toLowerCase()}function ia(t,e,n){return Math.max(e,Math.min(n,t))}function zO(t,e){return(t%e+e)%e}function BOe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function HOe(t,e,n){return t!==e?(n-t)/(e-t):0}function s0(t,e,n){return(1-n)*t+n*e}function $Oe(t,e,n,r){return s0(t,e,1-Math.exp(-n*r))}function VOe(t,e=1){return e-Math.abs(zO(t,e*2)-e)}function GOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function WOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function qOe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function KOe(t,e){return t+Math.random()*(e-t)}function XOe(t){return t*(.5-Math.random())}function YOe(t){t!==void 0&&(Q$=t);let e=Q$+=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 ZOe(t){return t*a0}function QOe(t){return t*ib}function rj(t){return(t&t-1)===0&&t!==0}function JOe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Xw(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function eLe(t,e,n,r,i){const a=Math.cos,s=Math.sin,l=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),p=a((r-e)/2),x=s((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*g,l*u);break;case"YZY":t.set(c*g,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*g,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function cl(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 Jn(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 lQ={DEG2RAD:a0,RAD2DEG:ib,generateUUID:Dc,clamp:ia,euclideanModulo:zO,mapLinear:BOe,inverseLerp:HOe,lerp:s0,damp:$Oe,pingpong:VOe,smoothstep:GOe,smootherstep:WOe,randInt:qOe,randFloat:KOe,randFloatSpread:XOe,seededRandom:YOe,degToRad:ZOe,radToDeg:QOe,isPowerOfTwo:rj,ceilPowerOfTwo:JOe,floorPowerOfTwo:Xw,setQuaternionFromProperEuler:eLe,normalize:Jn,denormalize:cl};class Qt{constructor(e=0,n=0){Qt.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(ia(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 gn{constructor(e,n,r,i,a,s,l,c,u){gn.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,l,c,u)}set(e,n,r,i,a,s,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=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],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],v=i[0],y=i[3],b=i[6],E=i[1],w=i[4],T=i[7],A=i[2],C=i[5],N=i[8];return a[0]=s*v+l*E+c*A,a[3]=s*y+l*w+c*C,a[6]=s*b+l*T+c*N,a[1]=u*v+d*E+f*A,a[4]=u*y+d*w+f*C,a[7]=u*b+d*T+f*N,a[2]=g*v+p*E+x*A,a[5]=g*y+p*w+x*C,a[8]=g*b+p*T+x*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],l=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*l*u-r*a*d+r*l*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],l=e[5],c=e[6],u=e[7],d=e[8],f=d*s-l*u,g=l*c-d*a,p=u*a-s*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*l)+s+e,-i*u,i*c,-i*(-u*s+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(pC.makeScale(e,n)),this}rotate(e){return this.premultiply(pC.makeRotation(-e)),this}translate(e,n){return this.premultiply(pC.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 pC=new gn;function cQ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Yw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function tLe(){const t=Yw("canvas");return t.style.display="block",t}const J$={};function o0(t){t in J$||(J$[t]=!0,console.warn(t))}const eV=new gn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),tV=new gn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),p_={[Kc]:{transfer:Ww,primaries:qw,toReference:t=>t,fromReference:t=>t},[ra]:{transfer:mr,primaries:qw,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[nE]:{transfer:Ww,primaries:Kw,toReference:t=>t.applyMatrix3(tV),fromReference:t=>t.applyMatrix3(eV)},[UO]:{transfer:mr,primaries:Kw,toReference:t=>t.convertSRGBToLinear().applyMatrix3(tV),fromReference:t=>t.applyMatrix3(eV).convertLinearToSRGB()}},nLe=new Set([Kc,nE]),er={enabled:!0,_workingColorSpace:Kc,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(!nLe.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=p_[e].toReference,i=p_[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 p_[t].primaries},getTransfer:function(t){return t===ro?Ww:p_[t].transfer}};function pp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function gC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Am;class uQ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Am===void 0&&(Am=Yw("canvas")),Am.width=e.width,Am.height=e.height;const r=Am.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Am}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=Yw("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]=pp(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(pp(n[r]/255)*255):n[r]=pp(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 rLe=0;class dQ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:rLe++}),this.uuid=Dc(),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,l=i.length;s<l;s++)i[s].isDataTexture?a.push(xC(i[s].image)):a.push(xC(i[s]))}else a=xC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function xC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?uQ.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 iLe=0;class ns extends Mf{constructor(e=ns.DEFAULT_IMAGE,n=ns.DEFAULT_MAPPING,r=Do,i=Do,a=to,s=tb,l=no,c=cd,u=ns.DEFAULT_ANISOTROPY,d=ro){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:iLe++}),this.uuid=Dc(),this.name="",this.source=new dQ(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=l,this.internalFormat=null,this.type=c,this.offset=new Qt(0,0),this.repeat=new Qt(1,1),this.center=new Qt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new gn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(o0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Bh?ra:ro),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!==ZZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case JP:e.x=e.x-Math.floor(e.x);break;case Do:e.x=e.x<0?0:1;break;case ej: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 JP:e.y=e.y-Math.floor(e.y);break;case Do:e.y=e.y<0?0:1;break;case ej: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 o0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ra?Bh:aQ}set encoding(e){o0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Bh?ra:ro}}ns.DEFAULT_IMAGE=null;ns.DEFAULT_MAPPING=ZZ;ns.DEFAULT_ANISOTROPY=1;class nr{constructor(e=0,n=0,r=0,i=1){nr.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],p=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,T=(p+1)/2,A=(b+1)/2,C=(d+g)/4,N=(f+v)/4,F=(x+y)/4;return w>T&&w>A?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=N/r):T>A?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=F/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=N/a,i=F/a),this.set(r,i,a,n),this}let E=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(y-x)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+b-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 aLe extends Mf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new nr(0,0,e,n),this.scissorTest=!1,this.viewport=new nr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(o0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Bh?ra:ro),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:to,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new ns(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 dQ(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 ff extends aLe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class hQ extends ns{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=na,this.minFilter=na,this.wrapR=Do,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class sLe extends ns{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=na,this.minFilter=na,this.wrapR=Do,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class mf{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,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=a[s+0],p=a[s+1],x=a[s+2],v=a[s+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==x){let y=1-l;const b=c*g+u*p+d*x+f*v,E=b>=0?1:-1,w=1-b*b;if(w>Number.EPSILON){const A=Math.sqrt(w),C=Math.atan2(A,b*E);y=Math.sin(y*C)/A,l=Math.sin(l*C)/A}const T=l*E;if(c=c*y+g*T,u=u*y+p*T,d=d*y+x*T,f=f*y+v*T,y===1-l){const A=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=A,u*=A,d*=A,f*=A}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],p=a[s+2],x=a[s+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,s=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+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],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+l+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(s-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+s)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+s)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(s-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ia(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,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*l+i*u-a*c,this._y=i*d+s*c+a*l-r*u,this._z=a*d+s*u+r*c-i*l,this._w=s*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,s=this._w;let l=s*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=s,this._x=r,this._y=i,this._z=a,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-n;return this._w=p*s+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=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 De{constructor(e=0,n=0,r=0){De.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(nV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(nV.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,l=e.z,c=e.w,u=2*(s*i-l*r),d=2*(l*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-l*d,this.y=r+c*d+l*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,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*s-r*c,this.z=r*l-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 bC.copy(this).projectOnVector(e),this.sub(bC)}reflect(e){return this.sub(bC.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(ia(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 bC=new De,nV=new mf;class uo{constructor(e=new De(1/0,1/0,1/0),n=new De(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Ao.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ao.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Ao.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,l=a.count;s<l;s++)e.isMesh===!0?e.getVertexPosition(s,Ao):Ao.fromBufferAttribute(a,s),Ao.applyMatrix4(e.matrixWorld),this.expandByPoint(Ao);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),g_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),g_.copy(r.boundingBox)),g_.applyMatrix4(e.matrixWorld),this.union(g_)}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,Ao),Ao.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Dx),x_.subVectors(this.max,Dx),Nm.subVectors(e.a,Dx),Cm.subVectors(e.b,Dx),km.subVectors(e.c,Dx),ku.subVectors(Cm,Nm),Pu.subVectors(km,Cm),ih.subVectors(Nm,km);let n=[0,-ku.z,ku.y,0,-Pu.z,Pu.y,0,-ih.z,ih.y,ku.z,0,-ku.x,Pu.z,0,-Pu.x,ih.z,0,-ih.x,-ku.y,ku.x,0,-Pu.y,Pu.x,0,-ih.y,ih.x,0];return!yC(n,Nm,Cm,km,x_)||(n=[1,0,0,0,1,0,0,0,1],!yC(n,Nm,Cm,km,x_))?!1:(b_.crossVectors(ku,Pu),n=[b_.x,b_.y,b_.z],yC(n,Nm,Cm,km,x_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ao).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ao).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ac[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ac[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ac[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ac[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ac[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ac[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ac[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ac[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ac),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 ac=[new De,new De,new De,new De,new De,new De,new De,new De],Ao=new De,g_=new uo,Nm=new De,Cm=new De,km=new De,ku=new De,Pu=new De,ih=new De,Dx=new De,x_=new De,b_=new De,ah=new De;function yC(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){ah.fromArray(t,a);const l=i.x*Math.abs(ah.x)+i.y*Math.abs(ah.y)+i.z*Math.abs(ah.z),c=e.dot(ah),u=n.dot(ah),d=r.dot(ah);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const oLe=new uo,Ox=new De,vC=new De;class pl{constructor(e=new De,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):oLe.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;Ox.subVectors(e,this.center);const n=Ox.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Ox,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):(vC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ox.copy(e.center).add(vC)),this.expandByPoint(Ox.copy(e.center).sub(vC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const sc=new De,_C=new De,y_=new De,ju=new De,wC=new De,v_=new De,SC=new De;class BO{constructor(e=new De,n=new De(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,sc)),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=sc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(sc.copy(this.origin).addScaledVector(this.direction,n),sc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){_C.copy(e).add(n).multiplyScalar(.5),y_.copy(n).sub(e).normalize(),ju.copy(this.origin).sub(_C);const a=e.distanceTo(n)*.5,s=-this.direction.dot(y_),l=ju.dot(this.direction),c=-ju.dot(y_),u=ju.lengthSq(),d=Math.abs(1-s*s);let f,g,p,x;if(d>0)if(f=s*c-l,g=s*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,p=f*(f+s*g+2*l)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(s*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(_C).addScaledVector(y_,g),p}intersectSphere(e,n){sc.subVectors(e.center,this.origin);const r=sc.dot(this.direction),i=sc.dot(sc)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),l=r-s,c=r+s;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,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?(l=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(l=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,sc)!==null}intersectTriangle(e,n,r,i,a){wC.subVectors(n,e),v_.subVectors(r,e),SC.crossVectors(wC,v_);let s=this.direction.dot(SC),l;if(s>0){if(i)return null;l=1}else if(s<0)l=-1,s=-s;else return null;ju.subVectors(this.origin,e);const c=l*this.direction.dot(v_.crossVectors(ju,v_));if(c<0)return null;const u=l*this.direction.dot(wC.cross(ju));if(u<0||c+u>s)return null;const d=-l*ju.dot(SC);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 dr{constructor(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){dr.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,l,c,u,d,f,g,p,x,v,y)}set(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=l,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=p,b[7]=x,b[11]=v,b[15]=y,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 dr().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/Pm.setFromMatrixColumn(e,0).length(),a=1/Pm.setFromMatrixColumn(e,1).length(),s=1/Pm.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),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-v*u,n[9]=-l*c,n[2]=v-g*u,n[6]=x+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g+v*l,n[4]=x*l-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-l,n[2]=p*l-x,n[6]=v+g*l,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g-v*l,n[4]=-s*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=s*d,n[9]=v-g*l,n[2]=-s*u,n[6]=l,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+p,n[1]=f,n[5]=s*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=v*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(lLe,e,cLe)}lookAt(e,n,r){const i=this.elements;return ys.subVectors(e,n),ys.lengthSq()===0&&(ys.z=1),ys.normalize(),Ru.crossVectors(r,ys),Ru.lengthSq()===0&&(Math.abs(r.z)===1?ys.x+=1e-4:ys.z+=1e-4,ys.normalize(),Ru.crossVectors(r,ys)),Ru.normalize(),__.crossVectors(ys,Ru),i[0]=Ru.x,i[4]=__.x,i[8]=ys.x,i[1]=Ru.y,i[5]=__.y,i[9]=ys.y,i[2]=Ru.z,i[6]=__.z,i[10]=ys.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],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],v=r[6],y=r[10],b=r[14],E=r[3],w=r[7],T=r[11],A=r[15],C=i[0],N=i[4],F=i[8],k=i[12],R=i[1],I=i[5],L=i[9],q=i[13],j=i[2],V=i[6],K=i[10],W=i[14],J=i[3],ee=i[7],Z=i[11],B=i[15];return a[0]=s*C+l*R+c*j+u*J,a[4]=s*N+l*I+c*V+u*ee,a[8]=s*F+l*L+c*K+u*Z,a[12]=s*k+l*q+c*W+u*B,a[1]=d*C+f*R+g*j+p*J,a[5]=d*N+f*I+g*V+p*ee,a[9]=d*F+f*L+g*K+p*Z,a[13]=d*k+f*q+g*W+p*B,a[2]=x*C+v*R+y*j+b*J,a[6]=x*N+v*I+y*V+b*ee,a[10]=x*F+v*L+y*K+b*Z,a[14]=x*k+v*q+y*W+b*B,a[3]=E*C+w*R+T*j+A*J,a[7]=E*N+w*I+T*V+A*ee,a[11]=E*F+w*L+T*K+A*Z,a[15]=E*k+w*q+T*W+A*B,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],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+v*(+n*c*p-n*u*g+a*s*g-i*s*p+i*u*d-a*c*d)+y*(+n*u*f-n*l*p-a*s*f+r*s*p+a*l*d-r*u*d)+b*(-i*l*d-n*c*f+n*l*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],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],v=e[13],y=e[14],b=e[15],E=f*y*u-v*g*u+v*c*p-l*y*p-f*c*b+l*g*b,w=x*g*u-d*y*u-x*c*p+s*y*p+d*c*b-s*g*b,T=d*v*u-x*f*u+x*l*p-s*v*p-d*l*b+s*f*b,A=x*f*c-d*v*c-x*l*g+s*v*g+d*l*y-s*f*y,C=n*E+r*w+i*T+a*A;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/C;return e[0]=E*N,e[1]=(v*g*a-f*y*a-v*i*p+r*y*p+f*i*b-r*g*b)*N,e[2]=(l*y*a-v*c*a+v*i*u-r*y*u-l*i*b+r*c*b)*N,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*N,e[4]=w*N,e[5]=(d*y*a-x*g*a+x*i*p-n*y*p-d*i*b+n*g*b)*N,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*p+n*c*p)*N,e[8]=T*N,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*b-n*f*b)*N,e[10]=(s*v*a-x*l*a+x*r*u-n*v*u-s*r*b+n*l*b)*N,e[11]=(d*l*a-s*f*a-d*r*u+n*f*u+s*r*p-n*l*p)*N,e[12]=A*N,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*N,e[14]=(x*l*i-s*v*i-x*r*c+n*v*c+s*r*y-n*l*y)*N,e[15]=(s*f*i-d*l*i+d*r*c-n*f*c-s*r*g+n*l*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,l=e.y,c=e.z,u=a*s,d=a*l;return this.set(u*s+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*s,0,u*c-i*l,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,l=n._z,c=n._w,u=a+a,d=s+s,f=l+l,g=a*u,p=a*d,x=a*f,v=s*d,y=s*f,b=l*f,E=c*u,w=c*d,T=c*f,A=r.x,C=r.y,N=r.z;return i[0]=(1-(v+b))*A,i[1]=(p+T)*A,i[2]=(x-w)*A,i[3]=0,i[4]=(p-T)*C,i[5]=(1-(g+b))*C,i[6]=(y+E)*C,i[7]=0,i[8]=(x+w)*N,i[9]=(y-E)*N,i[10]=(1-(g+v))*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=Pm.set(i[0],i[1],i[2]).length();const s=Pm.set(i[4],i[5],i[6]).length(),l=Pm.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],No.copy(this);const u=1/a,d=1/s,f=1/l;return No.elements[0]*=u,No.elements[1]*=u,No.elements[2]*=u,No.elements[4]*=d,No.elements[5]*=d,No.elements[6]*=d,No.elements[8]*=f,No.elements[9]*=f,No.elements[10]*=f,n.setFromRotationMatrix(No),r.x=a,r.y=s,r.z=l,this}makePerspective(e,n,r,i,a,s,l=fl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let p,x;if(l===fl)p=-(s+a)/(s-a),x=-2*s*a/(s-a);else if(l===rb)p=-s/(s-a),x=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,s,l=fl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(s-a),g=(n+e)*u,p=(r+i)*d;let x,v;if(l===fl)x=(s+a)*f,v=-2*f;else if(l===rb)x=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-g,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=v,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const Pm=new De,No=new dr,lLe=new De(0,0,0),cLe=new De(1,1,1),Ru=new De,__=new De,ys=new De,rV=new dr,iV=new mf;class ry{constructor(e=0,n=0,r=0,i=ry.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],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(ia(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-ia(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(ia(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-ia(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(ia(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-ia(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return rV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(rV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return iV.setFromEuler(this),this.setFromQuaternion(iV,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}}ry.DEFAULT_ORDER="XYZ";class fQ{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 uLe=0;const aV=new De,jm=new mf,oc=new dr,w_=new De,Lx=new De,dLe=new De,hLe=new mf,sV=new De(1,0,0),oV=new De(0,1,0),lV=new De(0,0,1),fLe={type:"added"},mLe={type:"removed"};class Da extends Mf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:uLe++}),this.uuid=Dc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Da.DEFAULT_UP.clone();const e=new De,n=new ry,r=new mf,i=new De(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 dr},normalMatrix:{value:new gn}}),this.matrix=new dr,this.matrixWorld=new dr,this.matrixAutoUpdate=Da.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Da.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fQ,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 jm.setFromAxisAngle(e,n),this.quaternion.multiply(jm),this}rotateOnWorldAxis(e,n){return jm.setFromAxisAngle(e,n),this.quaternion.premultiply(jm),this}rotateX(e){return this.rotateOnAxis(sV,e)}rotateY(e){return this.rotateOnAxis(oV,e)}rotateZ(e){return this.rotateOnAxis(lV,e)}translateOnAxis(e,n){return aV.copy(e).applyQuaternion(this.quaternion),this.position.add(aV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(sV,e)}translateY(e){return this.translateOnAxis(oV,e)}translateZ(e){return this.translateOnAxis(lV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(oc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?w_.copy(e):w_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Lx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?oc.lookAt(Lx,w_,this.up):oc.lookAt(w_,Lx,this.up),this.quaternion.setFromRotationMatrix(oc),i&&(oc.extractRotation(i.matrixWorld),jm.setFromRotationMatrix(oc),this.quaternion.premultiply(jm.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(fLe)):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(mLe)),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),oc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),oc.multiply(e.parent.matrixWorld)),e.applyMatrix4(oc),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(Lx,e,dLe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lx,hLe,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 l=i[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),p=s(e.animations),x=s(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Da.DEFAULT_UP=new De(0,1,0);Da.DEFAULT_MATRIX_AUTO_UPDATE=!0;Da.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Co=new De,lc=new De,MC=new De,cc=new De,Rm=new De,Dm=new De,cV=new De,EC=new De,TC=new De,AC=new De;let S_=!1;class ko{constructor(e=new De,n=new De,r=new De){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Co.subVectors(e,n),i.cross(Co);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Co.subVectors(i,n),lc.subVectors(r,n),MC.subVectors(e,n);const s=Co.dot(Co),l=Co.dot(lc),c=Co.dot(MC),u=lc.dot(lc),d=lc.dot(MC),f=s*u-l*l;if(f===0)return a.set(-2,-1,-1);const g=1/f,p=(u*c-l*d)*g,x=(s*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,cc),cc.x>=0&&cc.y>=0&&cc.x+cc.y<=1}static getUV(e,n,r,i,a,s,l,c){return S_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),S_=!0),this.getInterpolation(e,n,r,i,a,s,l,c)}static getInterpolation(e,n,r,i,a,s,l,c){return this.getBarycoord(e,n,r,i,cc),c.setScalar(0),c.addScaledVector(a,cc.x),c.addScaledVector(s,cc.y),c.addScaledVector(l,cc.z),c}static isFrontFacing(e,n,r,i){return Co.subVectors(r,n),lc.subVectors(e,n),Co.cross(lc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Co.subVectors(this.c,this.b),lc.subVectors(this.a,this.b),Co.cross(lc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ko.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return ko.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return S_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),S_=!0),ko.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return ko.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return ko.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ko.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,l;Rm.subVectors(i,r),Dm.subVectors(a,r),EC.subVectors(e,r);const c=Rm.dot(EC),u=Dm.dot(EC);if(c<=0&&u<=0)return n.copy(r);TC.subVectors(e,i);const d=Rm.dot(TC),f=Dm.dot(TC);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(Rm,s);AC.subVectors(e,a);const p=Rm.dot(AC),x=Dm.dot(AC);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Dm,l);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return cV.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(cV,l);const b=1/(y+v+g);return s=v*b,l=g*b,n.copy(r).addScaledVector(Rm,s).addScaledVector(Dm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const mQ={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},Du={h:0,s:0,l:0},M_={h:0,s:0,l:0};function NC(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 Vt=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=ra){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,er.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=er.workingColorSpace){return this.r=e,this.g=n,this.b=r,er.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=er.workingColorSpace){if(e=zO(e,1),n=ia(n,0,1),r=ia(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=NC(s,a,e+1/3),this.g=NC(s,a,e),this.b=NC(s,a,e-1/3)}return er.toWorkingColorSpace(this,i),this}setStyle(e,n=ra){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],l=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],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=ra){const r=mQ[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=pp(e.r),this.g=pp(e.g),this.b=pp(e.b),this}copyLinearToSRGB(e){return this.r=gC(e.r),this.g=gC(e.g),this.b=gC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ra){return er.fromWorkingColorSpace(fa.copy(this),e),Math.round(ia(fa.r*255,0,255))*65536+Math.round(ia(fa.g*255,0,255))*256+Math.round(ia(fa.b*255,0,255))}getHexString(e=ra){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=er.workingColorSpace){er.fromWorkingColorSpace(fa.copy(this),n);const r=fa.r,i=fa.g,a=fa.b,s=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+s)/2;if(l===s)c=0,u=0;else{const f=s-l;switch(u=d<=.5?f/(s+l):f/(2-s-l),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=er.workingColorSpace){return er.fromWorkingColorSpace(fa.copy(this),n),e.r=fa.r,e.g=fa.g,e.b=fa.b,e}getStyle(e=ra){er.fromWorkingColorSpace(fa.copy(this),e);const n=fa.r,r=fa.g,i=fa.b;return e!==ra?`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(Du),this.setHSL(Du.h+e,Du.s+n,Du.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(Du),e.getHSL(M_);const r=s0(Du.h,M_.h,n),i=s0(Du.s,M_.s,n),a=s0(Du.l,M_.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 fa=new Vt;Vt.NAMES=mQ;let pLe=0;class vg extends Mf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:pLe++}),this.uuid=Dc(),this.name="",this.type="Material",this.blending=mp,this.side=Md,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=XP,this.blendDst=YP,this.blendEquation=yh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Vt(0,0,0),this.blendAlpha=0,this.depthFunc=Gw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Y$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Tm,this.stencilZFail=Tm,this.stencilZPass=Tm,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==mp&&(r.blending=this.blending),this.side!==Md&&(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!==XP&&(r.blendSrc=this.blendSrc),this.blendDst!==YP&&(r.blendDst=this.blendDst),this.blendEquation!==yh&&(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!==Gw&&(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!==Y$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Tm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Tm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Tm&&(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 l in a){const c=a[l];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 pQ extends vg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Vt(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=IO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const si=new De,E_=new Qt;class ks{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=tj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ac,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++)E_.fromBufferAttribute(this,n),E_.applyMatrix3(e),this.setXY(n,E_.x,E_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.applyMatrix3(e),this.setXYZ(n,si.x,si.y,si.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.applyMatrix4(e),this.setXYZ(n,si.x,si.y,si.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.applyNormalMatrix(e),this.setXYZ(n,si.x,si.y,si.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.transformDirection(e),this.setXYZ(n,si.x,si.y,si.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=cl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Jn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=cl(n,this.array)),n}setX(e,n){return this.normalized&&(n=Jn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=cl(n,this.array)),n}setY(e,n){return this.normalized&&(n=Jn(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=cl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Jn(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=cl(n,this.array)),n}setW(e,n){return this.normalized&&(n=Jn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Jn(n,this.array),r=Jn(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=Jn(n,this.array),r=Jn(r,this.array),i=Jn(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=Jn(n,this.array),r=Jn(r,this.array),i=Jn(i,this.array),a=Jn(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!==tj&&(e.usage=this.usage),e}}class gQ extends ks{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class xQ extends ks{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Jr extends ks{constructor(e,n,r){super(new Float32Array(e),n,r)}}let gLe=0;const Gs=new dr,CC=new Da,Om=new De,vs=new uo,Ix=new uo,Di=new De;class Sa extends Mf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:gLe++}),this.uuid=Dc(),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(cQ(e)?xQ:gQ)(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 gn().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 Gs.makeRotationFromQuaternion(e),this.applyMatrix4(Gs),this}rotateX(e){return Gs.makeRotationX(e),this.applyMatrix4(Gs),this}rotateY(e){return Gs.makeRotationY(e),this.applyMatrix4(Gs),this}rotateZ(e){return Gs.makeRotationZ(e),this.applyMatrix4(Gs),this}translate(e,n,r){return Gs.makeTranslation(e,n,r),this.applyMatrix4(Gs),this}scale(e,n,r){return Gs.makeScale(e,n,r),this.applyMatrix4(Gs),this}lookAt(e){return CC.lookAt(e),CC.updateMatrix(),this.applyMatrix4(CC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Om).negate(),this.translate(Om.x,Om.y,Om.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 Jr(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new uo);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 De(-1/0,-1/0,-1/0),new De(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];vs.setFromBufferAttribute(a),this.morphTargetsRelative?(Di.addVectors(this.boundingBox.min,vs.min),this.boundingBox.expandByPoint(Di),Di.addVectors(this.boundingBox.max,vs.max),this.boundingBox.expandByPoint(Di)):(this.boundingBox.expandByPoint(vs.min),this.boundingBox.expandByPoint(vs.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 pl);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 De,1/0);return}if(e){const r=this.boundingSphere.center;if(vs.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const l=n[a];Ix.setFromBufferAttribute(l),this.morphTargetsRelative?(Di.addVectors(vs.min,Ix.min),vs.expandByPoint(Di),Di.addVectors(vs.max,Ix.max),vs.expandByPoint(Di)):(vs.expandByPoint(Ix.min),vs.expandByPoint(Ix.max))}vs.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Di.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Di));if(n)for(let a=0,s=n.length;a<s;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Di.fromBufferAttribute(l,u),c&&(Om.fromBufferAttribute(e,u),Di.add(Om)),i=Math.max(i,r.distanceToSquared(Di))}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,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ks(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new De,d[R]=new De;const f=new De,g=new De,p=new De,x=new Qt,v=new Qt,y=new Qt,b=new De,E=new De;function w(R,I,L){f.fromArray(i,R*3),g.fromArray(i,I*3),p.fromArray(i,L*3),x.fromArray(s,R*2),v.fromArray(s,I*2),y.fromArray(s,L*2),g.sub(f),p.sub(f),v.sub(x),y.sub(x);const q=1/(v.x*y.y-y.x*v.y);isFinite(q)&&(b.copy(g).multiplyScalar(y.y).addScaledVector(p,-v.y).multiplyScalar(q),E.copy(p).multiplyScalar(v.x).addScaledVector(g,-y.x).multiplyScalar(q),u[R].add(b),u[I].add(b),u[L].add(b),d[R].add(E),d[I].add(E),d[L].add(E))}let T=this.groups;T.length===0&&(T=[{start:0,count:r.length}]);for(let R=0,I=T.length;R<I;++R){const L=T[R],q=L.start,j=L.count;for(let V=q,K=q+j;V<K;V+=3)w(r[V+0],r[V+1],r[V+2])}const A=new De,C=new De,N=new De,F=new De;function k(R){N.fromArray(a,R*3),F.copy(N);const I=u[R];A.copy(I),A.sub(N.multiplyScalar(N.dot(I))).normalize(),C.crossVectors(F,I);const q=C.dot(d[R])<0?-1:1;c[R*4]=A.x,c[R*4+1]=A.y,c[R*4+2]=A.z,c[R*4+3]=q}for(let R=0,I=T.length;R<I;++R){const L=T[R],q=L.start,j=L.count;for(let V=q,K=q+j;V<K;V+=3)k(r[V+0]),k(r[V+1]),k(r[V+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 ks(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new De,a=new De,s=new De,l=new De,c=new De,u=new De,d=new De,f=new De;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),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++)Di.fromBufferAttribute(e,n),Di.normalize(),e.setXYZ(n,Di.x,Di.y,Di.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,y=c.length;v<y;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[p++]}return new ks(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Sa,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let l=0,c=s.length;l<c;l++){const u=s[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const 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 l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const uV=new dr,sh=new BO,T_=new pl,dV=new De,Lm=new De,Im=new De,Fm=new De,kC=new De,A_=new De,N_=new Qt,C_=new Qt,k_=new Qt,hV=new De,fV=new De,mV=new De,P_=new De,j_=new De;class Io extends Da{constructor(e=new Sa,n=new pQ){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){A_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(kC.fromBufferAttribute(f,e),s?A_.addScaledVector(kC,d):A_.addScaledVector(kC.sub(n),d))}n.add(A_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),T_.copy(r.boundingSphere),T_.applyMatrix4(a),sh.copy(e.ray).recast(e.near),!(T_.containsPoint(sh.origin)===!1&&(sh.intersectSphere(T_,dV)===null||sh.origin.distanceToSquared(dV)>(e.far-e.near)**2))&&(uV.copy(a).invert(),sh.copy(e.ray).applyMatrix4(uV),!(r.boundingBox!==null&&sh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,sh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(l.count,Math.min(y.start+y.count,p.start+p.count));for(let T=E,A=w;T<A;T+=3){const C=l.getX(T),N=l.getX(T+1),F=l.getX(T+2);i=R_(this,b,e,r,u,d,f,C,N,F),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=l.getX(y),w=l.getX(y+1),T=l.getX(y+2);i=R_(this,s,e,r,u,d,f,E,w,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let T=E,A=w;T<A;T+=3){const C=T,N=T+1,F=T+2;i=R_(this,b,e,r,u,d,f,C,N,F),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=y,w=y+1,T=y+2;i=R_(this,s,e,r,u,d,f,E,w,T),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}}function xLe(t,e,n,r,i,a,s,l){let c;if(e.side===ts?c=r.intersectTriangle(s,a,i,!0,l):c=r.intersectTriangle(i,a,s,e.side===Md,l),c===null)return null;j_.copy(l),j_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(j_);return u<n.near||u>n.far?null:{distance:u,point:j_.clone(),object:t}}function R_(t,e,n,r,i,a,s,l,c,u){t.getVertexPosition(l,Lm),t.getVertexPosition(c,Im),t.getVertexPosition(u,Fm);const d=xLe(t,e,n,r,Lm,Im,Fm,P_);if(d){i&&(N_.fromBufferAttribute(i,l),C_.fromBufferAttribute(i,c),k_.fromBufferAttribute(i,u),d.uv=ko.getInterpolation(P_,Lm,Im,Fm,N_,C_,k_,new Qt)),a&&(N_.fromBufferAttribute(a,l),C_.fromBufferAttribute(a,c),k_.fromBufferAttribute(a,u),d.uv1=ko.getInterpolation(P_,Lm,Im,Fm,N_,C_,k_,new Qt),d.uv2=d.uv1),s&&(hV.fromBufferAttribute(s,l),fV.fromBufferAttribute(s,c),mV.fromBufferAttribute(s,u),d.normal=ko.getInterpolation(P_,Lm,Im,Fm,hV,fV,mV,new De),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new De,materialIndex:0};ko.getNormal(Lm,Im,Fm,f.normal),d.face=f}return d}class iy extends Sa{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 l=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Jr(u,3)),this.setAttribute("normal",new Jr(d,3)),this.setAttribute("uv",new Jr(f,2));function x(v,y,b,E,w,T,A,C,N,F,k){const R=T/N,I=A/F,L=T/2,q=A/2,j=C/2,V=N+1,K=F+1;let W=0,J=0;const ee=new De;for(let Z=0;Z<K;Z++){const B=Z*I-q;for(let G=0;G<V;G++){const Q=G*R-L;ee[v]=Q*E,ee[y]=B*w,ee[b]=j,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[y]=0,ee[b]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(G/N),f.push(1-Z/F),W+=1}}for(let Z=0;Z<F;Z++)for(let B=0;B<N;B++){const G=g+B+V*Z,Q=g+B+V*(Z+1),te=g+(B+1)+V*(Z+1),he=g+(B+1)+V*Z;c.push(G,Q,he),c.push(Q,te,he),J+=6}l.addGroup(p,J,k),p+=J,g+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new iy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Vp(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 Na(t){const e={};for(let n=0;n<t.length;n++){const r=Vp(t[n]);for(const i in r)e[i]=r[i]}return e}function bLe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function bQ(t){return t.getRenderTarget()===null?t.outputColorSpace:er.workingColorSpace}const HO={clone:Vp,merge:Na};var yLe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,vLe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Ed extends vg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=yLe,this.fragmentShader=vLe,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=Vp(e.uniforms),this.uniformsGroups=bLe(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 yQ extends Da{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new dr,this.projectionMatrix=new dr,this.projectionMatrixInverse=new dr,this.coordinateSystem=fl}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 ws extends yQ{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=ib*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(a0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ib*2*Math.atan(Math.tan(a0*.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(a0*.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 l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const Um=-90,zm=1;class _Le extends Da{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ws(Um,zm,e,n);i.layers=this.layers,this.add(i);const a=new ws(Um,zm,e,n);a.layers=this.layers,this.add(a);const s=new ws(Um,zm,e,n);s.layers=this.layers,this.add(s);const l=new ws(Um,zm,e,n);l.layers=this.layers,this.add(l);const c=new ws(Um,zm,e,n);c.layers=this.layers,this.add(c);const u=new ws(Um,zm,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,l,c]=n;for(const u of n)this.remove(u);if(e===fl)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),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===rb)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),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class vQ extends ns{constructor(e,n,r,i,a,s,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Bp,super(e,n,r,i,a,s,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class wLe extends ff{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&&(o0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Bh?ra:ro),this.texture=new vQ(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:to}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new iy(5,5,5),a=new Ed({name:"CubemapFromEquirect",uniforms:Vp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ts,blending:od});a.uniforms.tEquirect.value=n;const s=new Io(i,a),l=n.minFilter;return n.minFilter===tb&&(n.minFilter=to),new _Le(1,10,this).update(e,s),n.minFilter=l,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 PC=new De,SLe=new De,MLe=new gn;class Hu{constructor(e=new De(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=PC.subVectors(r,n).cross(SLe.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(PC),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||MLe.getNormalMatrix(e),i=this.coplanarPoint(PC).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 oh=new pl,D_=new De;class rE{constructor(e=new Hu,n=new Hu,r=new Hu,i=new Hu,a=new Hu,s=new Hu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(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=fl){const r=this.planes,i=e.elements,a=i[0],s=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],g=i[7],p=i[8],x=i[9],v=i[10],y=i[11],b=i[12],E=i[13],w=i[14],T=i[15];if(r[0].setComponents(c-a,g-u,y-p,T-b).normalize(),r[1].setComponents(c+a,g+u,y+p,T+b).normalize(),r[2].setComponents(c+s,g+d,y+x,T+E).normalize(),r[3].setComponents(c-s,g-d,y-x,T-E).normalize(),r[4].setComponents(c-l,g-f,y-v,T-w).normalize(),n===fl)r[5].setComponents(c+l,g+f,y+v,T+w).normalize();else if(n===rb)r[5].setComponents(l,f,v,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),oh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),oh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(oh)}intersectsSprite(e){return oh.center.set(0,0,0),oh.radius=.7071067811865476,oh.applyMatrix4(e.matrixWorld),this.intersectsSphere(oh)}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(D_.x=i.normal.x>0?e.max.x:e.min.x,D_.y=i.normal.y>0?e.max.y:e.min.y,D_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(D_)<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 _Q(){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 ELe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,g),u.onUploadCallback();let v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const g=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,g),x.length!==0){for(let v=0,y=x.length;v<y;v++){const b=x[v];n?t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g,b.start,b.count):t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g.subarray(b.start,b.start+b.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g,p.offset,p.count):t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function s(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:s,remove:l,update:c}}class $O extends Sa{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,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const E=b*g-s;for(let w=0;w<u;w++){const T=w*f-a;x.push(T,-E,0),v.push(0,0,1),y.push(w/l),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<l;E++){const w=E+u*b,T=E+u*(b+1),A=E+1+u*(b+1),C=E+1+u*b;p.push(w,T,C),p.push(T,A,C)}this.setIndex(p),this.setAttribute("position",new Jr(x,3)),this.setAttribute("normal",new Jr(v,3)),this.setAttribute("uv",new Jr(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $O(e.width,e.height,e.widthSegments,e.heightSegments)}}var TLe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,ALe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,NLe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,CLe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,kLe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,PLe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,jLe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,RLe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,DLe=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,OLe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,LLe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,ILe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,FLe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,ULe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,zLe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,BLe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,HLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,$Le=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,VLe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,GLe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,WLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,qLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,KLe=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,XLe=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,YLe=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,ZLe=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,QLe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,JLe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,e4e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,t4e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,n4e="gl_FragColor = linearToOutputTexel( gl_FragColor );",r4e=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,i4e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,a4e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,s4e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,o4e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,l4e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,c4e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,u4e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,d4e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,h4e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,f4e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,m4e=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,p4e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,g4e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,x4e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,b4e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,y4e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,v4e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,_4e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,w4e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,S4e=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,M4e=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,E4e=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,T4e=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,A4e=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,N4e=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,C4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,k4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,P4e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,j4e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,R4e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,D4e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,O4e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,L4e=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,I4e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,F4e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,U4e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,z4e=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,B4e=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,H4e=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,$4e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,V4e=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,G4e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,W4e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,q4e=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,K4e=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,X4e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Y4e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Z4e=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,Q4e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,J4e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,eIe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,tIe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,nIe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,rIe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,iIe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,aIe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,sIe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,oIe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,lIe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,cIe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,uIe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,dIe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,hIe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,fIe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,mIe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,pIe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,gIe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,xIe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,bIe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,yIe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,vIe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,_Ie=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,wIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,SIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,MIe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const EIe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,TIe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,AIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,NIe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,CIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,kIe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,PIe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,jIe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,RIe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,DIe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,OIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,LIe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,IIe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,FIe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,UIe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,zIe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,BIe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,HIe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,$Ie=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,VIe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,GIe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,WIe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,qIe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,KIe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,XIe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,YIe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,ZIe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,QIe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,JIe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,e5e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,t5e=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,n5e=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,r5e=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,i5e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,un={alphahash_fragment:TLe,alphahash_pars_fragment:ALe,alphamap_fragment:NLe,alphamap_pars_fragment:CLe,alphatest_fragment:kLe,alphatest_pars_fragment:PLe,aomap_fragment:jLe,aomap_pars_fragment:RLe,batching_pars_vertex:DLe,batching_vertex:OLe,begin_vertex:LLe,beginnormal_vertex:ILe,bsdfs:FLe,iridescence_fragment:ULe,bumpmap_pars_fragment:zLe,clipping_planes_fragment:BLe,clipping_planes_pars_fragment:HLe,clipping_planes_pars_vertex:$Le,clipping_planes_vertex:VLe,color_fragment:GLe,color_pars_fragment:WLe,color_pars_vertex:qLe,color_vertex:KLe,common:XLe,cube_uv_reflection_fragment:YLe,defaultnormal_vertex:ZLe,displacementmap_pars_vertex:QLe,displacementmap_vertex:JLe,emissivemap_fragment:e4e,emissivemap_pars_fragment:t4e,colorspace_fragment:n4e,colorspace_pars_fragment:r4e,envmap_fragment:i4e,envmap_common_pars_fragment:a4e,envmap_pars_fragment:s4e,envmap_pars_vertex:o4e,envmap_physical_pars_fragment:y4e,envmap_vertex:l4e,fog_vertex:c4e,fog_pars_vertex:u4e,fog_fragment:d4e,fog_pars_fragment:h4e,gradientmap_pars_fragment:f4e,lightmap_fragment:m4e,lightmap_pars_fragment:p4e,lights_lambert_fragment:g4e,lights_lambert_pars_fragment:x4e,lights_pars_begin:b4e,lights_toon_fragment:v4e,lights_toon_pars_fragment:_4e,lights_phong_fragment:w4e,lights_phong_pars_fragment:S4e,lights_physical_fragment:M4e,lights_physical_pars_fragment:E4e,lights_fragment_begin:T4e,lights_fragment_maps:A4e,lights_fragment_end:N4e,logdepthbuf_fragment:C4e,logdepthbuf_pars_fragment:k4e,logdepthbuf_pars_vertex:P4e,logdepthbuf_vertex:j4e,map_fragment:R4e,map_pars_fragment:D4e,map_particle_fragment:O4e,map_particle_pars_fragment:L4e,metalnessmap_fragment:I4e,metalnessmap_pars_fragment:F4e,morphcolor_vertex:U4e,morphnormal_vertex:z4e,morphtarget_pars_vertex:B4e,morphtarget_vertex:H4e,normal_fragment_begin:$4e,normal_fragment_maps:V4e,normal_pars_fragment:G4e,normal_pars_vertex:W4e,normal_vertex:q4e,normalmap_pars_fragment:K4e,clearcoat_normal_fragment_begin:X4e,clearcoat_normal_fragment_maps:Y4e,clearcoat_pars_fragment:Z4e,iridescence_pars_fragment:Q4e,opaque_fragment:J4e,packing:eIe,premultiplied_alpha_fragment:tIe,project_vertex:nIe,dithering_fragment:rIe,dithering_pars_fragment:iIe,roughnessmap_fragment:aIe,roughnessmap_pars_fragment:sIe,shadowmap_pars_fragment:oIe,shadowmap_pars_vertex:lIe,shadowmap_vertex:cIe,shadowmask_pars_fragment:uIe,skinbase_vertex:dIe,skinning_pars_vertex:hIe,skinning_vertex:fIe,skinnormal_vertex:mIe,specularmap_fragment:pIe,specularmap_pars_fragment:gIe,tonemapping_fragment:xIe,tonemapping_pars_fragment:bIe,transmission_fragment:yIe,transmission_pars_fragment:vIe,uv_pars_fragment:_Ie,uv_pars_vertex:wIe,uv_vertex:SIe,worldpos_vertex:MIe,background_vert:EIe,background_frag:TIe,backgroundCube_vert:AIe,backgroundCube_frag:NIe,cube_vert:CIe,cube_frag:kIe,depth_vert:PIe,depth_frag:jIe,distanceRGBA_vert:RIe,distanceRGBA_frag:DIe,equirect_vert:OIe,equirect_frag:LIe,linedashed_vert:IIe,linedashed_frag:FIe,meshbasic_vert:UIe,meshbasic_frag:zIe,meshlambert_vert:BIe,meshlambert_frag:HIe,meshmatcap_vert:$Ie,meshmatcap_frag:VIe,meshnormal_vert:GIe,meshnormal_frag:WIe,meshphong_vert:qIe,meshphong_frag:KIe,meshphysical_vert:XIe,meshphysical_frag:YIe,meshtoon_vert:ZIe,meshtoon_frag:QIe,points_vert:JIe,points_frag:e5e,shadow_vert:t5e,shadow_frag:n5e,sprite_vert:r5e,sprite_frag:i5e},Tt={common:{diffuse:{value:new Vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new gn},alphaMap:{value:null},alphaMapTransform:{value:new gn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new gn}},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 gn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new gn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new gn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new gn},normalScale:{value:new Qt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new gn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new gn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new gn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new gn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(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 Vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new gn},alphaTest:{value:0},uvTransform:{value:new gn}},sprite:{diffuse:{value:new Vt(16777215)},opacity:{value:1},center:{value:new Qt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new gn},alphaMap:{value:null},alphaMapTransform:{value:new gn},alphaTest:{value:0}}},Za={basic:{uniforms:Na([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.fog]),vertexShader:un.meshbasic_vert,fragmentShader:un.meshbasic_frag},lambert:{uniforms:Na([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new Vt(0)}}]),vertexShader:un.meshlambert_vert,fragmentShader:un.meshlambert_frag},phong:{uniforms:Na([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30}}]),vertexShader:un.meshphong_vert,fragmentShader:un.meshphong_frag},standard:{uniforms:Na([Tt.common,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.roughnessmap,Tt.metalnessmap,Tt.fog,Tt.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:un.meshphysical_vert,fragmentShader:un.meshphysical_frag},toon:{uniforms:Na([Tt.common,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.gradientmap,Tt.fog,Tt.lights,{emissive:{value:new Vt(0)}}]),vertexShader:un.meshtoon_vert,fragmentShader:un.meshtoon_frag},matcap:{uniforms:Na([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,{matcap:{value:null}}]),vertexShader:un.meshmatcap_vert,fragmentShader:un.meshmatcap_frag},points:{uniforms:Na([Tt.points,Tt.fog]),vertexShader:un.points_vert,fragmentShader:un.points_frag},dashed:{uniforms:Na([Tt.common,Tt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:un.linedashed_vert,fragmentShader:un.linedashed_frag},depth:{uniforms:Na([Tt.common,Tt.displacementmap]),vertexShader:un.depth_vert,fragmentShader:un.depth_frag},normal:{uniforms:Na([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,{opacity:{value:1}}]),vertexShader:un.meshnormal_vert,fragmentShader:un.meshnormal_frag},sprite:{uniforms:Na([Tt.sprite,Tt.fog]),vertexShader:un.sprite_vert,fragmentShader:un.sprite_frag},background:{uniforms:{uvTransform:{value:new gn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:un.background_vert,fragmentShader:un.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:un.backgroundCube_vert,fragmentShader:un.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:un.cube_vert,fragmentShader:un.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:un.equirect_vert,fragmentShader:un.equirect_frag},distanceRGBA:{uniforms:Na([Tt.common,Tt.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:un.distanceRGBA_vert,fragmentShader:un.distanceRGBA_frag},shadow:{uniforms:Na([Tt.lights,Tt.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:un.shadow_vert,fragmentShader:un.shadow_frag}};Za.physical={uniforms:Na([Za.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new gn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new gn},clearcoatNormalScale:{value:new Qt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new gn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new gn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new gn},sheen:{value:0},sheenColor:{value:new Vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new gn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new gn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new gn},transmissionSamplerSize:{value:new Qt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new gn},attenuationDistance:{value:0},attenuationColor:{value:new Vt(0)},specularColor:{value:new Vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new gn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new gn},anisotropyVector:{value:new Qt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new gn}}]),vertexShader:un.meshphysical_vert,fragmentShader:un.meshphysical_frag};const O_={r:0,b:0,g:0};function a5e(t,e,n,r,i,a,s){const l=new Vt(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(y,b){let E=!1,w=b.isScene===!0?b.background:null;w&&w.isTexture&&(w=(b.backgroundBlurriness>0?n:e).get(w)),w===null?v(l,c):w&&w.isColor&&(v(w,1),E=!0);const T=t.xr.getEnvironmentBlendMode();T==="additive"?r.buffers.color.setClear(0,0,0,1,s):T==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===tE)?(d===void 0&&(d=new Io(new iy(1,1,1),new Ed({name:"BackgroundCubeMaterial",uniforms:Vp(Za.backgroundCube.uniforms),vertexShader:Za.backgroundCube.vertexShader,fragmentShader:Za.backgroundCube.fragmentShader,side:ts,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,C,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=w,d.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,d.material.toneMapped=er.getTransfer(w.colorSpace)!==mr,(f!==w||g!==w.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new Io(new $O(2,2),new Ed({name:"BackgroundMaterial",uniforms:Vp(Za.background.uniforms),vertexShader:Za.background.vertexShader,fragmentShader:Za.background.fragmentShader,side:Md,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=w,u.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,u.material.toneMapped=er.getTransfer(w.colorSpace)!==mr,w.matrixAutoUpdate===!0&&w.updateMatrix(),u.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||g!==w.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null))}function v(y,b){y.getRGB(O_,bQ(t)),r.buffers.color.setClear(O_.r,O_.g,O_.b,b,s)}return{getClearColor:function(){return l},setClearColor:function(y,b=1){l.set(y),c=b,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,v(l,c)},render:x}}function s5e(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,l={},c=y(null);let u=c,d=!1;function f(j,V,K,W,J){let ee=!1;if(s){const Z=v(W,K,V);u!==Z&&(u=Z,p(u.object)),ee=b(j,W,K,J),ee&&E(j,W,K,J)}else{const Z=V.wireframe===!0;(u.geometry!==W.id||u.program!==K.id||u.wireframe!==Z)&&(u.geometry=W.id,u.program=K.id,u.wireframe=Z,ee=!0)}J!==null&&n.update(J,t.ELEMENT_ARRAY_BUFFER),(ee||d)&&(d=!1,F(j,V,K,W),J!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(J).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(j){return r.isWebGL2?t.bindVertexArray(j):a.bindVertexArrayOES(j)}function x(j){return r.isWebGL2?t.deleteVertexArray(j):a.deleteVertexArrayOES(j)}function v(j,V,K){const W=K.wireframe===!0;let J=l[j.id];J===void 0&&(J={},l[j.id]=J);let ee=J[V.id];ee===void 0&&(ee={},J[V.id]=ee);let Z=ee[W];return Z===void 0&&(Z=y(g()),ee[W]=Z),Z}function y(j){const V=[],K=[],W=[];for(let J=0;J<i;J++)V[J]=0,K[J]=0,W[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:K,attributeDivisors:W,object:j,attributes:{},index:null}}function b(j,V,K,W){const J=u.attributes,ee=V.attributes;let Z=0;const B=K.getAttributes();for(const G in B)if(B[G].location>=0){const te=J[G];let he=ee[G];if(he===void 0&&(G==="instanceMatrix"&&j.instanceMatrix&&(he=j.instanceMatrix),G==="instanceColor"&&j.instanceColor&&(he=j.instanceColor)),te===void 0||te.attribute!==he||he&&te.data!==he.data)return!0;Z++}return u.attributesNum!==Z||u.index!==W}function E(j,V,K,W){const J={},ee=V.attributes;let Z=0;const B=K.getAttributes();for(const G in B)if(B[G].location>=0){let te=ee[G];te===void 0&&(G==="instanceMatrix"&&j.instanceMatrix&&(te=j.instanceMatrix),G==="instanceColor"&&j.instanceColor&&(te=j.instanceColor));const he={};he.attribute=te,te&&te.data&&(he.data=te.data),J[G]=he,Z++}u.attributes=J,u.attributesNum=Z,u.index=W}function w(){const j=u.newAttributes;for(let V=0,K=j.length;V<K;V++)j[V]=0}function T(j){A(j,0)}function A(j,V){const K=u.newAttributes,W=u.enabledAttributes,J=u.attributeDivisors;K[j]=1,W[j]===0&&(t.enableVertexAttribArray(j),W[j]=1),J[j]!==V&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,V),J[j]=V)}function C(){const j=u.newAttributes,V=u.enabledAttributes;for(let K=0,W=V.length;K<W;K++)V[K]!==j[K]&&(t.disableVertexAttribArray(K),V[K]=0)}function N(j,V,K,W,J,ee,Z){Z===!0?t.vertexAttribIPointer(j,V,K,J,ee):t.vertexAttribPointer(j,V,K,W,J,ee)}function F(j,V,K,W){if(r.isWebGL2===!1&&(j.isInstancedMesh||W.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const J=W.attributes,ee=K.getAttributes(),Z=V.defaultAttributeValues;for(const B in ee){const G=ee[B];if(G.location>=0){let Q=J[B];if(Q===void 0&&(B==="instanceMatrix"&&j.instanceMatrix&&(Q=j.instanceMatrix),B==="instanceColor"&&j.instanceColor&&(Q=j.instanceColor)),Q!==void 0){const te=Q.normalized,he=Q.itemSize,oe=n.get(Q);if(oe===void 0)continue;const xe=oe.buffer,Te=oe.type,me=oe.bytesPerElement,ce=r.isWebGL2===!0&&(Te===t.INT||Te===t.UNSIGNED_INT||Q.gpuType===QZ);if(Q.isInterleavedBufferAttribute){const Ce=Q.data,fe=Ce.stride,Ie=Q.offset;if(Ce.isInstancedInterleavedBuffer){for(let z=0;z<G.locationSize;z++)A(G.location+z,Ce.meshPerAttribute);j.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=Ce.meshPerAttribute*Ce.count)}else for(let z=0;z<G.locationSize;z++)T(G.location+z);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let z=0;z<G.locationSize;z++)N(G.location+z,he/G.locationSize,Te,te,fe*me,(Ie+he/G.locationSize*z)*me,ce)}else{if(Q.isInstancedBufferAttribute){for(let Ce=0;Ce<G.locationSize;Ce++)A(G.location+Ce,Q.meshPerAttribute);j.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let Ce=0;Ce<G.locationSize;Ce++)T(G.location+Ce);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let Ce=0;Ce<G.locationSize;Ce++)N(G.location+Ce,he/G.locationSize,Te,te,he*me,he/G.locationSize*Ce*me,ce)}}else if(Z!==void 0){const te=Z[B];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv(G.location,te);break;case 3:t.vertexAttrib3fv(G.location,te);break;case 4:t.vertexAttrib4fv(G.location,te);break;default:t.vertexAttrib1fv(G.location,te)}}}}C()}function k(){L();for(const j in l){const V=l[j];for(const K in V){const W=V[K];for(const J in W)x(W[J].object),delete W[J];delete V[K]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const V=l[j.id];for(const K in V){const W=V[K];for(const J in W)x(W[J].object),delete W[J];delete V[K]}delete l[j.id]}function I(j){for(const V in l){const K=l[V];if(K[j.id]===void 0)continue;const W=K[j.id];for(const J in W)x(W[J].object),delete W[J];delete K[j.id]}}function L(){q(),d=!0,u!==c&&(u=c,p(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:L,resetDefaultState:q,dispose:k,releaseStatesOfGeometry:R,releaseStatesOfProgram:I,initAttributes:w,enableAttribute:T,disableUnusedAttributes:C}}function o5e(t,e,n,r){const i=r.isWebGL2;let a;function s(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,g){if(g===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](a,d,f,g),n.update(f,a,g)}function u(d,f,g){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<g;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,g);let x=0;for(let v=0;v<g;v++)x+=f[v];n.update(x,a,1)}}this.setMode=s,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function l5e(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 l=n.precision!==void 0?n.precision:"highp";const c=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=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),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),y=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,T=s||e.has("OES_texture_float"),A=w&&T,C=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:p,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:y,maxVaryings:b,maxFragmentUniforms:E,vertexTextures:w,floatFragmentTextures:T,floatVertexTextures:A,maxSamples:C}}function c5e(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Hu,l=new gn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const E=a?0:r,w=E*4;let T=b.clippingState||null;c.value=T,T=d(x,g,w,p);for(let A=0;A!==w;++A)T[A]=n[A];b.clippingState=T,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=p+v*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(y===null||y.length<b)&&(y=new Float32Array(b));for(let w=0,T=p;w!==v;++w,T+=4)s.copy(f[w]).applyMatrix4(E,l),s.normal.toArray(y,T),y[T+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function u5e(t){let e=new WeakMap;function n(s,l){return l===ZP?s.mapping=Bp:l===QP&&(s.mapping=Hp),s}function r(s){if(s&&s.isTexture){const l=s.mapping;if(l===ZP||l===QP)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 wLe(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 l=s.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class d5e extends yQ{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,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,l,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const ap=4,pV=[.125,.215,.35,.446,.526,.582],vh=20,jC=new d5e,gV=new Vt;let RC=null,DC=0,OC=0;const ph=(1+Math.sqrt(5))/2,Bm=1/ph,xV=[new De(1,1,1),new De(-1,1,1),new De(1,1,-1),new De(-1,1,-1),new De(0,ph,Bm),new De(0,ph,-Bm),new De(Bm,0,ph),new De(-Bm,0,ph),new De(ph,Bm,0),new De(-ph,Bm,0)];class bV{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){RC=this._renderer.getRenderTarget(),DC=this._renderer.getActiveCubeFace(),OC=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=_V(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=vV(),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(RC,DC,OC),e.scissorTest=!1,L_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Bp||e.mapping===Hp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),RC=this._renderer.getRenderTarget(),DC=this._renderer.getActiveCubeFace(),OC=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:to,minFilter:to,generateMipmaps:!1,type:nb,format:no,colorSpace:Kc,depthBuffer:!1},i=yV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=yV(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=h5e(a)),this._blurMaterial=f5e(a,e,n)}return i}_compileMaterial(e){const n=new Io(this._lodPlanes[0],e);this._renderer.compile(n,jC)}_sceneToCubeUV(e,n,r,i){const l=new ws(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(gV),d.toneMapping=ld,d.autoClear=!1;const p=new pQ({name:"PMREM.Background",side:ts,depthWrite:!1,depthTest:!1}),x=new Io(new iy,p);let v=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,v=!0):(p.color.copy(gV),v=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(l.up.set(0,c[b],0),l.lookAt(u[b],0,0)):E===1?(l.up.set(0,0,c[b]),l.lookAt(0,u[b],0)):(l.up.set(0,c[b],0),l.lookAt(0,0,u[b]));const w=this._cubeSize;L_(i,E*w,b>2?w:0,w,w),d.setRenderTarget(i),v&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=y}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Bp||e.mapping===Hp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=_V()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=vV());const a=i?this._cubemapMaterial:this._equirectMaterial,s=new Io(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;L_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,jC)}_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=xV[(i-1)%xV.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,l){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 Io(this._lodPlanes[i],u),g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*vh-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):vh;y>vh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${vh}`);const b=[];let E=0;for(let N=0;N<vh;++N){const F=N/v,k=Math.exp(-F*F/2);b.push(k),N===0?E+=k:N<y&&(E+=2*k)}for(let N=0;N<b.length;N++)b[N]=b[N]/E;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const T=this._sizeLods[i],A=3*T*(i>w-ap?i-w+ap:0),C=4*(this._cubeSize-T);L_(n,A,C,3*T,2*T),c.setRenderTarget(n),c.render(f,jC)}}function h5e(t){const e=[],n=[],r=[];let i=t;const a=t-ap+1+pV.length;for(let s=0;s<a;s++){const l=Math.pow(2,i);n.push(l);let c=1/l;s>t-ap?c=pV[s-t+ap-1]:s===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,y=2,b=1,E=new Float32Array(v*x*p),w=new Float32Array(y*x*p),T=new Float32Array(b*x*p);for(let C=0;C<p;C++){const N=C%3*2/3-1,F=C>2?0:-1,k=[N,F,0,N+2/3,F,0,N+2/3,F+1,0,N,F,0,N+2/3,F+1,0,N,F+1,0];E.set(k,v*x*C),w.set(g,y*x*C);const R=[C,C,C,C,C,C];T.set(R,b*x*C)}const A=new Sa;A.setAttribute("position",new ks(E,v)),A.setAttribute("uv",new ks(w,y)),A.setAttribute("faceIndex",new ks(T,b)),e.push(A),i>ap&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function yV(t,e,n){const r=new ff(t,e,n);return r.texture.mapping=tE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function L_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function f5e(t,e,n){const r=new Float32Array(vh),i=new De(0,1,0);return new Ed({name:"SphericalGaussianBlur",defines:{n:vh,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:VO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:od,depthTest:!1,depthWrite:!1})}function vV(){return new Ed({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:VO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:od,depthTest:!1,depthWrite:!1})}function _V(){return new Ed({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:VO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:od,depthTest:!1,depthWrite:!1})}function VO(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function m5e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===ZP||c===QP,d=c===Bp||c===Hp;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new bV(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new bV(t));const g=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,g),l.addEventListener("dispose",a),g.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function p5e(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 g5e(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 x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const v=g.morphAttributes[x];for(let y=0,b=v.length;y<b;y++)e.remove(v[y])}g.removeEventListener("dispose",s),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function l(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const v=p[x];for(let y=0,b=v.length;y<b;y++)e.update(v[y],t.ARRAY_BUFFER)}}function u(f){const g=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const E=p.array;v=p.version;for(let w=0,T=E.length;w<T;w+=3){const A=E[w+0],C=E[w+1],N=E[w+2];g.push(A,C,C,N,N,A)}}else if(x!==void 0){const E=x.array;v=x.version;for(let w=0,T=E.length/3-1;w<T;w+=3){const A=w+0,C=w+1,N=w+2;g.push(A,C,C,N,N,A)}}else return;const y=new(cQ(g)?xQ:gQ)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function x5e(t,e,n,r){const i=r.isWebGL2;let a;function s(p){a=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(a,x,l,p*c),n.update(x,a,1)}function f(p,x,v){if(v===0)return;let y,b;if(i)y=t,b="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[b](a,x,l,p*c,v),n.update(x,a,v)}function g(p,x,v){if(v===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<v;b++)this.render(p[b]/c,x[b]);else{y.multiDrawElementsWEBGL(a,x,0,l,p,0,v);let b=0;for(let E=0;E<v;E++)b+=x[E];n.update(b,a,1)}}this.setMode=s,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function b5e(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,l){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",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 y5e(t,e){return t[0]-e[0]}function v5e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function _5e(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,s=new nr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=x!==void 0?x.length:0;let y=a.get(d);if(y===void 0||y.count!==v){let V=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",V)};var p=V;y!==void 0&&y.texture.dispose();const w=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,A=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],N=d.morphAttributes.normal||[],F=d.morphAttributes.color||[];let k=0;w===!0&&(k=1),T===!0&&(k=2),A===!0&&(k=3);let R=d.attributes.position.count*k,I=1;R>e.maxTextureSize&&(I=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const L=new Float32Array(R*I*4*v),q=new hQ(L,R,I,v);q.type=Ac,q.needsUpdate=!0;const j=k*4;for(let K=0;K<v;K++){const W=C[K],J=N[K],ee=F[K],Z=R*I*4*K;for(let B=0;B<W.count;B++){const G=B*j;w===!0&&(s.fromBufferAttribute(W,B),L[Z+G+0]=s.x,L[Z+G+1]=s.y,L[Z+G+2]=s.z,L[Z+G+3]=0),T===!0&&(s.fromBufferAttribute(J,B),L[Z+G+4]=s.x,L[Z+G+5]=s.y,L[Z+G+6]=s.z,L[Z+G+7]=0),A===!0&&(s.fromBufferAttribute(ee,B),L[Z+G+8]=s.x,L[Z+G+9]=s.y,L[Z+G+10]=s.z,L[Z+G+11]=ee.itemSize===4?s.w:1)}}y={count:v,texture:q,size:new Qt(R,I)},a.set(d,y),d.addEventListener("dispose",V)}let b=0;for(let w=0;w<g.length;w++)b+=g[w];const E=d.morphTargetsRelative?1:1-b;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",y.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",y.size)}else{const x=g===void 0?0:g.length;let v=r[d.id];if(v===void 0||v.length!==x){v=[];for(let T=0;T<x;T++)v[T]=[T,0];r[d.id]=v}for(let T=0;T<x;T++){const A=v[T];A[0]=T,A[1]=g[T]}v.sort(v5e);for(let T=0;T<8;T++)T<x&&v[T][1]?(l[T][0]=v[T][0],l[T][1]=v[T][1]):(l[T][0]=Number.MAX_SAFE_INTEGER,l[T][1]=0);l.sort(y5e);const y=d.morphAttributes.position,b=d.morphAttributes.normal;let E=0;for(let T=0;T<8;T++){const A=l[T],C=A[0],N=A[1];C!==Number.MAX_SAFE_INTEGER&&N?(y&&d.getAttribute("morphTarget"+T)!==y[C]&&d.setAttribute("morphTarget"+T,y[C]),b&&d.getAttribute("morphNormal"+T)!==b[C]&&d.setAttribute("morphNormal"+T,b[C]),i[T]=N,E+=N):(y&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),b&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const w=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function w5e(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}class wQ extends ns{constructor(e,n,r,i,a,s,l,c,u,d){if(d=d!==void 0?d:zh,d!==zh&&d!==$p)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===zh&&(r=Ju),r===void 0&&d===$p&&(r=Uh),super(null,i,a,s,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:na,this.minFilter=c!==void 0?c:na,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 SQ=new ns,MQ=new wQ(1,1);MQ.compareFunction=oQ;const EQ=new hQ,TQ=new sLe,AQ=new vQ,wV=[],SV=[],MV=new Float32Array(16),EV=new Float32Array(9),TV=new Float32Array(4);function _g(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=wV[i];if(a===void 0&&(a=new Float32Array(i),wV[i]=a),e!==0){r.toArray(a,0);for(let s=1,l=0;s!==e;++s)l+=n,t[s].toArray(a,l)}return a}function wi(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 Si(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function iE(t,e){let n=SV[e];n===void 0&&(n=new Int32Array(e),SV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function S5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function M5e(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(wi(n,e))return;t.uniform2fv(this.addr,e),Si(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.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(wi(n,e))return;t.uniform3fv(this.addr,e),Si(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.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(wi(n,e))return;t.uniform4fv(this.addr,e),Si(n,e)}}function A5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(wi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Si(n,e)}else{if(wi(n,r))return;TV.set(r),t.uniformMatrix2fv(this.addr,!1,TV),Si(n,r)}}function N5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(wi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Si(n,e)}else{if(wi(n,r))return;EV.set(r),t.uniformMatrix3fv(this.addr,!1,EV),Si(n,r)}}function C5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(wi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Si(n,e)}else{if(wi(n,r))return;MV.set(r),t.uniformMatrix4fv(this.addr,!1,MV),Si(n,r)}}function k5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function P5e(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(wi(n,e))return;t.uniform2iv(this.addr,e),Si(n,e)}}function j5e(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(wi(n,e))return;t.uniform3iv(this.addr,e),Si(n,e)}}function R5e(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(wi(n,e))return;t.uniform4iv(this.addr,e),Si(n,e)}}function D5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function O5e(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(wi(n,e))return;t.uniform2uiv(this.addr,e),Si(n,e)}}function L5e(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(wi(n,e))return;t.uniform3uiv(this.addr,e),Si(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||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(wi(n,e))return;t.uniform4uiv(this.addr,e),Si(n,e)}}function F5e(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?MQ:SQ;n.setTexture2D(e||a,i)}function U5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||TQ,i)}function z5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||AQ,i)}function B5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||EQ,i)}function H5e(t){switch(t){case 5126:return S5e;case 35664:return M5e;case 35665:return E5e;case 35666:return T5e;case 35674:return A5e;case 35675:return N5e;case 35676:return C5e;case 5124:case 35670:return k5e;case 35667:case 35671:return P5e;case 35668:case 35672:return j5e;case 35669:case 35673:return R5e;case 5125:return D5e;case 36294:return O5e;case 36295:return L5e;case 36296:return I5e;case 35678:case 36198:case 36298:case 36306:case 35682:return F5e;case 35679:case 36299:case 36307:return U5e;case 35680:case 36300:case 36308:case 36293:return z5e;case 36289:case 36303:case 36311:case 36292:return B5e}}function $5e(t,e){t.uniform1fv(this.addr,e)}function V5e(t,e){const n=_g(e,this.size,2);t.uniform2fv(this.addr,n)}function G5e(t,e){const n=_g(e,this.size,3);t.uniform3fv(this.addr,n)}function W5e(t,e){const n=_g(e,this.size,4);t.uniform4fv(this.addr,n)}function q5e(t,e){const n=_g(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function K5e(t,e){const n=_g(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function X5e(t,e){const n=_g(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Y5e(t,e){t.uniform1iv(this.addr,e)}function Z5e(t,e){t.uniform2iv(this.addr,e)}function Q5e(t,e){t.uniform3iv(this.addr,e)}function J5e(t,e){t.uniform4iv(this.addr,e)}function eFe(t,e){t.uniform1uiv(this.addr,e)}function tFe(t,e){t.uniform2uiv(this.addr,e)}function nFe(t,e){t.uniform3uiv(this.addr,e)}function rFe(t,e){t.uniform4uiv(this.addr,e)}function iFe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||SQ,a[s])}function aFe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||TQ,a[s])}function sFe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||AQ,a[s])}function oFe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||EQ,a[s])}function lFe(t){switch(t){case 5126:return $5e;case 35664:return V5e;case 35665:return G5e;case 35666:return W5e;case 35674:return q5e;case 35675:return K5e;case 35676:return X5e;case 5124:case 35670:return Y5e;case 35667:case 35671:return Z5e;case 35668:case 35672:return Q5e;case 35669:case 35673:return J5e;case 5125:return eFe;case 36294:return tFe;case 36295:return nFe;case 36296:return rFe;case 35678:case 36198:case 36298:case 36306:case 35682:return iFe;case 35679:case 36299:case 36307:return aFe;case 35680:case 36300:case 36308:case 36293:return sFe;case 36289:case 36303:case 36311:case 36292:return oFe}}class cFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=H5e(n.type)}}class uFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=lFe(n.type)}}class dFe{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 l=i[a];l.setValue(e,n[l.id],r)}}}const LC=/(\w+)(\])?(\[|\.)?/g;function AV(t,e){t.seq.push(e),t.map[e.id]=e}function hFe(t,e,n){const r=t.name,i=r.length;for(LC.lastIndex=0;;){const a=LC.exec(r),s=LC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&s+2===i){AV(n,u===void 0?new cFe(l,t,e):new uFe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new dFe(l),AV(n,f)),n=f}}}class E1{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);hFe(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 l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}}function NV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const fFe=37297;let mFe=0;function pFe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const l=s+1;r.push(`${l===e?">":" "} ${l}: ${n[s]}`)}return r.join(`
- `)}function gFe(t){const e=er.getPrimaries(er.workingColorSpace),n=er.getPrimaries(t);let r;switch(e===n?r="":e===Kw&&n===qw?r="LinearDisplayP3ToLinearSRGB":e===qw&&n===Kw&&(r="LinearSRGBToLinearDisplayP3"),t){case Kc:case nE:return[r,"LinearTransferOETF"];case ra:case UO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function CV(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()+`
- `+i+`
- `+pFe(t.getShaderSource(e),s)}else return i}function xFe(t,e){const n=gFe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function bFe(t,e){let n;switch(e){case xOe:n="Linear";break;case bOe:n="Reinhard";break;case yOe:n="OptimizedCineon";break;case vOe:n="ACESFilmic";break;case _Oe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function yFe(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(Xx).join(`
- `)}function vFe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function _Fe(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 l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:l}}return n}function Xx(t){return t!==""}function kV(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 PV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const wFe=/^[ \t]*#include +<([\w\d./]+)>/gm;function ij(t){return t.replace(wFe,MFe)}const SFe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function MFe(t,e){let n=un[e];if(n===void 0){const r=SFe.get(e);if(r!==void 0)n=un[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 ij(n)}const EFe=/#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 jV(t){return t.replace(EFe,TFe)}function TFe(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 RV(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function AFe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===YZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===GDe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===mc&&(e="SHADOWMAP_TYPE_VSM"),e}function NFe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Bp:case Hp:e="ENVMAP_TYPE_CUBE";break;case tE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function CFe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Hp:e="ENVMAP_MODE_REFRACTION";break}return e}function kFe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case IO:e="ENVMAP_BLENDING_MULTIPLY";break;case pOe:e="ENVMAP_BLENDING_MIX";break;case gOe:e="ENVMAP_BLENDING_ADD";break}return e}function PFe(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 jFe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,l=n.fragmentShader;const c=AFe(n),u=NFe(n),d=CFe(n),f=kFe(n),g=PFe(n),p=n.isWebGL2?"":yFe(n),x=vFe(a),v=i.createProgram();let y,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Xx).join(`
- `),y.length>0&&(y+=`
- `),b=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Xx).join(`
- `),b.length>0&&(b+=`
- `)):(y=[RV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Xx).join(`
- `),b=[p,RV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ld?"#define TONE_MAPPING":"",n.toneMapping!==ld?un.tonemapping_pars_fragment:"",n.toneMapping!==ld?bFe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",un.colorspace_pars_fragment,xFe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Xx).join(`
- `)),s=ij(s),s=kV(s,n),s=PV(s,n),l=ij(l),l=kV(l,n),l=PV(l,n),s=jV(s),l=jV(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,b=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===Z$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Z$?"":"#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(`
- `)+`
- `+b);const w=E+y+s,T=E+b+l,A=NV(i,i.VERTEX_SHADER,w),C=NV(i,i.FRAGMENT_SHADER,T);i.attachShader(v,A),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(I){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v).trim(),q=i.getShaderInfoLog(A).trim(),j=i.getShaderInfoLog(C).trim();let V=!0,K=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(V=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,A,C);else{const W=CV(i,A,"vertex"),J=CV(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Program Info Log: `+L+`
- `+W+`
- `+J)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(q===""||j==="")&&(K=!1);K&&(I.diagnostics={runnable:V,programLog:L,vertexShader:{log:q,prefix:y},fragmentShader:{log:j,prefix:b}})}i.deleteShader(A),i.deleteShader(C),F=new E1(i,v),k=_Fe(i,v)}let F;this.getUniforms=function(){return F===void 0&&N(this),F};let k;this.getAttributes=function(){return k===void 0&&N(this),k};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(v,fFe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mFe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=A,this.fragmentShader=C,this}let RFe=0;class DFe{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 OFe(e),n.set(e,r)),r}}class OFe{constructor(e){this.id=RFe++,this.code=e,this.usedTimes=0}}function LFe(t,e,n,r,i,a,s){const l=new fQ,c=new DFe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(k){return k===0?"uv":`uv${k}`}function y(k,R,I,L,q){const j=L.fog,V=q.geometry,K=k.isMeshStandardMaterial?L.environment:null,W=(k.isMeshStandardMaterial?n:e).get(k.envMap||K),J=W&&W.mapping===tE?W.image.height:null,ee=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&console.warn("THREE.WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const Z=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,B=Z!==void 0?Z.length:0;let G=0;V.morphAttributes.position!==void 0&&(G=1),V.morphAttributes.normal!==void 0&&(G=2),V.morphAttributes.color!==void 0&&(G=3);let Q,te,he,oe;if(ee){const qt=Za[ee];Q=qt.vertexShader,te=qt.fragmentShader}else Q=k.vertexShader,te=k.fragmentShader,c.update(k),he=c.getVertexShaderID(k),oe=c.getFragmentShaderID(k);const xe=t.getRenderTarget(),Te=q.isInstancedMesh===!0,me=q.isBatchedMesh===!0,ce=!!k.map,Ce=!!k.matcap,fe=!!W,Ie=!!k.aoMap,z=!!k.lightMap,H=!!k.bumpMap,re=!!k.normalMap,$=!!k.displacementMap,Y=!!k.emissiveMap,se=!!k.metalnessMap,ue=!!k.roughnessMap,Ee=k.anisotropy>0,Me=k.clearcoat>0,U=k.iridescence>0,O=k.sheen>0,ne=k.transmission>0,be=Ee&&!!k.anisotropyMap,ye=Me&&!!k.clearcoatMap,_e=Me&&!!k.clearcoatNormalMap,We=Me&&!!k.clearcoatRoughnessMap,Ve=U&&!!k.iridescenceMap,Ye=U&&!!k.iridescenceThicknessMap,lt=O&&!!k.sheenColorMap,de=O&&!!k.sheenRoughnessMap,ae=!!k.specularMap,ze=!!k.specularColorMap,Ue=!!k.specularIntensityMap,et=ne&&!!k.transmissionMap,dt=ne&&!!k.thicknessMap,pe=!!k.gradientMap,nt=!!k.alphaMap,ve=k.alphaTest>0,He=!!k.alphaHash,je=!!k.extensions,we=!!V.attributes.uv1,Xe=!!V.attributes.uv2,ot=!!V.attributes.uv3;let St=ld;return k.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(St=t.toneMapping),{isWebGL2:d,shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:Q,fragmentShader:te,defines:k.defines,customVertexShaderID:he,customFragmentShaderID:oe,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:me,instancing:Te,instancingColor:Te&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Kc,map:ce,matcap:Ce,envMap:fe,envMapMode:fe&&W.mapping,envMapCubeUVHeight:J,aoMap:Ie,lightMap:z,bumpMap:H,normalMap:re,displacementMap:g&&$,emissiveMap:Y,normalMapObjectSpace:re&&k.normalMapType===ROe,normalMapTangentSpace:re&&k.normalMapType===sQ,metalnessMap:se,roughnessMap:ue,anisotropy:Ee,anisotropyMap:be,clearcoat:Me,clearcoatMap:ye,clearcoatNormalMap:_e,clearcoatRoughnessMap:We,iridescence:U,iridescenceMap:Ve,iridescenceThicknessMap:Ye,sheen:O,sheenColorMap:lt,sheenRoughnessMap:de,specularMap:ae,specularColorMap:ze,specularIntensityMap:Ue,transmission:ne,transmissionMap:et,thicknessMap:dt,gradientMap:pe,opaque:k.transparent===!1&&k.blending===mp,alphaMap:nt,alphaTest:ve,alphaHash:He,combine:k.combine,mapUv:ce&&v(k.map.channel),aoMapUv:Ie&&v(k.aoMap.channel),lightMapUv:z&&v(k.lightMap.channel),bumpMapUv:H&&v(k.bumpMap.channel),normalMapUv:re&&v(k.normalMap.channel),displacementMapUv:$&&v(k.displacementMap.channel),emissiveMapUv:Y&&v(k.emissiveMap.channel),metalnessMapUv:se&&v(k.metalnessMap.channel),roughnessMapUv:ue&&v(k.roughnessMap.channel),anisotropyMapUv:be&&v(k.anisotropyMap.channel),clearcoatMapUv:ye&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:_e&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:We&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:Ye&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:de&&v(k.sheenRoughnessMap.channel),specularMapUv:ae&&v(k.specularMap.channel),specularColorMapUv:ze&&v(k.specularColorMap.channel),specularIntensityMapUv:Ue&&v(k.specularIntensityMap.channel),transmissionMapUv:et&&v(k.transmissionMap.channel),thicknessMapUv:dt&&v(k.thicknessMap.channel),alphaMapUv:nt&&v(k.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(re||Ee),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:we,vertexUv2s:Xe,vertexUv3s:ot,pointsUvs:q.isPoints===!0&&!!V.attributes.uv&&(ce||nt),fog:!!j,useFog:k.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:k.flatShading===!0,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:G,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&I.length>0,shadowMapType:t.shadowMap.type,toneMapping:St,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ce&&k.map.isVideoTexture===!0&&er.getTransfer(k.map.colorSpace)===mr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===vc,flipSided:k.side===ts,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionDerivatives:je&&k.extensions.derivatives===!0,extensionFragDepth:je&&k.extensions.fragDepth===!0,extensionDrawBuffers:je&&k.extensions.drawBuffers===!0,extensionShaderTextureLOD:je&&k.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()}}function b(k){const R=[];if(k.shaderID?R.push(k.shaderID):(R.push(k.customVertexShaderID),R.push(k.customFragmentShaderID)),k.defines!==void 0)for(const I in k.defines)R.push(I),R.push(k.defines[I]);return k.isRawShaderMaterial===!1&&(E(R,k),w(R,k),R.push(t.outputColorSpace)),R.push(k.customProgramCacheKey),R.join()}function E(k,R){k.push(R.precision),k.push(R.outputColorSpace),k.push(R.envMapMode),k.push(R.envMapCubeUVHeight),k.push(R.mapUv),k.push(R.alphaMapUv),k.push(R.lightMapUv),k.push(R.aoMapUv),k.push(R.bumpMapUv),k.push(R.normalMapUv),k.push(R.displacementMapUv),k.push(R.emissiveMapUv),k.push(R.metalnessMapUv),k.push(R.roughnessMapUv),k.push(R.anisotropyMapUv),k.push(R.clearcoatMapUv),k.push(R.clearcoatNormalMapUv),k.push(R.clearcoatRoughnessMapUv),k.push(R.iridescenceMapUv),k.push(R.iridescenceThicknessMapUv),k.push(R.sheenColorMapUv),k.push(R.sheenRoughnessMapUv),k.push(R.specularMapUv),k.push(R.specularColorMapUv),k.push(R.specularIntensityMapUv),k.push(R.transmissionMapUv),k.push(R.thicknessMapUv),k.push(R.combine),k.push(R.fogExp2),k.push(R.sizeAttenuation),k.push(R.morphTargetsCount),k.push(R.morphAttributeCount),k.push(R.numDirLights),k.push(R.numPointLights),k.push(R.numSpotLights),k.push(R.numSpotLightMaps),k.push(R.numHemiLights),k.push(R.numRectAreaLights),k.push(R.numDirLightShadows),k.push(R.numPointLightShadows),k.push(R.numSpotLightShadows),k.push(R.numSpotLightShadowsWithMaps),k.push(R.numLightProbes),k.push(R.shadowMapType),k.push(R.toneMapping),k.push(R.numClippingPlanes),k.push(R.numClipIntersection),k.push(R.depthPacking)}function w(k,R){l.disableAll(),R.isWebGL2&&l.enable(0),R.supportsVertexTextures&&l.enable(1),R.instancing&&l.enable(2),R.instancingColor&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),k.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.skinning&&l.enable(4),R.morphTargets&&l.enable(5),R.morphNormals&&l.enable(6),R.morphColors&&l.enable(7),R.premultipliedAlpha&&l.enable(8),R.shadowMapEnabled&&l.enable(9),R.useLegacyLights&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),k.push(l.mask)}function T(k){const R=x[k.type];let I;if(R){const L=Za[R];I=HO.clone(L.uniforms)}else I=k.uniforms;return I}function A(k,R){let I;for(let L=0,q=u.length;L<q;L++){const j=u[L];if(j.cacheKey===R){I=j,++I.usedTimes;break}}return I===void 0&&(I=new jFe(t,R,k,a),u.push(I)),I}function C(k){if(--k.usedTimes===0){const R=u.indexOf(k);u[R]=u[u.length-1],u.pop(),k.destroy()}}function N(k){c.remove(k)}function F(){c.dispose()}return{getParameters:y,getProgramCacheKey:b,getUniforms:T,acquireProgram:A,releaseProgram:C,releaseShaderCache:N,programs:u,dispose:F}}function IFe(){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,l){t.get(a)[s]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function FFe(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 DV(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 OV(){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,p,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=p,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=v,b.group=y),e++,b}function l(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.push(b):p.transparent===!0?i.push(b):n.push(b)}function c(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.unshift(b):p.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||FFe),r.length>1&&r.sort(g||DV),i.length>1&&i.sort(g||DV)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function UFe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new OV,t.set(r,[s])):i>=a.length?(s=new OV,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function zFe(){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 De,color:new Vt};break;case"SpotLight":n={position:new De,direction:new De,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new De,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new De,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":n={color:new Vt,position:new De,halfWidth:new De,halfHeight:new De};break}return t[e.id]=n,n}}}function BFe(){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 Qt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Qt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Qt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let HFe=0;function $Fe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function VFe(t,e){const n=new zFe,r=BFe(),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 De);const a=new De,s=new dr,l=new dr;function c(d,f){let g=0,p=0,x=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let v=0,y=0,b=0,E=0,w=0,T=0,A=0,C=0,N=0,F=0,k=0;d.sort($Fe);const R=f===!0?Math.PI:1;for(let L=0,q=d.length;L<q;L++){const j=d[L],V=j.color,K=j.intensity,W=j.distance,J=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)g+=V.r*K*R,p+=V.g*K*R,x+=V.b*K*R;else if(j.isLightProbe){for(let ee=0;ee<9;ee++)i.probe[ee].addScaledVector(j.sh.coefficients[ee],K);k++}else if(j.isDirectionalLight){const ee=n.get(j);if(ee.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const Z=j.shadow,B=r.get(j);B.shadowBias=Z.bias,B.shadowNormalBias=Z.normalBias,B.shadowRadius=Z.radius,B.shadowMapSize=Z.mapSize,i.directionalShadow[v]=B,i.directionalShadowMap[v]=J,i.directionalShadowMatrix[v]=j.shadow.matrix,T++}i.directional[v]=ee,v++}else if(j.isSpotLight){const ee=n.get(j);ee.position.setFromMatrixPosition(j.matrixWorld),ee.color.copy(V).multiplyScalar(K*R),ee.distance=W,ee.coneCos=Math.cos(j.angle),ee.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),ee.decay=j.decay,i.spot[b]=ee;const Z=j.shadow;if(j.map&&(i.spotLightMap[N]=j.map,N++,Z.updateMatrices(j),j.castShadow&&F++),i.spotLightMatrix[b]=Z.matrix,j.castShadow){const B=r.get(j);B.shadowBias=Z.bias,B.shadowNormalBias=Z.normalBias,B.shadowRadius=Z.radius,B.shadowMapSize=Z.mapSize,i.spotShadow[b]=B,i.spotShadowMap[b]=J,C++}b++}else if(j.isRectAreaLight){const ee=n.get(j);ee.color.copy(V).multiplyScalar(K),ee.halfWidth.set(j.width*.5,0,0),ee.halfHeight.set(0,j.height*.5,0),i.rectArea[E]=ee,E++}else if(j.isPointLight){const ee=n.get(j);if(ee.color.copy(j.color).multiplyScalar(j.intensity*R),ee.distance=j.distance,ee.decay=j.decay,j.castShadow){const Z=j.shadow,B=r.get(j);B.shadowBias=Z.bias,B.shadowNormalBias=Z.normalBias,B.shadowRadius=Z.radius,B.shadowMapSize=Z.mapSize,B.shadowCameraNear=Z.camera.near,B.shadowCameraFar=Z.camera.far,i.pointShadow[y]=B,i.pointShadowMap[y]=J,i.pointShadowMatrix[y]=j.shadow.matrix,A++}i.point[y]=ee,y++}else if(j.isHemisphereLight){const ee=n.get(j);ee.skyColor.copy(j.color).multiplyScalar(K*R),ee.groundColor.copy(j.groundColor).multiplyScalar(K*R),i.hemi[w]=ee,w++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Tt.LTC_FLOAT_1,i.rectAreaLTC2=Tt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Tt.LTC_HALF_1,i.rectAreaLTC2=Tt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=p,i.ambient[2]=x;const I=i.hash;(I.directionalLength!==v||I.pointLength!==y||I.spotLength!==b||I.rectAreaLength!==E||I.hemiLength!==w||I.numDirectionalShadows!==T||I.numPointShadows!==A||I.numSpotShadows!==C||I.numSpotMaps!==N||I.numLightProbes!==k)&&(i.directional.length=v,i.spot.length=b,i.rectArea.length=E,i.point.length=y,i.hemi.length=w,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=C+N-F,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=F,i.numLightProbes=k,I.directionalLength=v,I.pointLength=y,I.spotLength=b,I.rectAreaLength=E,I.hemiLength=w,I.numDirectionalShadows=T,I.numPointShadows=A,I.numSpotShadows=C,I.numSpotMaps=N,I.numLightProbes=k,i.version=HFe++)}function u(d,f){let g=0,p=0,x=0,v=0,y=0;const b=f.matrixWorldInverse;for(let E=0,w=d.length;E<w;E++){const T=d[E];if(T.isDirectionalLight){const A=i.directional[g];A.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(b),g++}else if(T.isSpotLight){const A=i.spot[x];A.position.setFromMatrixPosition(T.matrixWorld),A.position.applyMatrix4(b),A.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(b),x++}else if(T.isRectAreaLight){const A=i.rectArea[v];A.position.setFromMatrixPosition(T.matrixWorld),A.position.applyMatrix4(b),l.identity(),s.copy(T.matrixWorld),s.premultiply(b),l.extractRotation(s),A.halfWidth.set(T.width*.5,0,0),A.halfHeight.set(0,T.height*.5,0),A.halfWidth.applyMatrix4(l),A.halfHeight.applyMatrix4(l),v++}else if(T.isPointLight){const A=i.point[p];A.position.setFromMatrixPosition(T.matrixWorld),A.position.applyMatrix4(b),p++}else if(T.isHemisphereLight){const A=i.hemi[y];A.direction.setFromMatrixPosition(T.matrixWorld),A.direction.transformDirection(b),y++}}}return{setup:c,setupView:u,state:i}}function LV(t,e){const n=new VFe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function s(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:s,pushShadow:l}}function GFe(t,e){let n=new WeakMap;function r(a,s=0){const l=n.get(a);let c;return l===void 0?(c=new LV(t,e),n.set(a,[c])):s>=l.length?(c=new LV(t,e),l.push(c)):c=l[s],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class WFe extends vg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=POe,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 qFe extends vg{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 KFe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,XFe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function YFe(t,e,n){let r=new rE;const i=new Qt,a=new Qt,s=new nr,l=new WFe({depthPacking:jOe}),c=new qFe,u={},d=n.maxTextureSize,f={[Md]:ts,[ts]:Md,[vc]:vc},g=new Ed({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Qt},radius:{value:4}},vertexShader:KFe,fragmentShader:XFe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Sa;x.setAttribute("position",new ks(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Io(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=YZ;let b=this.type;this.render=function(A,C,N){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||A.length===0)return;const F=t.getRenderTarget(),k=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),I=t.state;I.setBlending(od),I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const L=b!==mc&&this.type===mc,q=b===mc&&this.type!==mc;for(let j=0,V=A.length;j<V;j++){const K=A[j],W=K.shadow;if(W===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);const J=W.getFrameExtents();if(i.multiply(J),a.copy(W.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,W.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,W.mapSize.y=a.y)),W.map===null||L===!0||q===!0){const Z=this.type!==mc?{minFilter:na,magFilter:na}:{};W.map!==null&&W.map.dispose(),W.map=new ff(i.x,i.y,Z),W.map.texture.name=K.name+".shadowMap",W.camera.updateProjectionMatrix()}t.setRenderTarget(W.map),t.clear();const ee=W.getViewportCount();for(let Z=0;Z<ee;Z++){const B=W.getViewport(Z);s.set(a.x*B.x,a.y*B.y,a.x*B.z,a.y*B.w),I.viewport(s),W.updateMatrices(K,Z),r=W.getFrustum(),T(C,N,W.camera,K,this.type)}W.isPointLightShadow!==!0&&this.type===mc&&E(W,N),W.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(F,k,R)};function E(A,C){const N=e.update(v);g.defines.VSM_SAMPLES!==A.blurSamples&&(g.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new ff(i.x,i.y)),g.uniforms.shadow_pass.value=A.map.texture,g.uniforms.resolution.value=A.mapSize,g.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(C,null,N,g,v,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(C,null,N,p,v,null)}function w(A,C,N,F){let k=null;const R=N.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(R!==void 0)k=R;else if(k=N.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const I=k.uuid,L=C.uuid;let q=u[I];q===void 0&&(q={},u[I]=q);let j=q[L];j===void 0&&(j=k.clone(),q[L]=j),k=j}if(k.visible=C.visible,k.wireframe=C.wireframe,F===mc?k.side=C.shadowSide!==null?C.shadowSide:C.side:k.side=C.shadowSide!==null?C.shadowSide:f[C.side],k.alphaMap=C.alphaMap,k.alphaTest=C.alphaTest,k.map=C.map,k.clipShadows=C.clipShadows,k.clippingPlanes=C.clippingPlanes,k.clipIntersection=C.clipIntersection,k.displacementMap=C.displacementMap,k.displacementScale=C.displacementScale,k.displacementBias=C.displacementBias,k.wireframeLinewidth=C.wireframeLinewidth,k.linewidth=C.linewidth,N.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const I=t.properties.get(k);I.light=N}return k}function T(A,C,N,F,k){if(A.visible===!1)return;if(A.layers.test(C.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&k===mc)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,A.matrixWorld);const L=e.update(A),q=A.material;if(Array.isArray(q)){const j=L.groups;for(let V=0,K=j.length;V<K;V++){const W=j[V],J=q[W.materialIndex];if(J&&J.visible){const ee=w(A,J,F,k);A.onBeforeShadow(t,A,C,N,L,ee,W),t.renderBufferDirect(N,null,L,ee,A,W),A.onAfterShadow(t,A,C,N,L,ee,W)}}}else if(q.visible){const j=w(A,q,F,k);A.onBeforeShadow(t,A,C,N,L,j,null),t.renderBufferDirect(N,null,L,j,A,null),A.onAfterShadow(t,A,C,N,L,j,null)}}const I=A.children;for(let L=0,q=I.length;L<q;L++)T(I[L],C,N,F,k)}}function ZFe(t,e,n){const r=n.isWebGL2;function i(){let ve=!1;const He=new nr;let je=null;const we=new nr(0,0,0,0);return{setMask:function(Xe){je!==Xe&&!ve&&(t.colorMask(Xe,Xe,Xe,Xe),je=Xe)},setLocked:function(Xe){ve=Xe},setClear:function(Xe,ot,St,Dt,qt){qt===!0&&(Xe*=Dt,ot*=Dt,St*=Dt),He.set(Xe,ot,St,Dt),we.equals(He)===!1&&(t.clearColor(Xe,ot,St,Dt),we.copy(He))},reset:function(){ve=!1,je=null,we.set(-1,0,0,0)}}}function a(){let ve=!1,He=null,je=null,we=null;return{setTest:function(Xe){Xe?me(t.DEPTH_TEST):ce(t.DEPTH_TEST)},setMask:function(Xe){He!==Xe&&!ve&&(t.depthMask(Xe),He=Xe)},setFunc:function(Xe){if(je!==Xe){switch(Xe){case lOe:t.depthFunc(t.NEVER);break;case cOe:t.depthFunc(t.ALWAYS);break;case uOe:t.depthFunc(t.LESS);break;case Gw:t.depthFunc(t.LEQUAL);break;case dOe:t.depthFunc(t.EQUAL);break;case hOe:t.depthFunc(t.GEQUAL);break;case fOe:t.depthFunc(t.GREATER);break;case mOe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}je=Xe}},setLocked:function(Xe){ve=Xe},setClear:function(Xe){we!==Xe&&(t.clearDepth(Xe),we=Xe)},reset:function(){ve=!1,He=null,je=null,we=null}}}function s(){let ve=!1,He=null,je=null,we=null,Xe=null,ot=null,St=null,Dt=null,qt=null;return{setTest:function(Ft){ve||(Ft?me(t.STENCIL_TEST):ce(t.STENCIL_TEST))},setMask:function(Ft){He!==Ft&&!ve&&(t.stencilMask(Ft),He=Ft)},setFunc:function(Ft,kn,Nn){(je!==Ft||we!==kn||Xe!==Nn)&&(t.stencilFunc(Ft,kn,Nn),je=Ft,we=kn,Xe=Nn)},setOp:function(Ft,kn,Nn){(ot!==Ft||St!==kn||Dt!==Nn)&&(t.stencilOp(Ft,kn,Nn),ot=Ft,St=kn,Dt=Nn)},setLocked:function(Ft){ve=Ft},setClear:function(Ft){qt!==Ft&&(t.clearStencil(Ft),qt=Ft)},reset:function(){ve=!1,He=null,je=null,we=null,Xe=null,ot=null,St=null,Dt=null,qt=null}}}const l=new i,c=new a,u=new s,d=new WeakMap,f=new WeakMap;let g={},p={},x=new WeakMap,v=[],y=null,b=!1,E=null,w=null,T=null,A=null,C=null,N=null,F=null,k=new Vt(0,0,0),R=0,I=!1,L=null,q=null,j=null,V=null,K=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,ee=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(Z)[1]),J=ee>=1):Z.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),J=ee>=2);let B=null,G={};const Q=t.getParameter(t.SCISSOR_BOX),te=t.getParameter(t.VIEWPORT),he=new nr().fromArray(Q),oe=new nr().fromArray(te);function xe(ve,He,je,we){const Xe=new Uint8Array(4),ot=t.createTexture();t.bindTexture(ve,ot),t.texParameteri(ve,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ve,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let St=0;St<je;St++)r&&(ve===t.TEXTURE_3D||ve===t.TEXTURE_2D_ARRAY)?t.texImage3D(He,0,t.RGBA,1,1,we,0,t.RGBA,t.UNSIGNED_BYTE,Xe):t.texImage2D(He+St,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Xe);return ot}const Te={};Te[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),Te[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Te[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Te[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),me(t.DEPTH_TEST),c.setFunc(Gw),Y(!1),se(b$),me(t.CULL_FACE),re(od);function me(ve){g[ve]!==!0&&(t.enable(ve),g[ve]=!0)}function ce(ve){g[ve]!==!1&&(t.disable(ve),g[ve]=!1)}function Ce(ve,He){return p[ve]!==He?(t.bindFramebuffer(ve,He),p[ve]=He,r&&(ve===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=He),ve===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=He)),!0):!1}function fe(ve,He){let je=v,we=!1;if(ve)if(je=x.get(He),je===void 0&&(je=[],x.set(He,je)),ve.isWebGLMultipleRenderTargets){const Xe=ve.texture;if(je.length!==Xe.length||je[0]!==t.COLOR_ATTACHMENT0){for(let ot=0,St=Xe.length;ot<St;ot++)je[ot]=t.COLOR_ATTACHMENT0+ot;je.length=Xe.length,we=!0}}else je[0]!==t.COLOR_ATTACHMENT0&&(je[0]=t.COLOR_ATTACHMENT0,we=!0);else je[0]!==t.BACK&&(je[0]=t.BACK,we=!0);we&&(n.isWebGL2?t.drawBuffers(je):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(je))}function Ie(ve){return y!==ve?(t.useProgram(ve),y=ve,!0):!1}const z={[yh]:t.FUNC_ADD,[qDe]:t.FUNC_SUBTRACT,[KDe]:t.FUNC_REVERSE_SUBTRACT};if(r)z[w$]=t.MIN,z[S$]=t.MAX;else{const ve=e.get("EXT_blend_minmax");ve!==null&&(z[w$]=ve.MIN_EXT,z[S$]=ve.MAX_EXT)}const H={[XDe]:t.ZERO,[YDe]:t.ONE,[ZDe]:t.SRC_COLOR,[XP]:t.SRC_ALPHA,[rOe]:t.SRC_ALPHA_SATURATE,[tOe]:t.DST_COLOR,[JDe]:t.DST_ALPHA,[QDe]:t.ONE_MINUS_SRC_COLOR,[YP]:t.ONE_MINUS_SRC_ALPHA,[nOe]:t.ONE_MINUS_DST_COLOR,[eOe]:t.ONE_MINUS_DST_ALPHA,[iOe]:t.CONSTANT_COLOR,[aOe]:t.ONE_MINUS_CONSTANT_COLOR,[sOe]:t.CONSTANT_ALPHA,[oOe]:t.ONE_MINUS_CONSTANT_ALPHA};function re(ve,He,je,we,Xe,ot,St,Dt,qt,Ft){if(ve===od){b===!0&&(ce(t.BLEND),b=!1);return}if(b===!1&&(me(t.BLEND),b=!0),ve!==WDe){if(ve!==E||Ft!==I){if((w!==yh||C!==yh)&&(t.blendEquation(t.FUNC_ADD),w=yh,C=yh),Ft)switch(ve){case mp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case y$:t.blendFunc(t.ONE,t.ONE);break;case v$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case _$:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}else switch(ve){case mp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case y$:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case v$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case _$:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}T=null,A=null,N=null,F=null,k.set(0,0,0),R=0,E=ve,I=Ft}return}Xe=Xe||He,ot=ot||je,St=St||we,(He!==w||Xe!==C)&&(t.blendEquationSeparate(z[He],z[Xe]),w=He,C=Xe),(je!==T||we!==A||ot!==N||St!==F)&&(t.blendFuncSeparate(H[je],H[we],H[ot],H[St]),T=je,A=we,N=ot,F=St),(Dt.equals(k)===!1||qt!==R)&&(t.blendColor(Dt.r,Dt.g,Dt.b,qt),k.copy(Dt),R=qt),E=ve,I=!1}function $(ve,He){ve.side===vc?ce(t.CULL_FACE):me(t.CULL_FACE);let je=ve.side===ts;He&&(je=!je),Y(je),ve.blending===mp&&ve.transparent===!1?re(od):re(ve.blending,ve.blendEquation,ve.blendSrc,ve.blendDst,ve.blendEquationAlpha,ve.blendSrcAlpha,ve.blendDstAlpha,ve.blendColor,ve.blendAlpha,ve.premultipliedAlpha),c.setFunc(ve.depthFunc),c.setTest(ve.depthTest),c.setMask(ve.depthWrite),l.setMask(ve.colorWrite);const we=ve.stencilWrite;u.setTest(we),we&&(u.setMask(ve.stencilWriteMask),u.setFunc(ve.stencilFunc,ve.stencilRef,ve.stencilFuncMask),u.setOp(ve.stencilFail,ve.stencilZFail,ve.stencilZPass)),Ee(ve.polygonOffset,ve.polygonOffsetFactor,ve.polygonOffsetUnits),ve.alphaToCoverage===!0?me(t.SAMPLE_ALPHA_TO_COVERAGE):ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function Y(ve){L!==ve&&(ve?t.frontFace(t.CW):t.frontFace(t.CCW),L=ve)}function se(ve){ve!==$De?(me(t.CULL_FACE),ve!==q&&(ve===b$?t.cullFace(t.BACK):ve===VDe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ce(t.CULL_FACE),q=ve}function ue(ve){ve!==j&&(J&&t.lineWidth(ve),j=ve)}function Ee(ve,He,je){ve?(me(t.POLYGON_OFFSET_FILL),(V!==He||K!==je)&&(t.polygonOffset(He,je),V=He,K=je)):ce(t.POLYGON_OFFSET_FILL)}function Me(ve){ve?me(t.SCISSOR_TEST):ce(t.SCISSOR_TEST)}function U(ve){ve===void 0&&(ve=t.TEXTURE0+W-1),B!==ve&&(t.activeTexture(ve),B=ve)}function O(ve,He,je){je===void 0&&(B===null?je=t.TEXTURE0+W-1:je=B);let we=G[je];we===void 0&&(we={type:void 0,texture:void 0},G[je]=we),(we.type!==ve||we.texture!==He)&&(B!==je&&(t.activeTexture(je),B=je),t.bindTexture(ve,He||Te[ve]),we.type=ve,we.texture=He)}function ne(){const ve=G[B];ve!==void 0&&ve.type!==void 0&&(t.bindTexture(ve.type,null),ve.type=void 0,ve.texture=void 0)}function be(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ye(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function _e(){try{t.texSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function We(){try{t.texSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ve(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ye(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function lt(){try{t.texStorage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function de(){try{t.texStorage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ae(){try{t.texImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ze(){try{t.texImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ue(ve){he.equals(ve)===!1&&(t.scissor(ve.x,ve.y,ve.z,ve.w),he.copy(ve))}function et(ve){oe.equals(ve)===!1&&(t.viewport(ve.x,ve.y,ve.z,ve.w),oe.copy(ve))}function dt(ve,He){let je=f.get(He);je===void 0&&(je=new WeakMap,f.set(He,je));let we=je.get(ve);we===void 0&&(we=t.getUniformBlockIndex(He,ve.name),je.set(ve,we))}function pe(ve,He){const we=f.get(He).get(ve);d.get(He)!==we&&(t.uniformBlockBinding(He,we,ve.__bindingPointIndex),d.set(He,we))}function nt(){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={},B=null,G={},p={},x=new WeakMap,v=[],y=null,b=!1,E=null,w=null,T=null,A=null,C=null,N=null,F=null,k=new Vt(0,0,0),R=0,I=!1,L=null,q=null,j=null,V=null,K=null,he.set(0,0,t.canvas.width,t.canvas.height),oe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:me,disable:ce,bindFramebuffer:Ce,drawBuffers:fe,useProgram:Ie,setBlending:re,setMaterial:$,setFlipSided:Y,setCullFace:se,setLineWidth:ue,setPolygonOffset:Ee,setScissorTest:Me,activeTexture:U,bindTexture:O,unbindTexture:ne,compressedTexImage2D:be,compressedTexImage3D:ye,texImage2D:ae,texImage3D:ze,updateUBOMapping:dt,uniformBlockBinding:pe,texStorage2D:lt,texStorage3D:de,texSubImage2D:_e,texSubImage3D:We,compressedTexSubImage2D:Ve,compressedTexSubImage3D:Ye,scissor:Ue,viewport:et,reset:nt}}function QFe(t,e,n,r,i,a,s){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let v;const y=new WeakMap;let b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(U,O){return b?new OffscreenCanvas(U,O):Yw("canvas")}function w(U,O,ne,be){let ye=1;if((U.width>be||U.height>be)&&(ye=be/Math.max(U.width,U.height)),ye<1||O===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const _e=O?Xw:Math.floor,We=_e(ye*U.width),Ve=_e(ye*U.height);v===void 0&&(v=E(We,Ve));const Ye=ne?E(We,Ve):v;return Ye.width=We,Ye.height=Ve,Ye.getContext("2d").drawImage(U,0,0,We,Ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+We+"x"+Ve+")."),Ye}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function T(U){return rj(U.width)&&rj(U.height)}function A(U){return l?!1:U.wrapS!==Do||U.wrapT!==Do||U.minFilter!==na&&U.minFilter!==to}function C(U,O){return U.generateMipmaps&&O&&U.minFilter!==na&&U.minFilter!==to}function N(U){t.generateMipmap(U)}function F(U,O,ne,be,ye=!1){if(l===!1)return O;if(U!==null){if(t[U]!==void 0)return t[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let _e=O;if(O===t.RED&&(ne===t.FLOAT&&(_e=t.R32F),ne===t.HALF_FLOAT&&(_e=t.R16F),ne===t.UNSIGNED_BYTE&&(_e=t.R8)),O===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(_e=t.R8UI),ne===t.UNSIGNED_SHORT&&(_e=t.R16UI),ne===t.UNSIGNED_INT&&(_e=t.R32UI),ne===t.BYTE&&(_e=t.R8I),ne===t.SHORT&&(_e=t.R16I),ne===t.INT&&(_e=t.R32I)),O===t.RG&&(ne===t.FLOAT&&(_e=t.RG32F),ne===t.HALF_FLOAT&&(_e=t.RG16F),ne===t.UNSIGNED_BYTE&&(_e=t.RG8)),O===t.RGBA){const We=ye?Ww:er.getTransfer(be);ne===t.FLOAT&&(_e=t.RGBA32F),ne===t.HALF_FLOAT&&(_e=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(_e=We===mr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(_e=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(_e=t.RGB5_A1)}return(_e===t.R16F||_e===t.R32F||_e===t.RG16F||_e===t.RG32F||_e===t.RGBA16F||_e===t.RGBA32F)&&e.get("EXT_color_buffer_float"),_e}function k(U,O,ne){return C(U,ne)===!0||U.isFramebufferTexture&&U.minFilter!==na&&U.minFilter!==to?Math.log2(Math.max(O.width,O.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?O.mipmaps.length:1}function R(U){return U===na||U===M$||U===cC?t.NEAREST:t.LINEAR}function I(U){const O=U.target;O.removeEventListener("dispose",I),q(O),O.isVideoTexture&&x.delete(O)}function L(U){const O=U.target;O.removeEventListener("dispose",L),V(O)}function q(U){const O=r.get(U);if(O.__webglInit===void 0)return;const ne=U.source,be=y.get(ne);if(be){const ye=be[O.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&j(U),Object.keys(be).length===0&&y.delete(ne)}r.remove(U)}function j(U){const O=r.get(U);t.deleteTexture(O.__webglTexture);const ne=U.source,be=y.get(ne);delete be[O.__cacheKey],s.memory.textures--}function V(U){const O=U.texture,ne=r.get(U),be=r.get(O);if(be.__webglTexture!==void 0&&(t.deleteTexture(be.__webglTexture),s.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(ne.__webglFramebuffer[ye]))for(let _e=0;_e<ne.__webglFramebuffer[ye].length;_e++)t.deleteFramebuffer(ne.__webglFramebuffer[ye][_e]);else t.deleteFramebuffer(ne.__webglFramebuffer[ye]);ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer[ye])}else{if(Array.isArray(ne.__webglFramebuffer))for(let ye=0;ye<ne.__webglFramebuffer.length;ye++)t.deleteFramebuffer(ne.__webglFramebuffer[ye]);else t.deleteFramebuffer(ne.__webglFramebuffer);if(ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let ye=0;ye<ne.__webglColorRenderbuffer.length;ye++)ne.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(ne.__webglColorRenderbuffer[ye]);ne.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let ye=0,_e=O.length;ye<_e;ye++){const We=r.get(O[ye]);We.__webglTexture&&(t.deleteTexture(We.__webglTexture),s.memory.textures--),r.remove(O[ye])}r.remove(O),r.remove(U)}let K=0;function W(){K=0}function J(){const U=K;return U>=c&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+c),K+=1,U}function ee(U){const O=[];return O.push(U.wrapS),O.push(U.wrapT),O.push(U.wrapR||0),O.push(U.magFilter),O.push(U.minFilter),O.push(U.anisotropy),O.push(U.internalFormat),O.push(U.format),O.push(U.type),O.push(U.generateMipmaps),O.push(U.premultiplyAlpha),O.push(U.flipY),O.push(U.unpackAlignment),O.push(U.colorSpace),O.join()}function Z(U,O){const ne=r.get(U);if(U.isVideoTexture&&Ee(U),U.isRenderTargetTexture===!1&&U.version>0&&ne.__version!==U.version){const be=U.image;if(be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{me(ne,U,O);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+O)}function B(U,O){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){me(ne,U,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+O)}function G(U,O){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){me(ne,U,O);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+O)}function Q(U,O){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){ce(ne,U,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+O)}const te={[JP]:t.REPEAT,[Do]:t.CLAMP_TO_EDGE,[ej]:t.MIRRORED_REPEAT},he={[na]:t.NEAREST,[M$]:t.NEAREST_MIPMAP_NEAREST,[cC]:t.NEAREST_MIPMAP_LINEAR,[to]:t.LINEAR,[wOe]:t.LINEAR_MIPMAP_NEAREST,[tb]:t.LINEAR_MIPMAP_LINEAR},oe={[DOe]:t.NEVER,[zOe]:t.ALWAYS,[OOe]:t.LESS,[oQ]:t.LEQUAL,[LOe]:t.EQUAL,[UOe]:t.GEQUAL,[IOe]:t.GREATER,[FOe]:t.NOTEQUAL};function xe(U,O,ne){if(ne?(t.texParameteri(U,t.TEXTURE_WRAP_S,te[O.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,te[O.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,te[O.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,he[O.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,he[O.minFilter])):(t.texParameteri(U,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(U,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(O.wrapS!==Do||O.wrapT!==Do)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(U,t.TEXTURE_MAG_FILTER,R(O.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,R(O.minFilter)),O.minFilter!==na&&O.minFilter!==to&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),O.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,oe[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const be=e.get("EXT_texture_filter_anisotropic");if(O.magFilter===na||O.minFilter!==cC&&O.minFilter!==tb||O.type===Ac&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===nb&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(U,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function Te(U,O){let ne=!1;U.__webglInit===void 0&&(U.__webglInit=!0,O.addEventListener("dispose",I));const be=O.source;let ye=y.get(be);ye===void 0&&(ye={},y.set(be,ye));const _e=ee(O);if(_e!==U.__cacheKey){ye[_e]===void 0&&(ye[_e]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),ye[_e].usedTimes++;const We=ye[U.__cacheKey];We!==void 0&&(ye[U.__cacheKey].usedTimes--,We.usedTimes===0&&j(O)),U.__cacheKey=_e,U.__webglTexture=ye[_e].texture}return ne}function me(U,O,ne){let be=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(be=t.TEXTURE_3D);const ye=Te(U,O),_e=O.source;n.bindTexture(be,U.__webglTexture,t.TEXTURE0+ne);const We=r.get(_e);if(_e.version!==We.__version||ye===!0){n.activeTexture(t.TEXTURE0+ne);const Ve=er.getPrimaries(er.workingColorSpace),Ye=O.colorSpace===ro?null:er.getPrimaries(O.colorSpace),lt=O.colorSpace===ro||Ve===Ye?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,lt);const de=A(O)&&T(O.image)===!1;let ae=w(O.image,de,!1,d);ae=Me(O,ae);const ze=T(ae)||l,Ue=a.convert(O.format,O.colorSpace);let et=a.convert(O.type),dt=F(O.internalFormat,Ue,et,O.colorSpace,O.isVideoTexture);xe(be,O,ze);let pe;const nt=O.mipmaps,ve=l&&O.isVideoTexture!==!0&&dt!==iQ,He=We.__version===void 0||ye===!0,je=k(O,ae,ze);if(O.isDepthTexture)dt=t.DEPTH_COMPONENT,l?O.type===Ac?dt=t.DEPTH_COMPONENT32F:O.type===Ju?dt=t.DEPTH_COMPONENT24:O.type===Uh?dt=t.DEPTH24_STENCIL8:dt=t.DEPTH_COMPONENT16:O.type===Ac&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===zh&&dt===t.DEPTH_COMPONENT&&O.type!==FO&&O.type!==Ju&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Ju,et=a.convert(O.type)),O.format===$p&&dt===t.DEPTH_COMPONENT&&(dt=t.DEPTH_STENCIL,O.type!==Uh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Uh,et=a.convert(O.type))),He&&(ve?n.texStorage2D(t.TEXTURE_2D,1,dt,ae.width,ae.height):n.texImage2D(t.TEXTURE_2D,0,dt,ae.width,ae.height,0,Ue,et,null));else if(O.isDataTexture)if(nt.length>0&&ze){ve&&He&&n.texStorage2D(t.TEXTURE_2D,je,dt,nt[0].width,nt[0].height);for(let we=0,Xe=nt.length;we<Xe;we++)pe=nt[we],ve?n.texSubImage2D(t.TEXTURE_2D,we,0,0,pe.width,pe.height,Ue,et,pe.data):n.texImage2D(t.TEXTURE_2D,we,dt,pe.width,pe.height,0,Ue,et,pe.data);O.generateMipmaps=!1}else ve?(He&&n.texStorage2D(t.TEXTURE_2D,je,dt,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae.width,ae.height,Ue,et,ae.data)):n.texImage2D(t.TEXTURE_2D,0,dt,ae.width,ae.height,0,Ue,et,ae.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){ve&&He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,dt,nt[0].width,nt[0].height,ae.depth);for(let we=0,Xe=nt.length;we<Xe;we++)pe=nt[we],O.format!==no?Ue!==null?ve?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,we,0,0,0,pe.width,pe.height,ae.depth,Ue,pe.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,we,dt,pe.width,pe.height,ae.depth,0,pe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage3D(t.TEXTURE_2D_ARRAY,we,0,0,0,pe.width,pe.height,ae.depth,Ue,et,pe.data):n.texImage3D(t.TEXTURE_2D_ARRAY,we,dt,pe.width,pe.height,ae.depth,0,Ue,et,pe.data)}else{ve&&He&&n.texStorage2D(t.TEXTURE_2D,je,dt,nt[0].width,nt[0].height);for(let we=0,Xe=nt.length;we<Xe;we++)pe=nt[we],O.format!==no?Ue!==null?ve?n.compressedTexSubImage2D(t.TEXTURE_2D,we,0,0,pe.width,pe.height,Ue,pe.data):n.compressedTexImage2D(t.TEXTURE_2D,we,dt,pe.width,pe.height,0,pe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage2D(t.TEXTURE_2D,we,0,0,pe.width,pe.height,Ue,et,pe.data):n.texImage2D(t.TEXTURE_2D,we,dt,pe.width,pe.height,0,Ue,et,pe.data)}else if(O.isDataArrayTexture)ve?(He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,dt,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ae.width,ae.height,ae.depth,Ue,et,ae.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,dt,ae.width,ae.height,ae.depth,0,Ue,et,ae.data);else if(O.isData3DTexture)ve?(He&&n.texStorage3D(t.TEXTURE_3D,je,dt,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ae.width,ae.height,ae.depth,Ue,et,ae.data)):n.texImage3D(t.TEXTURE_3D,0,dt,ae.width,ae.height,ae.depth,0,Ue,et,ae.data);else if(O.isFramebufferTexture){if(He)if(ve)n.texStorage2D(t.TEXTURE_2D,je,dt,ae.width,ae.height);else{let we=ae.width,Xe=ae.height;for(let ot=0;ot<je;ot++)n.texImage2D(t.TEXTURE_2D,ot,dt,we,Xe,0,Ue,et,null),we>>=1,Xe>>=1}}else if(nt.length>0&&ze){ve&&He&&n.texStorage2D(t.TEXTURE_2D,je,dt,nt[0].width,nt[0].height);for(let we=0,Xe=nt.length;we<Xe;we++)pe=nt[we],ve?n.texSubImage2D(t.TEXTURE_2D,we,0,0,Ue,et,pe):n.texImage2D(t.TEXTURE_2D,we,dt,Ue,et,pe);O.generateMipmaps=!1}else ve?(He&&n.texStorage2D(t.TEXTURE_2D,je,dt,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Ue,et,ae)):n.texImage2D(t.TEXTURE_2D,0,dt,Ue,et,ae);C(O,ze)&&N(be),We.__version=_e.version,O.onUpdate&&O.onUpdate(O)}U.__version=O.version}function ce(U,O,ne){if(O.image.length!==6)return;const be=Te(U,O),ye=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+ne);const _e=r.get(ye);if(ye.version!==_e.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const We=er.getPrimaries(er.workingColorSpace),Ve=O.colorSpace===ro?null:er.getPrimaries(O.colorSpace),Ye=O.colorSpace===ro||We===Ve?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ye);const lt=O.isCompressedTexture||O.image[0].isCompressedTexture,de=O.image[0]&&O.image[0].isDataTexture,ae=[];for(let we=0;we<6;we++)!lt&&!de?ae[we]=w(O.image[we],!1,!0,u):ae[we]=de?O.image[we].image:O.image[we],ae[we]=Me(O,ae[we]);const ze=ae[0],Ue=T(ze)||l,et=a.convert(O.format,O.colorSpace),dt=a.convert(O.type),pe=F(O.internalFormat,et,dt,O.colorSpace),nt=l&&O.isVideoTexture!==!0,ve=_e.__version===void 0||be===!0;let He=k(O,ze,Ue);xe(t.TEXTURE_CUBE_MAP,O,Ue);let je;if(lt){nt&&ve&&n.texStorage2D(t.TEXTURE_CUBE_MAP,He,pe,ze.width,ze.height);for(let we=0;we<6;we++){je=ae[we].mipmaps;for(let Xe=0;Xe<je.length;Xe++){const ot=je[Xe];O.format!==no?et!==null?nt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,0,0,ot.width,ot.height,et,ot.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,pe,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,0,0,ot.width,ot.height,et,dt,ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe,pe,ot.width,ot.height,0,et,dt,ot.data)}}}else{je=O.mipmaps,nt&&ve&&(je.length>0&&He++,n.texStorage2D(t.TEXTURE_CUBE_MAP,He,pe,ae[0].width,ae[0].height));for(let we=0;we<6;we++)if(de){nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,ae[we].width,ae[we].height,et,dt,ae[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,pe,ae[we].width,ae[we].height,0,et,dt,ae[we].data);for(let Xe=0;Xe<je.length;Xe++){const St=je[Xe].image[we].image;nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,0,0,St.width,St.height,et,dt,St.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,pe,St.width,St.height,0,et,dt,St.data)}}else{nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,et,dt,ae[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,pe,et,dt,ae[we]);for(let Xe=0;Xe<je.length;Xe++){const ot=je[Xe];nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,0,0,et,dt,ot.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Xe+1,pe,et,dt,ot.image[we])}}}C(O,Ue)&&N(t.TEXTURE_CUBE_MAP),_e.__version=ye.version,O.onUpdate&&O.onUpdate(O)}U.__version=O.version}function Ce(U,O,ne,be,ye,_e){const We=a.convert(ne.format,ne.colorSpace),Ve=a.convert(ne.type),Ye=F(ne.internalFormat,We,Ve,ne.colorSpace);if(!r.get(O).__hasExternalTextures){const de=Math.max(1,O.width>>_e),ae=Math.max(1,O.height>>_e);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,_e,Ye,de,ae,O.depth,0,We,Ve,null):n.texImage2D(ye,_e,Ye,de,ae,0,We,Ve,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),ue(O)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,ye,r.get(ne).__webglTexture,0,se(O)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,ye,r.get(ne).__webglTexture,_e),n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(U,O,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,U),O.depthBuffer&&!O.stencilBuffer){let be=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||ue(O)){const ye=O.depthTexture;ye&&ye.isDepthTexture&&(ye.type===Ac?be=t.DEPTH_COMPONENT32F:ye.type===Ju&&(be=t.DEPTH_COMPONENT24));const _e=se(O);ue(O)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,_e,be,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,_e,be,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,be,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(O.depthBuffer&&O.stencilBuffer){const be=se(O);ne&&ue(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,O.width,O.height):ue(O)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const be=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let ye=0;ye<be.length;ye++){const _e=be[ye],We=a.convert(_e.format,_e.colorSpace),Ve=a.convert(_e.type),Ye=F(_e.internalFormat,We,Ve,_e.colorSpace),lt=se(O);ne&&ue(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,lt,Ye,O.width,O.height):ue(O)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,lt,Ye,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Ye,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ie(U,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),Z(O.depthTexture,0);const be=r.get(O.depthTexture).__webglTexture,ye=se(O);if(O.depthTexture.format===zh)ue(O)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0);else if(O.depthTexture.format===$p)ue(O)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0);else throw new Error("Unknown depthTexture format")}function z(U){const O=r.get(U),ne=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!O.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");Ie(O.__webglFramebuffer,U)}else if(ne){O.__webglDepthbuffer=[];for(let be=0;be<6;be++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[be]),O.__webglDepthbuffer[be]=t.createRenderbuffer(),fe(O.__webglDepthbuffer[be],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),fe(O.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H(U,O,ne){const be=r.get(U);O!==void 0&&Ce(be.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&z(U)}function re(U){const O=U.texture,ne=r.get(U),be=r.get(O);U.addEventListener("dispose",L),U.isWebGLMultipleRenderTargets!==!0&&(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=O.version,s.memory.textures++);const ye=U.isWebGLCubeRenderTarget===!0,_e=U.isWebGLMultipleRenderTargets===!0,We=T(U)||l;if(ye){ne.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)if(l&&O.mipmaps&&O.mipmaps.length>0){ne.__webglFramebuffer[Ve]=[];for(let Ye=0;Ye<O.mipmaps.length;Ye++)ne.__webglFramebuffer[Ve][Ye]=t.createFramebuffer()}else ne.__webglFramebuffer[Ve]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ve=0;Ve<O.mipmaps.length;Ve++)ne.__webglFramebuffer[Ve]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(_e)if(i.drawBuffers){const Ve=U.texture;for(let Ye=0,lt=Ve.length;Ye<lt;Ye++){const de=r.get(Ve[Ye]);de.__webglTexture===void 0&&(de.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&U.samples>0&&ue(U)===!1){const Ve=_e?O:[O];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Ye=0;Ye<Ve.length;Ye++){const lt=Ve[Ye];ne.__webglColorRenderbuffer[Ye]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ye]);const de=a.convert(lt.format,lt.colorSpace),ae=a.convert(lt.type),ze=F(lt.internalFormat,de,ae,lt.colorSpace,U.isXRRenderTarget===!0),Ue=se(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ue,ze,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ye,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ye])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),fe(ne.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),xe(t.TEXTURE_CUBE_MAP,O,We);for(let Ve=0;Ve<6;Ve++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let Ye=0;Ye<O.mipmaps.length;Ye++)Ce(ne.__webglFramebuffer[Ve][Ye],U,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,Ye);else Ce(ne.__webglFramebuffer[Ve],U,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0);C(O,We)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(_e){const Ve=U.texture;for(let Ye=0,lt=Ve.length;Ye<lt;Ye++){const de=Ve[Ye],ae=r.get(de);n.bindTexture(t.TEXTURE_2D,ae.__webglTexture),xe(t.TEXTURE_2D,de,We),Ce(ne.__webglFramebuffer,U,de,t.COLOR_ATTACHMENT0+Ye,t.TEXTURE_2D,0),C(de,We)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Ve=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(l?Ve=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ve,be.__webglTexture),xe(Ve,O,We),l&&O.mipmaps&&O.mipmaps.length>0)for(let Ye=0;Ye<O.mipmaps.length;Ye++)Ce(ne.__webglFramebuffer[Ye],U,O,t.COLOR_ATTACHMENT0,Ve,Ye);else Ce(ne.__webglFramebuffer,U,O,t.COLOR_ATTACHMENT0,Ve,0);C(O,We)&&N(Ve),n.unbindTexture()}U.depthBuffer&&z(U)}function $(U){const O=T(U)||l,ne=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let be=0,ye=ne.length;be<ye;be++){const _e=ne[be];if(C(_e,O)){const We=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ve=r.get(_e).__webglTexture;n.bindTexture(We,Ve),N(We),n.unbindTexture()}}}function Y(U){if(l&&U.samples>0&&ue(U)===!1){const O=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],ne=U.width,be=U.height;let ye=t.COLOR_BUFFER_BIT;const _e=[],We=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ve=r.get(U),Ye=U.isWebGLMultipleRenderTargets===!0;if(Ye)for(let lt=0;lt<O.length;lt++)n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ve.__webglFramebuffer);for(let lt=0;lt<O.length;lt++){_e.push(t.COLOR_ATTACHMENT0+lt),U.depthBuffer&&_e.push(We);const de=Ve.__ignoreDepthValues!==void 0?Ve.__ignoreDepthValues:!1;if(de===!1&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Ye&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ve.__webglColorRenderbuffer[lt]),de===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[We]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[We])),Ye){const ae=r.get(O[lt]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ae,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,ye,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,_e)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ye)for(let lt=0;lt<O.length;lt++){n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,Ve.__webglColorRenderbuffer[lt]);const de=r.get(O[lt]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,de,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ve.__webglMultisampledFramebuffer)}}function se(U){return Math.min(f,U.samples)}function ue(U){const O=r.get(U);return l&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Ee(U){const O=s.render.frame;x.get(U)!==O&&(x.set(U,O),U.update())}function Me(U,O){const ne=U.colorSpace,be=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===nj||ne!==Kc&&ne!==ro&&(er.getTransfer(ne)===mr?l===!1?e.has("EXT_sRGB")===!0&&be===no?(U.format=nj,U.minFilter=to,U.generateMipmaps=!1):O=uQ.sRGBToLinear(O):(be!==no||ye!==cd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),O}this.allocateTextureUnit=J,this.resetTextureUnits=W,this.setTexture2D=Z,this.setTexture2DArray=B,this.setTexture3D=G,this.setTextureCube=Q,this.rebindTextures=H,this.setupRenderTarget=re,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=Y,this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=Ce,this.useMultisampledRTT=ue}function JFe(t,e,n){const r=n.isWebGL2;function i(a,s=ro){let l;const c=er.getTransfer(s);if(a===cd)return t.UNSIGNED_BYTE;if(a===JZ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===eQ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===SOe)return t.BYTE;if(a===MOe)return t.SHORT;if(a===FO)return t.UNSIGNED_SHORT;if(a===QZ)return t.INT;if(a===Ju)return t.UNSIGNED_INT;if(a===Ac)return t.FLOAT;if(a===nb)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===EOe)return t.ALPHA;if(a===no)return t.RGBA;if(a===TOe)return t.LUMINANCE;if(a===AOe)return t.LUMINANCE_ALPHA;if(a===zh)return t.DEPTH_COMPONENT;if(a===$p)return t.DEPTH_STENCIL;if(a===nj)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===NOe)return t.RED;if(a===tQ)return t.RED_INTEGER;if(a===COe)return t.RG;if(a===nQ)return t.RG_INTEGER;if(a===rQ)return t.RGBA_INTEGER;if(a===uC||a===dC||a===hC||a===fC)if(c===mr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===uC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===dC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===hC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===fC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===uC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===dC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===hC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===fC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===E$||a===T$||a===A$||a===N$)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===E$)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===T$)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===A$)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===N$)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===iQ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===C$||a===k$)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===C$)return c===mr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===k$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===P$||a===j$||a===R$||a===D$||a===O$||a===L$||a===I$||a===F$||a===U$||a===z$||a===B$||a===H$||a===$$||a===V$)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===P$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===j$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===R$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===D$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===O$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===L$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===I$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===F$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===U$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===z$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===B$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===H$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===$$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===V$)return c===mr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===mC||a===G$||a===W$)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===mC)return c===mr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===G$)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===W$)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===kOe||a===q$||a===K$||a===X$)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===mC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===q$)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===K$)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===X$)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Uh?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class eUe extends ws{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Yx extends Da{constructor(){super(),this.isGroup=!0,this.type="Group"}}const tUe={type:"move"};class IC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Yx,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 Yx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new De,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new De),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Yx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new De,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new De),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 l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(tUe)))}return l!==null&&(l.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 Yx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class nUe extends Mf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const v=n.getContextAttributes();let y=null,b=null;const E=[],w=[],T=new Qt;let A=null;const C=new ws;C.layers.enable(1),C.viewport=new nr;const N=new ws;N.layers.enable(2),N.viewport=new nr;const F=[C,N],k=new eUe;k.layers.enable(1),k.layers.enable(2);let R=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let te=E[Q];return te===void 0&&(te=new IC,E[Q]=te),te.getTargetRaySpace()},this.getControllerGrip=function(Q){let te=E[Q];return te===void 0&&(te=new IC,E[Q]=te),te.getGripSpace()},this.getHand=function(Q){let te=E[Q];return te===void 0&&(te=new IC,E[Q]=te),te.getHandSpace()};function L(Q){const te=w.indexOf(Q.inputSource);if(te===-1)return;const he=E[te];he!==void 0&&(he.update(Q.inputSource,Q.frame,u||s),he.dispatchEvent({type:Q.type,data:Q.inputSource}))}function q(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",j);for(let Q=0;Q<E.length;Q++){const te=w[Q];te!==null&&(w[Q]=null,E[Q].disconnect(te))}R=null,I=null,e.setRenderTarget(y),p=null,g=null,f=null,i=null,b=null,G.stop(),r.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Q){a=Q,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Q){l=Q,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(Q){u=Q},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(Q){if(i=Q,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",q),i.addEventListener("inputsourceschange",j),v.xrCompatible!==!0&&await n.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const te={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,te),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),b=new ff(p.framebufferWidth,p.framebufferHeight,{format:no,type:cd,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let te=null,he=null,oe=null;v.depth&&(oe=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,te=v.stencil?$p:zh,he=v.stencil?Uh:Ju);const xe={colorFormat:n.RGBA8,depthFormat:oe,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(xe),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),b=new ff(g.textureWidth,g.textureHeight,{format:no,type:cd,depthTexture:new wQ(g.textureWidth,g.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Te=e.properties.get(b);Te.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(l),G.setContext(i),G.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(Q){for(let te=0;te<Q.removed.length;te++){const he=Q.removed[te],oe=w.indexOf(he);oe>=0&&(w[oe]=null,E[oe].disconnect(he))}for(let te=0;te<Q.added.length;te++){const he=Q.added[te];let oe=w.indexOf(he);if(oe===-1){for(let Te=0;Te<E.length;Te++)if(Te>=w.length){w.push(he),oe=Te;break}else if(w[Te]===null){w[Te]=he,oe=Te;break}if(oe===-1)break}const xe=E[oe];xe&&xe.connect(he)}}const V=new De,K=new De;function W(Q,te,he){V.setFromMatrixPosition(te.matrixWorld),K.setFromMatrixPosition(he.matrixWorld);const oe=V.distanceTo(K),xe=te.projectionMatrix.elements,Te=he.projectionMatrix.elements,me=xe[14]/(xe[10]-1),ce=xe[14]/(xe[10]+1),Ce=(xe[9]+1)/xe[5],fe=(xe[9]-1)/xe[5],Ie=(xe[8]-1)/xe[0],z=(Te[8]+1)/Te[0],H=me*Ie,re=me*z,$=oe/(-Ie+z),Y=$*-Ie;te.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(Y),Q.translateZ($),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert();const se=me+$,ue=ce+$,Ee=H-Y,Me=re+(oe-Y),U=Ce*ce/ue*se,O=fe*ce/ue*se;Q.projectionMatrix.makePerspective(Ee,Me,U,O,se,ue),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}function J(Q,te){te===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(te.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(i===null)return;k.near=N.near=C.near=Q.near,k.far=N.far=C.far=Q.far,(R!==k.near||I!==k.far)&&(i.updateRenderState({depthNear:k.near,depthFar:k.far}),R=k.near,I=k.far);const te=Q.parent,he=k.cameras;J(k,te);for(let oe=0;oe<he.length;oe++)J(he[oe],te);he.length===2?W(k,C,N):k.projectionMatrix.copy(C.projectionMatrix),ee(Q,k,te)};function ee(Q,te,he){he===null?Q.matrix.copy(te.matrixWorld):(Q.matrix.copy(he.matrixWorld),Q.matrix.invert(),Q.matrix.multiply(te.matrixWorld)),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale),Q.updateMatrixWorld(!0),Q.projectionMatrix.copy(te.projectionMatrix),Q.projectionMatrixInverse.copy(te.projectionMatrixInverse),Q.isPerspectiveCamera&&(Q.fov=ib*2*Math.atan(1/Q.projectionMatrix.elements[5]),Q.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(Q){c=Q,g!==null&&(g.fixedFoveation=Q),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Q)};let Z=null;function B(Q,te){if(d=te.getViewerPose(u||s),x=te,d!==null){const he=d.views;p!==null&&(e.setRenderTargetFramebuffer(b,p.framebuffer),e.setRenderTarget(b));let oe=!1;he.length!==k.cameras.length&&(k.cameras.length=0,oe=!0);for(let xe=0;xe<he.length;xe++){const Te=he[xe];let me=null;if(p!==null)me=p.getViewport(Te);else{const Ce=f.getViewSubImage(g,Te);me=Ce.viewport,xe===0&&(e.setRenderTargetTextures(b,Ce.colorTexture,g.ignoreDepthValues?void 0:Ce.depthStencilTexture),e.setRenderTarget(b))}let ce=F[xe];ce===void 0&&(ce=new ws,ce.layers.enable(xe),ce.viewport=new nr,F[xe]=ce),ce.matrix.fromArray(Te.transform.matrix),ce.matrix.decompose(ce.position,ce.quaternion,ce.scale),ce.projectionMatrix.fromArray(Te.projectionMatrix),ce.projectionMatrixInverse.copy(ce.projectionMatrix).invert(),ce.viewport.set(me.x,me.y,me.width,me.height),xe===0&&(k.matrix.copy(ce.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),oe===!0&&k.cameras.push(ce)}}for(let he=0;he<E.length;he++){const oe=w[he],xe=E[he];oe!==null&&xe!==void 0&&xe.update(oe,te,u||s)}Z&&Z(Q,te),te.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:te}),x=null}const G=new _Q;G.setAnimationLoop(B),this.setAnimationLoop=function(Q){Z=Q},this.dispose=function(){}}}function rUe(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,bQ(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,E,w,T){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&p(y,b,T)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&l(y,b)):b.isPointsMaterial?c(y,b,E,w):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===ts&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===ts&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const E=e.get(b).envMap;if(E&&(y.envMap.value=E,y.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap){y.lightMap.value=b.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=b.lightMapIntensity*w,n(b.lightMap,y.lightMapTransform)}b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function l(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,E,w){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*E,y.scale.value=w*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),e.get(b).envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function p(y,b,E){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===ts&&y.clearcoatNormalScale.value.negate())),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=E.texture,y.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const E=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(E.matrixWorld),y.nearDistance.value=E.shadow.camera.near,y.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function iUe(t,e,n,r){let i={},a={},s=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(E,w){const T=w.program;r.uniformBlockBinding(E,T)}function u(E,w){let T=i[E.id];T===void 0&&(x(E),T=d(E),i[E.id]=T,E.addEventListener("dispose",y));const A=w.program;r.updateUBOMapping(E,A);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const T=t.createBuffer(),A=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,A,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,T),T}function f(){for(let E=0;E<l;E++)if(s.indexOf(E)===-1)return s.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],T=E.uniforms,A=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,N=T.length;C<N;C++){const F=T[C];if(p(F,C,A)===!0){const k=F.__offset,R=Array.isArray(F.value)?F.value:[F.value];let I=0;for(let L=0;L<R.length;L++){const q=R[L],j=v(q);typeof q=="number"?(F.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,k+I,F.__data)):q.isMatrix3?(F.__data[0]=q.elements[0],F.__data[1]=q.elements[1],F.__data[2]=q.elements[2],F.__data[3]=q.elements[0],F.__data[4]=q.elements[3],F.__data[5]=q.elements[4],F.__data[6]=q.elements[5],F.__data[7]=q.elements[0],F.__data[8]=q.elements[6],F.__data[9]=q.elements[7],F.__data[10]=q.elements[8],F.__data[11]=q.elements[0]):(q.toArray(F.__data,I),I+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,k,F.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,T){const A=E.value;if(T[w]===void 0){if(typeof A=="number")T[w]=A;else{const C=Array.isArray(A)?A:[A],N=[];for(let F=0;F<C.length;F++)N.push(C[F].clone());T[w]=N}return!0}else if(typeof A=="number"){if(T[w]!==A)return T[w]=A,!0}else{const C=Array.isArray(T[w])?T[w]:[T[w]],N=Array.isArray(A)?A:[A];for(let F=0;F<C.length;F++){const k=C[F];if(k.equals(N[F])===!1)return k.copy(N[F]),!0}}return!1}function x(E){const w=E.uniforms;let T=0;const A=16;let C=0;for(let N=0,F=w.length;N<F;N++){const k=w[N],R={boundary:0,storage:0},I=Array.isArray(k.value)?k.value:[k.value];for(let L=0,q=I.length;L<q;L++){const j=I[L],V=v(j);R.boundary+=V.boundary,R.storage+=V.storage}if(k.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=T,N>0){C=T%A;const L=A-C;C!==0&&L-R.boundary<0&&(T+=A-C,k.__offset=T)}T+=R.storage}return C=T%A,C>0&&(T+=A-C),E.__size=T,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function y(E){const w=E.target;w.removeEventListener("dispose",y);const T=s.indexOf(w.__bindingPointIndex);s.splice(T,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}class aj{constructor(e={}){const{canvas:n=tLe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:s=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=s;const p=new Uint32Array(4),x=new Int32Array(4);let v=null,y=null;const b=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=ra,this._useLegacyLights=!1,this.toneMapping=ld,this.toneMappingExposure=1;const w=this;let T=!1,A=0,C=0,N=null,F=-1,k=null;const R=new nr,I=new nr;let L=null;const q=new Vt(0);let j=0,V=n.width,K=n.height,W=1,J=null,ee=null;const Z=new nr(0,0,V,K),B=new nr(0,0,V,K);let G=!1;const Q=new rE;let te=!1,he=!1,oe=null;const xe=new dr,Te=new Qt,me=new De,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ce(){return N===null?W:1}let fe=r;function Ie(ge,Ge){for(let rt=0;rt<ge.length;rt++){const Ke=ge[rt],at=n.getContext(Ke,Ge);if(at!==null)return at}return null}try{const ge={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${eE}`),n.addEventListener("webglcontextlost",nt,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",He,!1),fe===null){const Ge=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ge.shift(),fe=Ie(Ge,ge),fe===null)throw Ie(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&fe instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),fe.getShaderPrecisionFormat===void 0&&(fe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ge){throw console.error("THREE.WebGLRenderer: "+ge.message),ge}let z,H,re,$,Y,se,ue,Ee,Me,U,O,ne,be,ye,_e,We,Ve,Ye,lt,de,ae,ze,Ue,et;function dt(){z=new p5e(fe),H=new l5e(fe,z,e),z.init(H),ze=new JFe(fe,z,H),re=new ZFe(fe,z,H),$=new b5e(fe),Y=new IFe,se=new QFe(fe,z,re,Y,H,ze,$),ue=new u5e(w),Ee=new m5e(w),Me=new ELe(fe,H),Ue=new s5e(fe,z,Me,H),U=new g5e(fe,Me,$,Ue),O=new w5e(fe,U,Me,$),lt=new _5e(fe,H,se),We=new c5e(Y),ne=new LFe(w,ue,Ee,z,H,Ue,We),be=new rUe(w,Y),ye=new UFe,_e=new GFe(z,H),Ye=new a5e(w,ue,Ee,re,O,g,c),Ve=new YFe(w,O,H),et=new iUe(fe,$,H,re),de=new o5e(fe,z,$,H),ae=new x5e(fe,z,$,H),$.programs=ne.programs,w.capabilities=H,w.extensions=z,w.properties=Y,w.renderLists=ye,w.shadowMap=Ve,w.state=re,w.info=$}dt();const pe=new nUe(w,fe);this.xr=pe,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const ge=z.get("WEBGL_lose_context");ge&&ge.loseContext()},this.forceContextRestore=function(){const ge=z.get("WEBGL_lose_context");ge&&ge.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(ge){ge!==void 0&&(W=ge,this.setSize(V,K,!1))},this.getSize=function(ge){return ge.set(V,K)},this.setSize=function(ge,Ge,rt=!0){if(pe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=ge,K=Ge,n.width=Math.floor(ge*W),n.height=Math.floor(Ge*W),rt===!0&&(n.style.width=ge+"px",n.style.height=Ge+"px"),this.setViewport(0,0,ge,Ge)},this.getDrawingBufferSize=function(ge){return ge.set(V*W,K*W).floor()},this.setDrawingBufferSize=function(ge,Ge,rt){V=ge,K=Ge,W=rt,n.width=Math.floor(ge*rt),n.height=Math.floor(Ge*rt),this.setViewport(0,0,ge,Ge)},this.getCurrentViewport=function(ge){return ge.copy(R)},this.getViewport=function(ge){return ge.copy(Z)},this.setViewport=function(ge,Ge,rt,Ke){ge.isVector4?Z.set(ge.x,ge.y,ge.z,ge.w):Z.set(ge,Ge,rt,Ke),re.viewport(R.copy(Z).multiplyScalar(W).floor())},this.getScissor=function(ge){return ge.copy(B)},this.setScissor=function(ge,Ge,rt,Ke){ge.isVector4?B.set(ge.x,ge.y,ge.z,ge.w):B.set(ge,Ge,rt,Ke),re.scissor(I.copy(B).multiplyScalar(W).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(ge){re.setScissorTest(G=ge)},this.setOpaqueSort=function(ge){J=ge},this.setTransparentSort=function(ge){ee=ge},this.getClearColor=function(ge){return ge.copy(Ye.getClearColor())},this.setClearColor=function(){Ye.setClearColor.apply(Ye,arguments)},this.getClearAlpha=function(){return Ye.getClearAlpha()},this.setClearAlpha=function(){Ye.setClearAlpha.apply(Ye,arguments)},this.clear=function(ge=!0,Ge=!0,rt=!0){let Ke=0;if(ge){let at=!1;if(N!==null){const At=N.texture.format;at=At===rQ||At===nQ||At===tQ}if(at){const At=N.texture.type,ie=At===cd||At===Ju||At===FO||At===Uh||At===JZ||At===eQ,Ae=Ye.getClearColor(),Fe=Ye.getClearAlpha(),Le=Ae.r,Pe=Ae.g,ct=Ae.b;ie?(p[0]=Le,p[1]=Pe,p[2]=ct,p[3]=Fe,fe.clearBufferuiv(fe.COLOR,0,p)):(x[0]=Le,x[1]=Pe,x[2]=ct,x[3]=Fe,fe.clearBufferiv(fe.COLOR,0,x))}else Ke|=fe.COLOR_BUFFER_BIT}Ge&&(Ke|=fe.DEPTH_BUFFER_BIT),rt&&(Ke|=fe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),fe.clear(Ke)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",nt,!1),n.removeEventListener("webglcontextrestored",ve,!1),n.removeEventListener("webglcontextcreationerror",He,!1),ye.dispose(),_e.dispose(),Y.dispose(),ue.dispose(),Ee.dispose(),O.dispose(),Ue.dispose(),et.dispose(),ne.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",qt),pe.removeEventListener("sessionend",Ft),oe&&(oe.dispose(),oe=null),kn.stop()};function nt(ge){ge.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const ge=$.autoReset,Ge=Ve.enabled,rt=Ve.autoUpdate,Ke=Ve.needsUpdate,at=Ve.type;dt(),$.autoReset=ge,Ve.enabled=Ge,Ve.autoUpdate=rt,Ve.needsUpdate=Ke,Ve.type=at}function He(ge){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ge.statusMessage)}function je(ge){const Ge=ge.target;Ge.removeEventListener("dispose",je),we(Ge)}function we(ge){Xe(ge),Y.remove(ge)}function Xe(ge){const Ge=Y.get(ge).programs;Ge!==void 0&&(Ge.forEach(function(rt){ne.releaseProgram(rt)}),ge.isShaderMaterial&&ne.releaseShaderCache(ge))}this.renderBufferDirect=function(ge,Ge,rt,Ke,at,At){Ge===null&&(Ge=ce);const ie=at.isMesh&&at.matrixWorld.determinant()<0,Ae=Oe(ge,Ge,rt,Ke,at);re.setMaterial(Ke,ie);let Fe=rt.index,Le=1;if(Ke.wireframe===!0){if(Fe=U.getWireframeAttribute(rt),Fe===void 0)return;Le=2}const Pe=rt.drawRange,ct=rt.attributes.position;let mt=Pe.start*Le,Mt=(Pe.start+Pe.count)*Le;At!==null&&(mt=Math.max(mt,At.start*Le),Mt=Math.min(Mt,(At.start+At.count)*Le)),Fe!==null?(mt=Math.max(mt,0),Mt=Math.min(Mt,Fe.count)):ct!=null&&(mt=Math.max(mt,0),Mt=Math.min(Mt,ct.count));const _t=Mt-mt;if(_t<0||_t===1/0)return;Ue.setup(at,Ke,Ae,rt,Fe);let Lt,Ct=de;if(Fe!==null&&(Lt=Me.get(Fe),Ct=ae,Ct.setIndex(Lt)),at.isMesh)Ke.wireframe===!0?(re.setLineWidth(Ke.wireframeLinewidth*Ce()),Ct.setMode(fe.LINES)):Ct.setMode(fe.TRIANGLES);else if(at.isLine){let bt=Ke.linewidth;bt===void 0&&(bt=1),re.setLineWidth(bt*Ce()),at.isLineSegments?Ct.setMode(fe.LINES):at.isLineLoop?Ct.setMode(fe.LINE_LOOP):Ct.setMode(fe.LINE_STRIP)}else at.isPoints?Ct.setMode(fe.POINTS):at.isSprite&&Ct.setMode(fe.TRIANGLES);if(at.isBatchedMesh)Ct.renderMultiDraw(at._multiDrawStarts,at._multiDrawCounts,at._multiDrawCount);else if(at.isInstancedMesh)Ct.renderInstances(mt,_t,at.count);else if(rt.isInstancedBufferGeometry){const bt=rt._maxInstanceCount!==void 0?rt._maxInstanceCount:1/0,Yt=Math.min(rt.instanceCount,bt);Ct.renderInstances(mt,_t,Yt)}else Ct.render(mt,_t)};function ot(ge,Ge,rt){ge.transparent===!0&&ge.side===vc&&ge.forceSinglePass===!1?(ge.side=ts,ge.needsUpdate=!0,ei(ge,Ge,rt),ge.side=Md,ge.needsUpdate=!0,ei(ge,Ge,rt),ge.side=vc):ei(ge,Ge,rt)}this.compile=function(ge,Ge,rt=null){rt===null&&(rt=ge),y=_e.get(rt),y.init(),E.push(y),rt.traverseVisible(function(at){at.isLight&&at.layers.test(Ge.layers)&&(y.pushLight(at),at.castShadow&&y.pushShadow(at))}),ge!==rt&&ge.traverseVisible(function(at){at.isLight&&at.layers.test(Ge.layers)&&(y.pushLight(at),at.castShadow&&y.pushShadow(at))}),y.setupLights(w._useLegacyLights);const Ke=new Set;return ge.traverse(function(at){const At=at.material;if(At)if(Array.isArray(At))for(let ie=0;ie<At.length;ie++){const Ae=At[ie];ot(Ae,rt,at),Ke.add(Ae)}else ot(At,rt,at),Ke.add(At)}),E.pop(),y=null,Ke},this.compileAsync=function(ge,Ge,rt=null){const Ke=this.compile(ge,Ge,rt);return new Promise(at=>{function At(){if(Ke.forEach(function(ie){Y.get(ie).currentProgram.isReady()&&Ke.delete(ie)}),Ke.size===0){at(ge);return}setTimeout(At,10)}z.get("KHR_parallel_shader_compile")!==null?At():setTimeout(At,10)})};let St=null;function Dt(ge){St&&St(ge)}function qt(){kn.stop()}function Ft(){kn.start()}const kn=new _Q;kn.setAnimationLoop(Dt),typeof self<"u"&&kn.setContext(self),this.setAnimationLoop=function(ge){St=ge,pe.setAnimationLoop(ge),ge===null?kn.stop():kn.start()},pe.addEventListener("sessionstart",qt),pe.addEventListener("sessionend",Ft),this.render=function(ge,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;ge.matrixWorldAutoUpdate===!0&&ge.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),pe.enabled===!0&&pe.isPresenting===!0&&(pe.cameraAutoUpdate===!0&&pe.updateCamera(Ge),Ge=pe.getCamera()),ge.isScene===!0&&ge.onBeforeRender(w,ge,Ge,N),y=_e.get(ge,E.length),y.init(),E.push(y),xe.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),Q.setFromProjectionMatrix(xe),he=this.localClippingEnabled,te=We.init(this.clippingPlanes,he),v=ye.get(ge,b.length),v.init(),b.push(v),Nn(ge,Ge,0,w.sortObjects),v.finish(),w.sortObjects===!0&&v.sort(J,ee),this.info.render.frame++,te===!0&&We.beginShadows();const rt=y.state.shadowsArray;if(Ve.render(rt,ge,Ge),te===!0&&We.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ye.render(v,ge),y.setupLights(w._useLegacyLights),Ge.isArrayCamera){const Ke=Ge.cameras;for(let at=0,At=Ke.length;at<At;at++){const ie=Ke[at];Lr(v,ge,ie,ie.viewport)}}else Lr(v,ge,Ge);N!==null&&(se.updateMultisampleRenderTarget(N),se.updateRenderTargetMipmap(N)),ge.isScene===!0&&ge.onAfterRender(w,ge,Ge),Ue.resetDefaultState(),F=-1,k=null,E.pop(),E.length>0?y=E[E.length-1]:y=null,b.pop(),b.length>0?v=b[b.length-1]:v=null};function Nn(ge,Ge,rt,Ke){if(ge.visible===!1)return;if(ge.layers.test(Ge.layers)){if(ge.isGroup)rt=ge.renderOrder;else if(ge.isLOD)ge.autoUpdate===!0&&ge.update(Ge);else if(ge.isLight)y.pushLight(ge),ge.castShadow&&y.pushShadow(ge);else if(ge.isSprite){if(!ge.frustumCulled||Q.intersectsSprite(ge)){Ke&&me.setFromMatrixPosition(ge.matrixWorld).applyMatrix4(xe);const ie=O.update(ge),Ae=ge.material;Ae.visible&&v.push(ge,ie,Ae,rt,me.z,null)}}else if((ge.isMesh||ge.isLine||ge.isPoints)&&(!ge.frustumCulled||Q.intersectsObject(ge))){const ie=O.update(ge),Ae=ge.material;if(Ke&&(ge.boundingSphere!==void 0?(ge.boundingSphere===null&&ge.computeBoundingSphere(),me.copy(ge.boundingSphere.center)):(ie.boundingSphere===null&&ie.computeBoundingSphere(),me.copy(ie.boundingSphere.center)),me.applyMatrix4(ge.matrixWorld).applyMatrix4(xe)),Array.isArray(Ae)){const Fe=ie.groups;for(let Le=0,Pe=Fe.length;Le<Pe;Le++){const ct=Fe[Le],mt=Ae[ct.materialIndex];mt&&mt.visible&&v.push(ge,ie,mt,rt,me.z,ct)}}else Ae.visible&&v.push(ge,ie,Ae,rt,me.z,null)}}const At=ge.children;for(let ie=0,Ae=At.length;ie<Ae;ie++)Nn(At[ie],Ge,rt,Ke)}function Lr(ge,Ge,rt,Ke){const at=ge.opaque,At=ge.transmissive,ie=ge.transparent;y.setupLightsView(rt),te===!0&&We.setGlobalState(w.clippingPlanes,rt),At.length>0&&Er(at,At,Ge,rt),Ke&&re.viewport(R.copy(Ke)),at.length>0&&br(at,Ge,rt),At.length>0&&br(At,Ge,rt),ie.length>0&&br(ie,Ge,rt),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function Er(ge,Ge,rt,Ke){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;const At=H.isWebGL2;oe===null&&(oe=new ff(1,1,{generateMipmaps:!0,type:z.has("EXT_color_buffer_half_float")?nb:cd,minFilter:tb,samples:At?4:0})),w.getDrawingBufferSize(Te),At?oe.setSize(Te.x,Te.y):oe.setSize(Xw(Te.x),Xw(Te.y));const ie=w.getRenderTarget();w.setRenderTarget(oe),w.getClearColor(q),j=w.getClearAlpha(),j<1&&w.setClearColor(16777215,.5),w.clear();const Ae=w.toneMapping;w.toneMapping=ld,br(ge,rt,Ke),se.updateMultisampleRenderTarget(oe),se.updateRenderTargetMipmap(oe);let Fe=!1;for(let Le=0,Pe=Ge.length;Le<Pe;Le++){const ct=Ge[Le],mt=ct.object,Mt=ct.geometry,_t=ct.material,Lt=ct.group;if(_t.side===vc&&mt.layers.test(Ke.layers)){const Ct=_t.side;_t.side=ts,_t.needsUpdate=!0,Tr(mt,rt,Ke,Mt,_t,Lt),_t.side=Ct,_t.needsUpdate=!0,Fe=!0}}Fe===!0&&(se.updateMultisampleRenderTarget(oe),se.updateRenderTargetMipmap(oe)),w.setRenderTarget(ie),w.setClearColor(q,j),w.toneMapping=Ae}function br(ge,Ge,rt){const Ke=Ge.isScene===!0?Ge.overrideMaterial:null;for(let at=0,At=ge.length;at<At;at++){const ie=ge[at],Ae=ie.object,Fe=ie.geometry,Le=Ke===null?ie.material:Ke,Pe=ie.group;Ae.layers.test(rt.layers)&&Tr(Ae,Ge,rt,Fe,Le,Pe)}}function Tr(ge,Ge,rt,Ke,at,At){ge.onBeforeRender(w,Ge,rt,Ke,at,At),ge.modelViewMatrix.multiplyMatrices(rt.matrixWorldInverse,ge.matrixWorld),ge.normalMatrix.getNormalMatrix(ge.modelViewMatrix),at.onBeforeRender(w,Ge,rt,Ke,ge,At),at.transparent===!0&&at.side===vc&&at.forceSinglePass===!1?(at.side=ts,at.needsUpdate=!0,w.renderBufferDirect(rt,Ge,Ke,at,ge,At),at.side=Md,at.needsUpdate=!0,w.renderBufferDirect(rt,Ge,Ke,at,ge,At),at.side=vc):w.renderBufferDirect(rt,Ge,Ke,at,ge,At),ge.onAfterRender(w,Ge,rt,Ke,at,At)}function ei(ge,Ge,rt){Ge.isScene!==!0&&(Ge=ce);const Ke=Y.get(ge),at=y.state.lights,At=y.state.shadowsArray,ie=at.state.version,Ae=ne.getParameters(ge,at.state,At,Ge,rt),Fe=ne.getProgramCacheKey(Ae);let Le=Ke.programs;Ke.environment=ge.isMeshStandardMaterial?Ge.environment:null,Ke.fog=Ge.fog,Ke.envMap=(ge.isMeshStandardMaterial?Ee:ue).get(ge.envMap||Ke.environment),Le===void 0&&(ge.addEventListener("dispose",je),Le=new Map,Ke.programs=Le);let Pe=Le.get(Fe);if(Pe!==void 0){if(Ke.currentProgram===Pe&&Ke.lightsStateVersion===ie)return rn(ge,Ae),Pe}else Ae.uniforms=ne.getUniforms(ge),ge.onBuild(rt,Ae,w),ge.onBeforeCompile(Ae,w),Pe=ne.acquireProgram(Ae,Fe),Le.set(Fe,Pe),Ke.uniforms=Ae.uniforms;const ct=Ke.uniforms;return(!ge.isShaderMaterial&&!ge.isRawShaderMaterial||ge.clipping===!0)&&(ct.clippingPlanes=We.uniform),rn(ge,Ae),Ke.needsLights=Gr(ge),Ke.lightsStateVersion=ie,Ke.needsLights&&(ct.ambientLightColor.value=at.state.ambient,ct.lightProbe.value=at.state.probe,ct.directionalLights.value=at.state.directional,ct.directionalLightShadows.value=at.state.directionalShadow,ct.spotLights.value=at.state.spot,ct.spotLightShadows.value=at.state.spotShadow,ct.rectAreaLights.value=at.state.rectArea,ct.ltc_1.value=at.state.rectAreaLTC1,ct.ltc_2.value=at.state.rectAreaLTC2,ct.pointLights.value=at.state.point,ct.pointLightShadows.value=at.state.pointShadow,ct.hemisphereLights.value=at.state.hemi,ct.directionalShadowMap.value=at.state.directionalShadowMap,ct.directionalShadowMatrix.value=at.state.directionalShadowMatrix,ct.spotShadowMap.value=at.state.spotShadowMap,ct.spotLightMatrix.value=at.state.spotLightMatrix,ct.spotLightMap.value=at.state.spotLightMap,ct.pointShadowMap.value=at.state.pointShadowMap,ct.pointShadowMatrix.value=at.state.pointShadowMatrix),Ke.currentProgram=Pe,Ke.uniformsList=null,Pe}function Ar(ge){if(ge.uniformsList===null){const Ge=ge.currentProgram.getUniforms();ge.uniformsList=E1.seqWithValue(Ge.seq,ge.uniforms)}return ge.uniformsList}function rn(ge,Ge){const rt=Y.get(ge);rt.outputColorSpace=Ge.outputColorSpace,rt.batching=Ge.batching,rt.instancing=Ge.instancing,rt.instancingColor=Ge.instancingColor,rt.skinning=Ge.skinning,rt.morphTargets=Ge.morphTargets,rt.morphNormals=Ge.morphNormals,rt.morphColors=Ge.morphColors,rt.morphTargetsCount=Ge.morphTargetsCount,rt.numClippingPlanes=Ge.numClippingPlanes,rt.numIntersection=Ge.numClipIntersection,rt.vertexAlphas=Ge.vertexAlphas,rt.vertexTangents=Ge.vertexTangents,rt.toneMapping=Ge.toneMapping}function Oe(ge,Ge,rt,Ke,at){Ge.isScene!==!0&&(Ge=ce),se.resetTextureUnits();const At=Ge.fog,ie=Ke.isMeshStandardMaterial?Ge.environment:null,Ae=N===null?w.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Kc,Fe=(Ke.isMeshStandardMaterial?Ee:ue).get(Ke.envMap||ie),Le=Ke.vertexColors===!0&&!!rt.attributes.color&&rt.attributes.color.itemSize===4,Pe=!!rt.attributes.tangent&&(!!Ke.normalMap||Ke.anisotropy>0),ct=!!rt.morphAttributes.position,mt=!!rt.morphAttributes.normal,Mt=!!rt.morphAttributes.color;let _t=ld;Ke.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(_t=w.toneMapping);const Lt=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,Ct=Lt!==void 0?Lt.length:0,bt=Y.get(Ke),Yt=y.state.lights;if(te===!0&&(he===!0||ge!==k)){const Wr=ge===k&&Ke.id===F;We.setState(Ke,ge,Wr)}let zt=!1;Ke.version===bt.__version?(bt.needsLights&&bt.lightsStateVersion!==Yt.state.version||bt.outputColorSpace!==Ae||at.isBatchedMesh&&bt.batching===!1||!at.isBatchedMesh&&bt.batching===!0||at.isInstancedMesh&&bt.instancing===!1||!at.isInstancedMesh&&bt.instancing===!0||at.isSkinnedMesh&&bt.skinning===!1||!at.isSkinnedMesh&&bt.skinning===!0||at.isInstancedMesh&&bt.instancingColor===!0&&at.instanceColor===null||at.isInstancedMesh&&bt.instancingColor===!1&&at.instanceColor!==null||bt.envMap!==Fe||Ke.fog===!0&&bt.fog!==At||bt.numClippingPlanes!==void 0&&(bt.numClippingPlanes!==We.numPlanes||bt.numIntersection!==We.numIntersection)||bt.vertexAlphas!==Le||bt.vertexTangents!==Pe||bt.morphTargets!==ct||bt.morphNormals!==mt||bt.morphColors!==Mt||bt.toneMapping!==_t||H.isWebGL2===!0&&bt.morphTargetsCount!==Ct)&&(zt=!0):(zt=!0,bt.__version=Ke.version);let on=bt.currentProgram;zt===!0&&(on=ei(Ke,Ge,at));let pn=!1,_n=!1,Ut=!1;const en=on.getUniforms(),nn=bt.uniforms;if(re.useProgram(on.program)&&(pn=!0,_n=!0,Ut=!0),Ke.id!==F&&(F=Ke.id,_n=!0),pn||k!==ge){en.setValue(fe,"projectionMatrix",ge.projectionMatrix),en.setValue(fe,"viewMatrix",ge.matrixWorldInverse);const Wr=en.map.cameraPosition;Wr!==void 0&&Wr.setValue(fe,me.setFromMatrixPosition(ge.matrixWorld)),H.logarithmicDepthBuffer&&en.setValue(fe,"logDepthBufFC",2/(Math.log(ge.far+1)/Math.LN2)),(Ke.isMeshPhongMaterial||Ke.isMeshToonMaterial||Ke.isMeshLambertMaterial||Ke.isMeshBasicMaterial||Ke.isMeshStandardMaterial||Ke.isShaderMaterial)&&en.setValue(fe,"isOrthographic",ge.isOrthographicCamera===!0),k!==ge&&(k=ge,_n=!0,Ut=!0)}if(at.isSkinnedMesh){en.setOptional(fe,at,"bindMatrix"),en.setOptional(fe,at,"bindMatrixInverse");const Wr=at.skeleton;Wr&&(H.floatVertexTextures?(Wr.boneTexture===null&&Wr.computeBoneTexture(),en.setValue(fe,"boneTexture",Wr.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."))}at.isBatchedMesh&&(en.setOptional(fe,at,"batchingTexture"),en.setValue(fe,"batchingTexture",at._matricesTexture,se));const Ir=rt.morphAttributes;if((Ir.position!==void 0||Ir.normal!==void 0||Ir.color!==void 0&&H.isWebGL2===!0)&<.update(at,rt,on),(_n||bt.receiveShadow!==at.receiveShadow)&&(bt.receiveShadow=at.receiveShadow,en.setValue(fe,"receiveShadow",at.receiveShadow)),Ke.isMeshGouraudMaterial&&Ke.envMap!==null&&(nn.envMap.value=Fe,nn.flipEnvMap.value=Fe.isCubeTexture&&Fe.isRenderTargetTexture===!1?-1:1),_n&&(en.setValue(fe,"toneMappingExposure",w.toneMappingExposure),bt.needsLights&&Jt(nn,Ut),At&&Ke.fog===!0&&be.refreshFogUniforms(nn,At),be.refreshMaterialUniforms(nn,Ke,W,K,oe),E1.upload(fe,Ar(bt),nn,se)),Ke.isShaderMaterial&&Ke.uniformsNeedUpdate===!0&&(E1.upload(fe,Ar(bt),nn,se),Ke.uniformsNeedUpdate=!1),Ke.isSpriteMaterial&&en.setValue(fe,"center",at.center),en.setValue(fe,"modelViewMatrix",at.modelViewMatrix),en.setValue(fe,"normalMatrix",at.normalMatrix),en.setValue(fe,"modelMatrix",at.matrixWorld),Ke.isShaderMaterial||Ke.isRawShaderMaterial){const Wr=Ke.uniformsGroups;for(let Fn=0,vo=Wr.length;Fn<vo;Fn++)if(H.isWebGL2){const zn=Wr[Fn];et.update(zn,on),et.bind(zn,on)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return on}function Jt(ge,Ge){ge.ambientLightColor.needsUpdate=Ge,ge.lightProbe.needsUpdate=Ge,ge.directionalLights.needsUpdate=Ge,ge.directionalLightShadows.needsUpdate=Ge,ge.pointLights.needsUpdate=Ge,ge.pointLightShadows.needsUpdate=Ge,ge.spotLights.needsUpdate=Ge,ge.spotLightShadows.needsUpdate=Ge,ge.rectAreaLights.needsUpdate=Ge,ge.hemisphereLights.needsUpdate=Ge}function Gr(ge){return ge.isMeshLambertMaterial||ge.isMeshToonMaterial||ge.isMeshPhongMaterial||ge.isMeshStandardMaterial||ge.isShadowMaterial||ge.isShaderMaterial&&ge.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(ge,Ge,rt){Y.get(ge.texture).__webglTexture=Ge,Y.get(ge.depthTexture).__webglTexture=rt;const Ke=Y.get(ge);Ke.__hasExternalTextures=!0,Ke.__hasExternalTextures&&(Ke.__autoAllocateDepthBuffer=rt===void 0,Ke.__autoAllocateDepthBuffer||z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Ke.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ge,Ge){const rt=Y.get(ge);rt.__webglFramebuffer=Ge,rt.__useDefaultFramebuffer=Ge===void 0},this.setRenderTarget=function(ge,Ge=0,rt=0){N=ge,A=Ge,C=rt;let Ke=!0,at=null,At=!1,ie=!1;if(ge){const Fe=Y.get(ge);Fe.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(fe.FRAMEBUFFER,null),Ke=!1):Fe.__webglFramebuffer===void 0?se.setupRenderTarget(ge):Fe.__hasExternalTextures&&se.rebindTextures(ge,Y.get(ge.texture).__webglTexture,Y.get(ge.depthTexture).__webglTexture);const Le=ge.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(ie=!0);const Pe=Y.get(ge).__webglFramebuffer;ge.isWebGLCubeRenderTarget?(Array.isArray(Pe[Ge])?at=Pe[Ge][rt]:at=Pe[Ge],At=!0):H.isWebGL2&&ge.samples>0&&se.useMultisampledRTT(ge)===!1?at=Y.get(ge).__webglMultisampledFramebuffer:Array.isArray(Pe)?at=Pe[rt]:at=Pe,R.copy(ge.viewport),I.copy(ge.scissor),L=ge.scissorTest}else R.copy(Z).multiplyScalar(W).floor(),I.copy(B).multiplyScalar(W).floor(),L=G;if(re.bindFramebuffer(fe.FRAMEBUFFER,at)&&H.drawBuffers&&Ke&&re.drawBuffers(ge,at),re.viewport(R),re.scissor(I),re.setScissorTest(L),At){const Fe=Y.get(ge.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Fe.__webglTexture,rt)}else if(ie){const Fe=Y.get(ge.texture),Le=Ge||0;fe.framebufferTextureLayer(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,Fe.__webglTexture,rt||0,Le)}F=-1},this.readRenderTargetPixels=function(ge,Ge,rt,Ke,at,At,ie){if(!(ge&&ge.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=Y.get(ge).__webglFramebuffer;if(ge.isWebGLCubeRenderTarget&&ie!==void 0&&(Ae=Ae[ie]),Ae){re.bindFramebuffer(fe.FRAMEBUFFER,Ae);try{const Fe=ge.texture,Le=Fe.format,Pe=Fe.type;if(Le!==no&&ze.convert(Le)!==fe.getParameter(fe.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ct=Pe===nb&&(z.has("EXT_color_buffer_half_float")||H.isWebGL2&&z.has("EXT_color_buffer_float"));if(Pe!==cd&&ze.convert(Pe)!==fe.getParameter(fe.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Pe===Ac&&(H.isWebGL2||z.has("OES_texture_float")||z.has("WEBGL_color_buffer_float")))&&!ct){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ge>=0&&Ge<=ge.width-Ke&&rt>=0&&rt<=ge.height-at&&fe.readPixels(Ge,rt,Ke,at,ze.convert(Le),ze.convert(Pe),At)}finally{const Fe=N!==null?Y.get(N).__webglFramebuffer:null;re.bindFramebuffer(fe.FRAMEBUFFER,Fe)}}},this.copyFramebufferToTexture=function(ge,Ge,rt=0){const Ke=Math.pow(2,-rt),at=Math.floor(Ge.image.width*Ke),At=Math.floor(Ge.image.height*Ke);se.setTexture2D(Ge,0),fe.copyTexSubImage2D(fe.TEXTURE_2D,rt,0,0,ge.x,ge.y,at,At),re.unbindTexture()},this.copyTextureToTexture=function(ge,Ge,rt,Ke=0){const at=Ge.image.width,At=Ge.image.height,ie=ze.convert(rt.format),Ae=ze.convert(rt.type);se.setTexture2D(rt,0),fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,rt.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,rt.unpackAlignment),Ge.isDataTexture?fe.texSubImage2D(fe.TEXTURE_2D,Ke,ge.x,ge.y,at,At,ie,Ae,Ge.image.data):Ge.isCompressedTexture?fe.compressedTexSubImage2D(fe.TEXTURE_2D,Ke,ge.x,ge.y,Ge.mipmaps[0].width,Ge.mipmaps[0].height,ie,Ge.mipmaps[0].data):fe.texSubImage2D(fe.TEXTURE_2D,Ke,ge.x,ge.y,ie,Ae,Ge.image),Ke===0&&rt.generateMipmaps&&fe.generateMipmap(fe.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(ge,Ge,rt,Ke,at=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const At=ge.max.x-ge.min.x+1,ie=ge.max.y-ge.min.y+1,Ae=ge.max.z-ge.min.z+1,Fe=ze.convert(Ke.format),Le=ze.convert(Ke.type);let Pe;if(Ke.isData3DTexture)se.setTexture3D(Ke,0),Pe=fe.TEXTURE_3D;else if(Ke.isDataArrayTexture)se.setTexture2DArray(Ke,0),Pe=fe.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,Ke.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ke.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,Ke.unpackAlignment);const ct=fe.getParameter(fe.UNPACK_ROW_LENGTH),mt=fe.getParameter(fe.UNPACK_IMAGE_HEIGHT),Mt=fe.getParameter(fe.UNPACK_SKIP_PIXELS),_t=fe.getParameter(fe.UNPACK_SKIP_ROWS),Lt=fe.getParameter(fe.UNPACK_SKIP_IMAGES),Ct=rt.isCompressedTexture?rt.mipmaps[0]:rt.image;fe.pixelStorei(fe.UNPACK_ROW_LENGTH,Ct.width),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,Ct.height),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,ge.min.x),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,ge.min.y),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,ge.min.z),rt.isDataTexture||rt.isData3DTexture?fe.texSubImage3D(Pe,at,Ge.x,Ge.y,Ge.z,At,ie,Ae,Fe,Le,Ct.data):rt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),fe.compressedTexSubImage3D(Pe,at,Ge.x,Ge.y,Ge.z,At,ie,Ae,Fe,Ct.data)):fe.texSubImage3D(Pe,at,Ge.x,Ge.y,Ge.z,At,ie,Ae,Fe,Le,Ct),fe.pixelStorei(fe.UNPACK_ROW_LENGTH,ct),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,mt),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,Mt),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,_t),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,Lt),at===0&&Ke.generateMipmaps&&fe.generateMipmap(Pe),re.unbindTexture()},this.initTexture=function(ge){ge.isCubeTexture?se.setTextureCube(ge,0):ge.isData3DTexture?se.setTexture3D(ge,0):ge.isDataArrayTexture||ge.isCompressedArrayTexture?se.setTexture2DArray(ge,0):se.setTexture2D(ge,0),re.unbindTexture()},this.resetState=function(){A=0,C=0,N=null,re.reset(),Ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===UO?"display-p3":"srgb",n.unpackColorSpace=er.workingColorSpace===nE?"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===ra?Bh:aQ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Bh?ra:Kc}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 aUe extends aj{}aUe.prototype.isWebGL1Renderer=!0;class GO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Vt(e),this.near=n,this.far=r}clone(){return new GO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class sUe extends Da{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 oUe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=tj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Dc()}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=Dc()),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=Dc()),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 Ta=new De;class ed{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++)Ta.fromBufferAttribute(this,n),Ta.applyMatrix4(e),this.setXYZ(n,Ta.x,Ta.y,Ta.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ta.fromBufferAttribute(this,n),Ta.applyNormalMatrix(e),this.setXYZ(n,Ta.x,Ta.y,Ta.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ta.fromBufferAttribute(this,n),Ta.transformDirection(e),this.setXYZ(n,Ta.x,Ta.y,Ta.z);return this}setX(e,n){return this.normalized&&(n=Jn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Jn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Jn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Jn(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=cl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=cl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=cl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=cl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Jn(n,this.array),r=Jn(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=Jn(n,this.array),r=Jn(r,this.array),i=Jn(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=Jn(n,this.array),r=Jn(r,this.array),i=Jn(i,this.array),a=Jn(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 ks(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 ed(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 lUe extends ns{constructor(e=null,n=1,r=1,i,a,s,l,c,u=na,d=na,f,g){super(null,s,l,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function cUe(t,e){return t.z-e.z}function uUe(t,e){return e.z-t.z}class dUe{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 Hm="batchId",Ou=new dr,IV=new dr,hUe=new dr,FV=new dr,FC=new rE,I_=new uo,lh=new pl,Fx=new De,UC=new dUe,ma=new Io,F_=[];function fUe(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 mUe extends Io{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Sa,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 lUe(n,e,e,no,Ac);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,g=new u.constructor(r*d),p=new c.constructor(g,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new ks(l,1))}const s=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Hm,new ks(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Hm))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Hm}"`);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===Hm)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 uo);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,Ou),this.getBoundingBoxAt(i,I_).applyMatrix4(Ou),n.union(I_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new pl);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,Ou),this.getBoundingSphereAt(i,lh).applyMatrix4(Ou),n.union(lh))}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,l=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,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const v=this._geometryCount;this._geometryCount++,hUe.toArray(x,v*16),p.needsUpdate=!0,s.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new uo,sphereInitialized:!1,sphere:new pl});const y=this.geometry.getAttribute(Hm);for(let b=0;b<i.vertexCount;b++)y.setX(i.vertexStart+b,v);return y.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),s=n.getIndex(),l=this._reservedRanges[e];if(i&&s.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const p in r.attributes){if(p===Hm)continue;const x=n.getAttribute(p),v=r.getAttribute(p);fUe(x,v,c);const y=x.itemSize;for(let b=x.count,E=u;b<E;b++){const w=c+b;for(let T=0;T<y;T++)v.setComponent(w,T,0)}v.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<s.count;x++)a.setX(p+x,c+s.getX(x));for(let x=s.count,v=l.indexCount;x<v;x++)a.setX(p+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],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 l=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;l&&(g=l.getX(g)),a.expandByPoint(Fx.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,I_),I_.getCenter(a.center);const l=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 p=f;l&&(p=l.getX(p)),Fx.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(Fx))}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,l=this.matrixWorld,c=this.geometry;ma.material=this.material,ma.geometry.index=c.index,ma.geometry.attributes=c.attributes,ma.geometry.boundingBox===null&&(ma.geometry.boundingBox=new uo),ma.geometry.boundingSphere===null&&(ma.geometry.boundingSphere=new pl);for(let u=0;u<s;u++){if(!r[u]||!i[u])continue;const d=a[u];ma.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ma.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,ma.geometry.boundingBox),this.getBoundingSphereAt(u,ma.geometry.boundingSphere),ma.raycast(e,F_);for(let f=0,g=F_.length;f<g;f++){const p=F_[f];p.object=this,p.batchId=u,n.push(p)}F_.length=0}ma.material=null,ma.geometry.index=null,ma.geometry.attributes={},ma.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),l=s===null?1:s.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(FV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),FC.setFromProjectionMatrix(FV,e.isWebGPURenderer?rb:fl));let p=0;if(this.sortObjects){IV.copy(this.matrixWorld).invert(),Fx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(IV);for(let y=0,b=c.length;y<b;y++)if(c[y]){this.getMatrixAt(y,Ou),this.getBoundingSphereAt(y,lh).applyMatrix4(Ou);let E=!1;if(g&&(E=!FC.intersectsSphere(lh)),!E){const w=Fx.distanceTo(lh.center);UC.push(f[y],w)}}const x=UC.list,v=this.customSort;v===null?x.sort(a.transparent?uUe:cUe):v.call(this,x,r);for(let y=0,b=x.length;y<b;y++){const E=x[y];u[p]=E.start*l,d[p]=E.count,p++}UC.reset()}else for(let x=0,v=c.length;x<v;x++)if(c[x]){let y=!1;if(g&&(this.getMatrixAt(x,Ou),this.getBoundingSphereAt(x,lh).applyMatrix4(Ou),y=!FC.intersectsSphere(lh)),!y){const b=f[x];u[p]=b.start*l,d[p]=b.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,s){this.onBeforeRender(e,null,i,a,s)}}class ay extends vg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Vt(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 De,zV=new De,BV=new dr,zC=new BO,U_=new pl;class pUe extends Da{constructor(e=new Sa,n=new ay){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),zV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=UV.distanceTo(zV);e.setAttribute("lineDistance",new Jr(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(),U_.copy(r.boundingSphere),U_.applyMatrix4(i),U_.radius+=a,e.ray.intersectsSphere(U_)===!1)return;BV.copy(i).invert(),zC.copy(e.ray).applyMatrix4(BV);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new De,d=new De,f=new De,g=new De,p=this.isLineSegments?2:1,x=r.index,y=r.attributes.position;if(x!==null){const b=Math.max(0,s.start),E=Math.min(x.count,s.start+s.count);for(let w=b,T=E-1;w<T;w+=p){const A=x.getX(w),C=x.getX(w+1);if(u.fromBufferAttribute(y,A),d.fromBufferAttribute(y,C),zC.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const F=e.ray.origin.distanceTo(g);F<e.near||F>e.far||n.push({distance:F,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const b=Math.max(0,s.start),E=Math.min(y.count,s.start+s.count);for(let w=b,T=E-1;w<T;w+=p){if(u.fromBufferAttribute(y,w),d.fromBufferAttribute(y,w+1),zC.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(g);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const HV=new De,$V=new De;class aE extends pUe{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)HV.fromBufferAttribute(n,i),$V.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+HV.distanceTo($V);e.setAttribute("lineDistance",new Jr(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class gUe extends Sa{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new De,a=new De;if(e.index!==null){const s=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,p=f.count;for(let x=g,v=g+p;x<v;x+=3)for(let y=0;y<3;y++){const b=l.getX(x+y),E=l.getX(x+(y+1)%3);i.fromBufferAttribute(s,b),a.fromBufferAttribute(s,E),VV(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 l=0,c=s.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(s,d),a.fromBufferAttribute(s,f),VV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Jr(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function VV(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 xUe extends vg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=sQ,this.normalScale=new Qt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=IO,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 bUe extends ay{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 NQ extends Da{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Vt(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 BC=new dr,GV=new De,WV=new De;class yUe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Qt(512,512),this.map=null,this.mapPass=null,this.matrix=new dr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rE,this._frameExtents=new Qt(1,1),this._viewportCount=1,this._viewports=[new nr(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),WV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(WV),n.updateMatrixWorld(),BC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(BC),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(BC)}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 qV=new dr,Ux=new De,HC=new De;class vUe extends yUe{constructor(){super(new ws(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Qt(4,2),this._viewportCount=6,this._viewports=[new nr(2,1,1,1),new nr(0,1,1,1),new nr(3,1,1,1),new nr(1,1,1,1),new nr(3,0,1,1),new nr(1,0,1,1)],this._cubeDirections=[new De(1,0,0),new De(-1,0,0),new De(0,0,1),new De(0,0,-1),new De(0,1,0),new De(0,-1,0)],this._cubeUps=[new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,0,1),new De(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()),Ux.setFromMatrixPosition(e.matrixWorld),r.position.copy(Ux),HC.copy(r.position),HC.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(HC),r.updateMatrixWorld(),i.makeTranslation(-Ux.x,-Ux.y,-Ux.z),qV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(qV)}}class _Ue extends NQ{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 vUe}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 wUe extends NQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class SUe extends Sa{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 sj extends oUe{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 KV{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(ia(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const XV=new De,z_=new De;class MUe{constructor(e=new De,n=new De){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){XV.subVectors(e,this.start),z_.subVectors(this.end,this.start);const r=z_.dot(z_);let a=z_.dot(XV)/r;return n&&(a=ia(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 EUe extends aE{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 Sa;i.setAttribute("position",new Jr(n,3)),i.setAttribute("color",new Jr(r,3));const a=new ay({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Vt,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:eE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=eE);class gl{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"),gl.nextNameID=gl.nextNameID||0,this.$name.id=`lil-gui-name-${++gl.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 TUe extends gl{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 oj(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 AUe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:oj,toHexString:oj},ab={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},NUe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=ab.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 ab.toHexString(i)}},CUe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=ab.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 ab.toHexString(i)}},kUe=[AUe,ab,NUe,CUe];function PUe(t){return kUe.find(e=>e.match(t))}class jUe extends gl{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=PUe(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=oj(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 $C extends gl{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 RUe extends gl{constructor(e,n,r,i,a,s){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=s!==void 0;this.step(l?s:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let E=parseFloat(this.$input.value);isNaN(E)||(this._stepExplicit&&(E=this._snap(E)),this.setValue(this._clamp(E)))},r=E=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},a=E=>{this._inputFocused&&(E.preventDefault(),r(this._step*this._normalizeMouseWheel(E)))};let s=!1,l,c,u,d,f;const g=5,p=E=>{l=E.clientX,c=u=E.clientY,s=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},x=E=>{if(s){const w=E.clientX-l,T=E.clientY-c;Math.abs(T)>g?(E.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&v()}if(!s){const w=E.clientY-u;f-=w*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)},y=()=>{this._inputFocused=!0},b=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",y),this.$input.addEventListener("blur",b)}_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=(b,E,w,T,A)=>(b-E)/(w-E)*(A-T)+T,n=b=>{const E=this.$slider.getBoundingClientRect();let w=e(b,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=b=>{n(b.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,l,c;const u=b=>{b.preventDefault(),this._setDraggingStyle(!0),n(b.touches[0].clientX),s=!1},d=b=>{b.touches.length>1||(this._hasScrollBar?(l=b.touches[0].clientX,c=b.touches[0].clientY,s=!0):u(b),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=b=>{if(s){const E=b.touches[0].clientX-l,w=b.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(b):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else b.preventDefault(),n(b.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},p=this._callOnFinishChange.bind(this),x=400;let v;const y=b=>{if(Math.abs(b.deltaX)<Math.abs(b.deltaY)&&this._hasScrollBar)return;b.preventDefault();const w=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",y,{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 DUe extends gl{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 OUe extends gl{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 LUe=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function IUe(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 YV=!1;class Zw{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:s=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!YV&&l&&(IUe(LUe),YV=!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 DUe(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new RUe(this,e,n,r,i,a);case"boolean":return new TUe(this,e,n);case"string":return new OUe(this,e,n);case"function":return new $C(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,s)}addColor(e,n,r=1){return new jUe(this,e,n,r)}addFolder(e){const n=new Zw({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof $C||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 $C)){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 VC(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 l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(s,l)}c((r=r.apply(t,[])).next())}))}class WO{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 WO(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 qO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class ZV extends qO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Lu extends qO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class QV{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class Qw{constructor(e){this.lines=[],this.preamble=new QV(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,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,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new ZV(e,c,u,s);case"t0":return new Lu(e,c,s,0);case"t1":return new Lu(e,c,s,1);case"t2":return new Lu(e,c,s,2);case"t3":return new Lu(e,c,s,3);case"t4":return new Lu(e,c,s,4);case"t5":return new Lu(e,c,s,5);case"t6":return new Lu(e,c,s,6);case"t7":return new Lu(e,c,s,7);default:return new qO(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 ZV){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 QV(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"),l=a.indexOf("thumbnail end");s>-1?r=WO.parse(a.slice(s+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}Qw.prototype.parseGcode=Qw.prototype.parseGCode;const JV={type:"change"},GC={type:"start"},e7={type:"end"},B_=new BO,t7=new Hu,FUe=Math.cos(70*lQ.DEG2RAD);class UUe extends Mf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new De,this.cursor=new De,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:Mm.ROTATE,MIDDLE:Mm.DOLLY,RIGHT:Mm.PAN},this.touches={ONE:Em.ROTATE,TWO:Em.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(H){H.addEventListener("keydown",Ce),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ce),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(JV),r.update(),a=i.NONE},this.update=(function(){const H=new De,re=new mf().setFromUnitVectors(e.up,new De(0,1,0)),$=re.clone().invert(),Y=new De,se=new mf,ue=new De,Ee=2*Math.PI;return function(Me=null){const U=r.object.position;H.copy(U).sub(r.target),H.applyQuaternion(re),l.setFromVector3(H),r.autoRotate&&a===i.NONE&&R((function(ye){return ye!==null?2*Math.PI/60*r.autoRotateSpeed*ye:2*Math.PI/60/60*r.autoRotateSpeed})(Me)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let O=r.minAzimuthAngle,ne=r.maxAzimuthAngle;isFinite(O)&&isFinite(ne)&&(O<-Math.PI?O+=Ee:O>Math.PI&&(O-=Ee),ne<-Math.PI?ne+=Ee:ne>Math.PI&&(ne-=Ee),l.theta=O<=ne?Math.max(O,Math.min(ne,l.theta)):l.theta>(O+ne)/2?Math.max(O,l.theta):Math.min(ne,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=J(l.radius):l.radius=J(l.radius*u),H.setFromSpherical(l),H.applyQuaternion($),U.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let be=!1;if(r.zoomToCursor&&C){let ye=null;if(r.object.isPerspectiveCamera){const _e=H.length();ye=J(_e*u);const We=_e-ye;r.object.position.addScaledVector(T,We),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const _e=new De(A.x,A.y,0);_e.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0;const We=new De(A.x,A.y,0);We.unproject(r.object),r.object.position.sub(We).add(_e),r.object.updateMatrixWorld(),ye=H.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;ye!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(ye).add(r.object.position):(B_.origin.copy(r.object.position),B_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(B_.direction))<FUe?e.lookAt(r.target):(t7.setFromNormalAndCoplanarPoint(r.object.up,r.target),B_.intersectPlane(t7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0);return u=1,C=!1,!!(be||Y.distanceToSquared(r.object.position)>s||8*(1-se.dot(r.object.quaternion))>s||ue.distanceToSquared(r.target)>0)&&(r.dispatchEvent(JV),Y.copy(r.object.position),se.copy(r.object.quaternion),ue.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",fe),r.domElement.removeEventListener("pointerdown",xe),r.domElement.removeEventListener("pointercancel",me),r.domElement.removeEventListener("wheel",ce),r.domElement.removeEventListener("pointermove",Te),r.domElement.removeEventListener("pointerup",me),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Ce),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,l=new KV,c=new KV;let u=1;const d=new De,f=new Qt,g=new Qt,p=new Qt,x=new Qt,v=new Qt,y=new Qt,b=new Qt,E=new Qt,w=new Qt,T=new De,A=new Qt;let C=!1;const N=[],F={};function k(){return Math.pow(.95,r.zoomSpeed)}function R(H){c.theta-=H}function I(H){c.phi-=H}const L=(function(){const H=new De;return function(re,$){H.setFromMatrixColumn($,0),H.multiplyScalar(-re),d.add(H)}})(),q=(function(){const H=new De;return function(re,$){r.screenSpacePanning===!0?H.setFromMatrixColumn($,1):(H.setFromMatrixColumn($,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(re),d.add(H)}})(),j=(function(){const H=new De;return function(re,$){const Y=r.domElement;if(r.object.isPerspectiveCamera){const se=r.object.position;H.copy(se).sub(r.target);let ue=H.length();ue*=Math.tan(r.object.fov/2*Math.PI/180),L(2*re*ue/Y.clientHeight,r.object.matrix),q(2*$*ue/Y.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(re*(r.object.right-r.object.left)/r.object.zoom/Y.clientWidth,r.object.matrix),q($*(r.object.top-r.object.bottom)/r.object.zoom/Y.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function V(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function W(H){if(!r.zoomToCursor)return;C=!0;const re=r.domElement.getBoundingClientRect(),$=H.clientX-re.left,Y=H.clientY-re.top,se=re.width,ue=re.height;A.x=$/se*2-1,A.y=-Y/ue*2+1,T.set(A.x,A.y,1).unproject(r.object).sub(r.object.position).normalize()}function J(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function ee(H){f.set(H.clientX,H.clientY)}function Z(H){x.set(H.clientX,H.clientY)}function B(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);f.set(H,re)}}function G(){if(N.length===1)x.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);x.set(H,re)}}function Q(){const H=N[0].pageX-N[1].pageX,re=N[0].pageY-N[1].pageY,$=Math.sqrt(H*H+re*re);b.set(0,$)}function te(H){if(N.length==1)g.set(H.pageX,H.pageY);else{const $=z(H),Y=.5*(H.pageX+$.x),se=.5*(H.pageY+$.y);g.set(Y,se)}p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const re=r.domElement;R(2*Math.PI*p.x/re.clientHeight),I(2*Math.PI*p.y/re.clientHeight),f.copy(g)}function he(H){if(N.length===1)v.set(H.pageX,H.pageY);else{const re=z(H),$=.5*(H.pageX+re.x),Y=.5*(H.pageY+re.y);v.set($,Y)}y.subVectors(v,x).multiplyScalar(r.panSpeed),j(y.x,y.y),x.copy(v)}function oe(H){const re=z(H),$=H.pageX-re.x,Y=H.pageY-re.y,se=Math.sqrt($*$+Y*Y);E.set(0,se),w.set(0,Math.pow(E.y/b.y,r.zoomSpeed)),V(w.y),b.copy(E)}function xe(H){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture(H.pointerId),r.domElement.addEventListener("pointermove",Te),r.domElement.addEventListener("pointerup",me)),(function(re){N.push(re)})(H),H.pointerType==="touch"?(function(re){switch(Ie(re),N.length){case 1:switch(r.touches.ONE){case Em.ROTATE:if(r.enableRotate===!1)return;B(),a=i.TOUCH_ROTATE;break;case Em.PAN:if(r.enablePan===!1)return;G(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Em.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&Q(),r.enablePan&&G(),a=i.TOUCH_DOLLY_PAN;break;case Em.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&Q(),r.enableRotate&&B(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(GC)})(H):(function(re){let $;switch(re.button){case 0:$=r.mouseButtons.LEFT;break;case 1:$=r.mouseButtons.MIDDLE;break;case 2:$=r.mouseButtons.RIGHT;break;default:$=-1}switch($){case Mm.DOLLY:if(r.enableZoom===!1)return;(function(Y){W(Y),b.set(Y.clientX,Y.clientY)})(re),a=i.DOLLY;break;case Mm.ROTATE:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enablePan===!1)return;Z(re),a=i.PAN}else{if(r.enableRotate===!1)return;ee(re),a=i.ROTATE}break;case Mm.PAN:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enableRotate===!1)return;ee(re),a=i.ROTATE}else{if(r.enablePan===!1)return;Z(re),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(GC)})(H))}function Te(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(re){switch(Ie(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;he(re),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function($){r.enableZoom&&oe($),r.enablePan&&he($)})(re),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function($){r.enableZoom&&oe($),r.enableRotate&&te($)})(re),r.update();break;default:a=i.NONE}})(H):(function(re){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function($){g.set($.clientX,$.clientY),p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const Y=r.domElement;R(2*Math.PI*p.x/Y.clientHeight),I(2*Math.PI*p.y/Y.clientHeight),f.copy(g),r.update()})(re);break;case i.DOLLY:if(r.enableZoom===!1)return;(function($){E.set($.clientX,$.clientY),w.subVectors(E,b),w.y>0?V(k()):w.y<0&&K(k()),b.copy(E),r.update()})(re);break;case i.PAN:if(r.enablePan===!1)return;(function($){v.set($.clientX,$.clientY),y.subVectors(v,x).multiplyScalar(r.panSpeed),j(y.x,y.y),x.copy(v),r.update()})(re)}})(H))}function me(H){(function(re){delete F[re.pointerId];for(let $=0;$<N.length;$++)if(N[$].pointerId==re.pointerId)return void N.splice($,1)})(H),N.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",Te),r.domElement.removeEventListener("pointerup",me)),r.dispatchEvent(e7),a=i.NONE}function ce(H){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(H.preventDefault(),r.dispatchEvent(GC),(function(re){W(re),re.deltaY<0?K(k()):re.deltaY>0&&V(k()),r.update()})(H),r.dispatchEvent(e7))}function Ce(H){r.enabled!==!1&&r.enablePan!==!1&&(function(re){let $=!1;switch(re.code){case r.keys.UP:re.ctrlKey||re.metaKey||re.shiftKey?I(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),$=!0;break;case r.keys.BOTTOM:re.ctrlKey||re.metaKey||re.shiftKey?I(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),$=!0;break;case r.keys.LEFT:re.ctrlKey||re.metaKey||re.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),$=!0;break;case r.keys.RIGHT:re.ctrlKey||re.metaKey||re.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),$=!0}$&&(re.preventDefault(),r.update())})(H)}function fe(H){r.enabled!==!1&&H.preventDefault()}function Ie(H){let re=F[H.pointerId];re===void 0&&(re=new Qt,F[H.pointerId]=re),re.set(H.pageX,H.pageY)}function z(H){const re=H.pointerId===N[0].pointerId?N[1]:N[0];return F[re.pointerId]}r.domElement.addEventListener("contextmenu",fe),r.domElement.addEventListener("pointerdown",xe),r.domElement.addEventListener("pointercancel",me),r.domElement.addEventListener("wheel",ce,{passive:!1}),this.update()}}Tt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Qt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Za.line={uniforms:HO.merge([Tt.common,Tt.fog,Tt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class CQ extends Ed{constructor(e){super({type:"LineMaterial",uniforms:HO.clone(Za.line.uniforms),vertexShader:Za.line.vertexShader,fragmentShader:Za.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 n7=new uo,H_=new De;class kQ extends SUe{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 Jr([-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 Jr([-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 sj(n,6,1);return this.setAttribute("instanceStart",new ed(r,3,0)),this.setAttribute("instanceEnd",new ed(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 sj(n,6,1);return this.setAttribute("instanceColorStart",new ed(r,3,0)),this.setAttribute("instanceColorEnd",new ed(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 gUe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new uo);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),n7.setFromBufferAttribute(n),this.boundingBox.union(n7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new pl),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++)H_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(H_)),H_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(H_));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 r7=new De,i7=new De,Zi=new nr,Qi=new nr,el=new nr,WC=new De,qC=new dr,Ji=new MUe,a7=new De,$_=new uo,V_=new pl,tl=new nr;let nl,_h;function s7(t,e,n){return tl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),tl.multiplyScalar(1/tl.w),tl.x=_h/n.width,tl.y=_h/n.height,tl.applyMatrix4(t.projectionMatrixInverse),tl.multiplyScalar(1/tl.w),Math.abs(Math.max(tl.x,tl.y))}class zUe extends Io{constructor(e=new kQ,n=new CQ({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,l=0,c=n.count;s<c;s++,l+=2)r7.fromBufferAttribute(n,s),i7.fromBufferAttribute(r,s),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+r7.distanceTo(i7);const a=new sj(i,2,1);return e.setAttribute("instanceDistanceStart",new ed(a,1,0)),e.setAttribute("instanceDistanceEnd",new ed(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;nl=e.ray;const s=this.matrixWorld,l=this.geometry,c=this.material;let u,d;_h=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),V_.copy(l.boundingSphere).applyMatrix4(s),r?u=.5*_h:u=s7(i,Math.max(i.near,V_.distanceToPoint(nl.origin)),c.resolution),V_.radius+=u,nl.intersectsSphere(V_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),$_.copy(l.boundingBox).applyMatrix4(s),r?d=.5*_h:d=s7(i,Math.max(i.near,$_.distanceToPoint(nl.origin)),c.resolution),$_.expandByScalar(d),nl.intersectsBox($_)!==!1&&(r?(function(f,g){const p=f.matrixWorld,x=f.geometry,v=x.attributes.instanceStart,y=x.attributes.instanceEnd;for(let b=0,E=Math.min(x.instanceCount,v.count);b<E;b++){Ji.start.fromBufferAttribute(v,b),Ji.end.fromBufferAttribute(y,b),Ji.applyMatrix4(p);const w=new De,T=new De;nl.distanceSqToSegment(Ji.start,Ji.end,T,w),T.distanceTo(w)<.5*_h&&g.push({point:T,pointOnLine:w,distance:nl.origin.distanceTo(T),object:f,face:null,faceIndex:b,uv:null,uv1:null})}})(this,n):(function(f,g,p){const x=g.projectionMatrix,v=f.material.resolution,y=f.matrixWorld,b=f.geometry,E=b.attributes.instanceStart,w=b.attributes.instanceEnd,T=Math.min(b.instanceCount,E.count),A=-g.near;nl.at(1,el),el.w=1,el.applyMatrix4(g.matrixWorldInverse),el.applyMatrix4(x),el.multiplyScalar(1/el.w),el.x*=v.x/2,el.y*=v.y/2,el.z=0,WC.copy(el),qC.multiplyMatrices(g.matrixWorldInverse,y);for(let C=0,N=T;C<N;C++){if(Zi.fromBufferAttribute(E,C),Qi.fromBufferAttribute(w,C),Zi.w=1,Qi.w=1,Zi.applyMatrix4(qC),Qi.applyMatrix4(qC),Zi.z>A&&Qi.z>A)continue;if(Zi.z>A){const L=Zi.z-Qi.z,q=(Zi.z-A)/L;Zi.lerp(Qi,q)}else if(Qi.z>A){const L=Qi.z-Zi.z,q=(Qi.z-A)/L;Qi.lerp(Zi,q)}Zi.applyMatrix4(x),Qi.applyMatrix4(x),Zi.multiplyScalar(1/Zi.w),Qi.multiplyScalar(1/Qi.w),Zi.x*=v.x/2,Zi.y*=v.y/2,Qi.x*=v.x/2,Qi.y*=v.y/2,Ji.start.copy(Zi),Ji.start.z=0,Ji.end.copy(Qi),Ji.end.z=0;const F=Ji.closestPointToPointParameter(WC,!0);Ji.at(F,a7);const k=lQ.lerp(Zi.z,Qi.z,F),R=k>=-1&&k<=1,I=WC.distanceTo(a7)<.5*_h;if(R&&I){Ji.start.fromBufferAttribute(E,C),Ji.end.fromBufferAttribute(w,C),Ji.start.applyMatrix4(y),Ji.end.applyMatrix4(y);const L=new De,q=new De;nl.distanceSqToSegment(Ji.start,Ji.end,q,L),p.push({point:q,pointOnLine:L,distance:nl.origin.distanceTo(q),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class BUe extends aE{constructor(e,n,r,i,a=4473924,s=8947848){a=new Vt(a),s=new Vt(s);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let g=-1*(e=l*n/2);g<=e;g+=n){c.push(g,0,-1*r,g,0,r);const p=g===0?a:s;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let g=-1*r;g<=r;g+=i){c.push(-1*e,0,g,e,0,g);const p=g===0?a:s;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Sa;f.setAttribute("position",new Jr(c,3)),f.setAttribute("color",new Jr(u,3)),super(f,new ay({vertexColors:!0,toneMapped:!1}))}}function HUe(t,e,n,r){const i=(function(s,l,c){s*=.5,l*=.5,c*=.5;const u=new Sa,d=[];return d.push(-s,-l,-c,-s,l,-c,-s,l,-c,s,l,-c,s,l,-c,s,-l,-c,s,-l,-c,-s,-l,-c,-s,-l,c,-s,l,c,-s,l,c,s,l,c,s,l,c,s,-l,c,s,-l,c,-s,-l,c,-s,-l,-c,-s,-l,c,-s,l,-c,-s,l,c,s,l,-c,s,l,c,s,-l,-c,s,-l,c),u.setAttribute("position",new Jr(d,3)),u})(t,e,n),a=new aE(i,new bUe({color:new Vt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var l0=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,l=n(new l0.Panel("FPS","#0ff","#002")),c=n(new l0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new l0.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&&(l.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}};l0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),l=80*s,c=48*s,u=3*s,d=2*s,f=3*s,g=15*s,p=74*s,x=30*s,v=document.createElement("canvas");v.width=l,v.height=c,v.style.cssText="width:80px;height:48px";var y=v.getContext("2d");return y.font="bold "+9*s+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=n,y.fillRect(0,0,l,c),y.fillStyle=e,y.fillText(t,u,d),y.fillRect(f,g,p,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f,g,p,x),{dom:v,update:function(b,E){r=Math.min(r,b),i=Math.max(i,b),y.fillStyle=n,y.globalAlpha=1,y.fillRect(0,0,l,g),y.fillStyle=e,y.fillText(a(b)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),y.drawImage(v,f+s,g,p-s,x,f,g,p-s,x),y.fillRect(f+p-s,g,s,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f+p-s,g,s,a((1-b/E)*x))}}};var $Ue=l0;class o7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new Zw,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 Zw,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 VUe extends Sa{constructor(e=[new De],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 De,s=new De,l=new Qt,c=[],u=[],d=[],f=[];function g(p){const[x,v,y]=(function(b){const E=e[b],w=new De,T=new De,A=new De,C=new De;w.copy(E).sub(e[b-1]||E).normalize().add((e[b+1]||E).clone().sub(E).normalize()).normalize();let N=Number.MAX_VALUE;const F=Math.abs(w.x),k=Math.abs(w.y),R=Math.abs(w.z);return F<=N&&(N=F,T.set(1,0,0)),k<=N&&(N=k,T.set(0,1,0)),R<=N&&T.set(0,0,1),C.crossVectors(w,T).normalize(),T.crossVectors(w,C),A.crossVectors(w,T),[E,T,A]})(p);for(let b=0;b<=i;b++){const E=b/i*Math.PI*2,w=Math.sin(E),T=-Math.cos(E);s.x=T*v.x+w*y.x,s.y=T*v.y+w*y.y,s.z=T*v.z+w*y.z,s.normalize(),u.push(s.x,s.y,s.z),a.x=x.x+n*s.x*.5,a.y=x.y+n*s.y*.5,a.z=x.z+r*s.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let p=0;p<e.length;p++)g(p);g(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const v=(i+1)*(p-1)+(x-1),y=(i+1)*p+(x-1),b=(i+1)*p+x,E=(i+1)*(p-1)+x;f.push(v,y,E),f.push(y,b,E)}})()})(),this.setIndex(f),this.setAttribute("position",new Jr(c,3)),this.setAttribute("normal",new Jr(u,3)),this.setAttribute("uv",new Jr(d,2))}}class c0{static get initial(){const e=new c0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const KC={h:0,s:0,l:0};class gp{constructor(e){var n,r,i,a,s,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=c0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=gp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Vt(14737632),this._travelColor=new Vt(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 Qw(this.minLayerThreshold),this.scene=new sUe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Vt(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=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new $Ue:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Vt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Vt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Vt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new Vt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+eE),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 aj({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new aj({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new ws(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 GO(this._backgroundColor,g,f),this.resize(),this.controls=new UUe(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 Vt(r)}else this._extrusionColor=new Vt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?gp.defaultExtrusionColor:this._extrusionColor instanceof Vt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:gp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Vt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Vt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Vt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Vt(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 EUe(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 wUe(13421772,.3*Math.PI),n=new _Ue(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 Yx;return n.name=e,n.quaternion.setFromEuler(new ry(-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=c0.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 VC(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,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=g;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const p=g,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=p.params.e)!==null&&s!==void 0?s:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const v=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,v,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,v))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const s=.1+.7*n/this.layers.length;a.getHSL(KC),a=new Vt().setHSL(KC.h,KC.s,s)}if(n==this.layers.length-1){const s=(r=this._topLayerColor)!==null&&r!==void 0?r:a,l=(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],l.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...u,...c],l.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new BUe(this.buildVolume.x,10,this.buildVolume.y,10));const e=HUe(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 Qw(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=c0.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,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let p=r.r,x=r.i,v=r.j;if(p){const V=d-l,K=f-c,W=Math.sqrt(Math.pow(V/2,2)+Math.pow(K/2,2));p=Math.max(p,W);const J=Math.pow(V,2)+Math.pow(K,2),ee=Math.pow(p,2)-J/4;let Z=Math.sqrt(ee/J);(a&&p<0||!a&&p>0)&&(Z=-Z),x=V/2+K*Z,v=K/2-V*Z}const y=l==d&&c==f,b=l+x,E=c+v,w=Math.sqrt(x*x+v*v),T=Math.atan2(-v,-x),A=Math.atan2(f-E,d-b);let C;y?C=2*Math.PI:(C=a?T-A:A-T,C<0&&(C+=2*Math.PI));let N=w*C/1.8;this.inches&&(N*=25),N<1&&(N=1);let F=C/N;F*=a?-1:1;const k=[];k.push({x:l,y:c,z:u});const R=(u-g)/N;let I=l,L=c,q=u,j=T;for(let V=0;V<N-1;V++)j+=F,I=b+w*Math.cos(j),L=E+w*Math.sin(j),q+=R,k.push({x:I,y:L,z:q});k.push({x:r.x,y:r.y,z:r.z});for(let V=0;V<k.length-1;V++)s.push(k[V].x,k[V].y,k[V].z,k[V+1].x,k[V+1].y,k[V+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Sa;i.setAttribute("position",new Jr(e,3)),this.disposables.push(i);const a=new ay({color:n});this.disposables.push(a);const s=new aE(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 l=e.slice(s,s+9),c=new De(l[0],l[1],l[2]),u=new De(l[3],l[4],l[5]),d=new De(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((s=>{var l;const c=new VUe(s,this.extrusionWidth,this.lineHeight||r,4);(l=this._geometries)[n]||(l[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new kQ;this.disposables.push(i);const a=new CQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new zUe(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=>VC(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 xUe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),s=new mUe(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 VC(this,void 0,void 0,(function*(){const i=e.getReader();let a,s="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(s+f),s=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new o7(this):typeof this.devMode=="object"&&(this.devGui=new o7(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())}}gp.defaultExtrusionColor=new Vt("hotpink");const GUe=function(t){return new gp(t)};function WUe({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=M.useRef(null),a=M.useRef(null),s=M.useRef(null),[l,c]=M.useState(!0),[u,d]=M.useState(null),[f,g]=M.useState(!1),[p,x]=M.useState(0),[v,y]=M.useState(0);M.useEffect(()=>{if(!i.current)return;const w=i.current,T=n&&n.length>0,A=n&&n.length>1,C=T?n[0]:"#00ae42",N=GUe({canvas:w,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:A?n:C,...A?{}:{topLayerColor:C},...A?{disableGradient:!0}:{},lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=N,c(!0),d(null),g(!1),fetch(t).then(async k=>{if(!k.ok)throw k.status===404&&(await k.json().catch(()=>({}))).detail?.includes("sliced")?(g(!0),new Error("not_sliced")):new Error("Failed to load G-code");return k.text()}).then(k=>{let R=k;A&&(R=k.split(`
- `).map(L=>{const q=L.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(q){const j=parseInt(q[2],10);if(j>15)return`${q[1]}; FILTERED: T${j}${q[3]||""}`}return L}).join(`
- `),R=`T0
- ${R}`),N.processGCode(R);const I=N.layers?.length||0;y(I),x(I),N.render(),c(!1)}).catch(k=>{d(k.message),c(!1)});const F=()=>{if(w.parentElement){const k=w.parentElement.getBoundingClientRect();w.width=k.width,w.height=k.height,N.resize()}};return F(),window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F),s.current&&cancelAnimationFrame(s.current),N.dispose()}},[t,e,n]);const b=M.useCallback(w=>{if(!a.current)return;const T=Math.max(1,Math.min(w,v));x(T),s.current&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=T,a.current.render())})},[v]),E=w=>{b(parseInt(w.target.value,10))};return o.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[o.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[o.jsx("canvas",{ref:i,className:"w-full h-full"}),l&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsxs("div",{className:"text-center",children:[o.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),o.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),f&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsxs("div",{className:"text-center max-w-sm px-4",children:[o.jsx(Ole,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),o.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),o.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&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsx("div",{className:"text-center text-red-400",children:o.jsx("p",{className:"text-sm",children:u})})})]}),!l&&!u&&!f&&v>0&&o.jsx("div",{className:"mt-4 px-2",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(pd,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),o.jsx("button",{onClick:()=>b(p-1),disabled:p<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:o.jsx(Yh,{className:"w-4 h-4"})}),o.jsx("input",{type:"range",min:1,max:v,value:p,onChange:E,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),o.jsx("button",{onClick:()=>b(p+1),disabled:p>=v,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:o.jsx(Xc,{className:"w-4 h-4"})}),o.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[p," / ",v]})]})})]})}function qUe({archiveId:t,title:e,onClose:n}){const[r,i]=M.useState(null),[a,s]=M.useState(null),[l,c]=M.useState(!0);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),M.useEffect(()=>{Se.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}${Se.getArchiveForSlicer(t,d)}`;gh(f)};return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:o.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:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:u,children:[o.jsx(ba,{className:"w-4 h-4"}),"Open in Slicer"]}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:n,children:o.jsx(Gt,{className:"w-5 h-5"})})]})]}),a&&o.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[o.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:[o.jsx(_p,{className:"w-4 h-4"}),"3D Model",!a.has_model&&o.jsx("span",{className:"text-xs",children:"(not available)"})]}),o.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:[o.jsx(ule,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&o.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),o.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?o.jsx(HDe,{url:Se.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):r==="gcode"&&a?o.jsx(WUe,{gcodeUrl:Se.getArchiveGcode(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function KUe({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const i=mn(),[a,s]=M.useState(null),[l,c]=M.useState(!1);M.useEffect(()=>{const T=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);const{data:u,isLoading:d}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:f}=gt({queryKey:["archive-filaments",t],queryFn:()=>Se.getArchiveFilamentRequirements(t)}),{data:g}=gt({queryKey:["printer-status",a],queryFn:()=>Se.getPrinterStatus(a),enabled:!!a}),p=vt({mutationFn:()=>{if(!a)throw new Error("No printer selected");return Se.reprintArchive(t,a)},onSuccess:()=>{r(),n()}}),x=u?.filter(T=>T.is_active)||[],v=T=>T?`#${T.replace("#","").substring(0,6)}`:"#808080",y=(T,A,C,N)=>{const F=String.fromCharCode(65+(T>=128?T-128:T));return C?`HT-${F}`:`AMS-${F} Slot ${A+1}`},b=M.useMemo(()=>{const T=[];return g?.ams?.forEach(A=>{const C=A.tray.length===1;A.tray.forEach(N=>{N.tray_type&&T.push({type:N.tray_type,color:v(N.tray_color),amsId:A.id,trayId:N.id,isHt:C,isExternal:!1,label:y(A.id,N.id,C)})})}),g?.vt_tray?.tray_type&&T.push({type:g.vt_tray.tray_type,color:v(g.vt_tray.tray_color),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External"}),T},[g]),E=M.useMemo(()=>{if(!f?.filaments||f.filaments.length===0)return[];const T=C=>C?C.replace("#","").toLowerCase().substring(0,6):"",A=(C,N,F=40)=>{const k=T(C),R=T(N);if(!k||!R||k.length<6||R.length<6)return!1;const I=parseInt(k.substring(0,2),16),L=parseInt(k.substring(2,4),16),q=parseInt(k.substring(4,6),16),j=parseInt(R.substring(0,2),16),V=parseInt(R.substring(2,4),16),K=parseInt(R.substring(4,6),16);return Math.abs(I-j)<=F&&Math.abs(L-V)<=F&&Math.abs(q-K)<=F};return f.filaments.map(C=>{const N=b.find(V=>V.type?.toUpperCase()===C.type?.toUpperCase()&&T(V.color)===T(C.color)),F=!N&&b.find(V=>V.type?.toUpperCase()===C.type?.toUpperCase()&&A(V.color,C.color)),k=!N&&!F&&b.find(V=>V.type?.toUpperCase()===C.type?.toUpperCase()),R=N||F||k||void 0,I=!!R,L=I,q=!!N||!!F;let j;return N||F?j="match":k?j="type_only":j="mismatch",{...C,loaded:R,hasFilament:I,typeMatch:L,colorMatch:q,status:j}})},[f,b]),w=E.some(T=>T.status==="mismatch");return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:o.jsx(wt,{className:"w-full max-w-md",children:o.jsxs(Et,{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:n,children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",o.jsx("span",{className:"text-white",children:e})," to a printer"]}),d?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):x.length===0?o.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):o.jsx("div",{className:"space-y-2 mb-6",children:x.map(T=>o.jsxs("button",{onClick:()=>s(T.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${a===T.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[o.jsx("div",{className:`p-2 rounded-lg ${a===T.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:o.jsx(Vi,{className:`w-5 h-5 ${a===T.id?"text-bambu-green":"text-bambu-gray"}`})}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-white font-medium",children:T.name}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[T.model||"Unknown model"," • ",T.ip_address]})]})]},T.id))}),a&&E.length>0&&o.jsxs("div",{className:"mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Filament Check"}),o.jsxs("button",{onClick:async()=>{if(a){c(!0);try{await Se.refreshPrinterStatus(a),await new Promise(T=>setTimeout(T,500)),await i.refetchQueries({queryKey:["printer-status",a]})}finally{c(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Re-read AMS status from printer",disabled:l,children:[o.jsx(_a,{className:`w-3 h-3 ${l?"animate-spin":""}`}),o.jsx("span",{children:"Re-read"})]}),w?o.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[o.jsx(Gn,{className:"w-3 h-3"}),"Type not found"]}):E.some(T=>T.status==="type_only")?o.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[o.jsx(Gn,{className:"w-3 h-3"}),"Color mismatch"]}):o.jsxs("span",{className:"text-xs text-bambu-green flex items-center gap-1",children:[o.jsx(xl,{className:"w-3 h-3"}),"Ready"]})]}),o.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 space-y-2 text-xs",children:E.map((T,A)=>o.jsxs("div",{className:"grid items-center gap-2",style:{gridTemplateColumns:"16px 1fr auto 16px 1fr 16px"},children:[o.jsx("span",{title:`Required: ${T.color}`,children:o.jsx(yU,{className:"w-3 h-3 flex-shrink-0",fill:T.color,stroke:T.color})}),o.jsxs("span",{className:"text-white truncate",children:[T.type," ",o.jsxs("span",{className:"text-bambu-gray",children:["(",T.used_grams,"g)"]})]}),o.jsx("span",{className:"text-bambu-gray",children:"→"}),T.loaded?o.jsx("span",{title:`Loaded: ${T.loaded.color}`,children:o.jsx(yU,{className:"w-3 h-3 flex-shrink-0",fill:T.loaded.color,stroke:T.loaded.color})}):o.jsx("span",{}),o.jsx("span",{className:T.status==="match"?"text-bambu-green":T.status==="type_only"?"text-yellow-400":"text-orange-400",children:T.loaded?o.jsxs(o.Fragment,{children:[T.loaded.type," ",o.jsxs("span",{className:"text-bambu-gray",children:["(",T.loaded.label,")"]})]}):"Not loaded"}),T.status==="match"?o.jsx(xl,{className:"w-3 h-3 text-bambu-green"}):T.status==="type_only"?o.jsx("span",{title:"Same type, different color",children:o.jsx(Gn,{className:"w-3 h-3 text-yellow-400"})}):o.jsx("span",{title:"Filament type not loaded",children:o.jsx(Gn,{className:"w-3 h-3 text-orange-400"})})]},A))}),w&&o.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]}),p.isError&&o.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:p.error.message||"Failed to start print"}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(ke,{onClick:()=>p.mutate(),disabled:!a||p.isPending,className:"flex-1",children:p.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Vi,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function XUe({onClose:t,initialFiles:e}){const n=mn(),{showToast:r}=Sr(),i=M.useRef(null),[a,s]=M.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[l,c]=M.useState(!1),[u,d]=M.useState(),[f,g]=M.useState(null);M.useEffect(()=>{const N=F=>{F.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);const{data:p}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),x=vt({mutationFn:N=>Se.uploadArchivesBulk(N,u),onSuccess:N=>{g(N),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(F=>F.map(k=>{const R=N.results.find(L=>L.filename===k.file.name),I=N.errors.find(L=>L.filename===k.file.name);return R?{...k,status:"success",archiveId:R.id}:I?{...k,status:"error",error:I.error}:k})),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(F=>({...F,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=M.useCallback(N=>{N.preventDefault(),c(!0)},[]),y=M.useCallback(N=>{N.preventDefault(),c(!1)},[]),b=M.useCallback(N=>{N.preventDefault(),c(!1);const F=Array.from(N.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));F.length>0&&s(k=>[...k,...F.map(R=>({file:R,status:"pending"}))])},[]),E=M.useCallback(N=>{const F=Array.from(N.target.files||[]).filter(k=>k.name.endsWith(".3mf"));F.length>0&&s(k=>[...k,...F.map(R=>({file:R,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=M.useCallback(N=>{s(F=>F.filter((k,R)=>R!==N))},[]),T=()=>{if(a.length===0)return;const N=a.filter(F=>F.status==="pending");N.length!==0&&(s(F=>F.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),x.mutate(N.map(F=>F.file)))},A=a.filter(N=>N.status==="pending").length,C=x.isPending;return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(wt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:o.jsxs(Et,{className:"p-0 flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"p-4",children:o.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:v,onDragLeave:y,onDrop:b,children:[o.jsx(oa,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),o.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),o.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),o.jsx(ke,{variant:"secondary",onClick:()=>i.current?.click(),disabled:C,children:"Browse Files"}),o.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),o.jsxs("div",{className:"px-4 pb-4",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),o.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:C,children:[o.jsx("option",{value:"",children:"No printer"}),p?.map(N=>o.jsx("option",{value:N.id,children:N.name},N.id))]})]}),a.length>0&&o.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:o.jsx("div",{className:"space-y-2",children:a.map((N,F)=>o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[o.jsx(uR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),o.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),o.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&o.jsx("button",{onClick:()=>w(F),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:C,children:o.jsx(Gt,{className:"w-4 h-4"})}),N.status==="uploading"&&o.jsx(xt,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&o.jsx(Cr,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-red-400",children:N.error}),o.jsx(mo,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${F}`))})}),f&&o.jsx("div",{className:"px-4 pb-4",children:o.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:o.jsxs("p",{className:"text-sm text-white",children:[o.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&o.jsxs(o.Fragment,{children:[", ",o.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),o.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[o.jsx(ke,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&o.jsx(ke,{onClick:T,disabled:A===0||C,className:"flex-1",children:C?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):o.jsxs(o.Fragment,{children:[o.jsx(oa,{className:"w-4 h-4"}),"Upload ",A>0&&`(${A})`]})})]})]})})})}const YUe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],ZUe=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function QUe({archive:t,onClose:e,existingTags:n=[]}){M.useEffect(()=>{const Q=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[e]);const r=mn(),[i,a]=M.useState(t.print_name||""),[s,l]=M.useState(t.printer_id),[c,u]=M.useState(t.project_id??null),[d,f]=M.useState(t.notes||""),[g,p]=M.useState(t.tags||""),[x,v]=M.useState(t.failure_reason||""),[y,b]=M.useState(t.status),[E,w]=M.useState(t.photos||[]),[T,A]=M.useState(!1),[C,N]=M.useState(!1),F=M.useRef(null),k=M.useRef(null),R=M.useRef(null),{data:I}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:L}=gt({queryKey:["projects"],queryFn:()=>Se.getProjects()}),{data:q}=gt({queryKey:["archives"],queryFn:()=>Se.getArchives(void 0,1e3,0),enabled:n.length===0}),j=n.length>0?n:[...new Set(q?.flatMap(Q=>Q.tags?.split(",").map(te=>te.trim())||[]).filter(Boolean)||[])].sort(),V=g.split(",").map(Q=>Q.trim()).filter(Boolean),K=j.filter(Q=>!V.includes(Q)),W=Q=>{if(!V.includes(Q)){const te=[...V,Q].join(", ");p(te)}R.current!==null&&clearTimeout(R.current),F.current?.focus()},J=Q=>{const te=V.filter(he=>he!==Q).join(", ");p(te)},ee=vt({mutationFn:Q=>Se.updateArchive(t.id,Q),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),Z=async Q=>{const te=Q.target.files?.[0];if(te){A(!0);try{const he=await Se.uploadArchivePhoto(t.id,te);w(he.photos),r.invalidateQueries({queryKey:["archives"]})}catch(he){console.error("Failed to upload photo:",he)}finally{A(!1),k.current&&(k.current.value="")}}},B=async Q=>{try{const te=await Se.deleteArchivePhoto(t.id,Q);w(te.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(te){console.error("Failed to delete photo:",te)}},G=Q=>{Q.preventDefault();const te={print_name:i||void 0,printer_id:s,project_id:c,notes:d||void 0,tags:g||void 0};y!==t.status&&(te.status=y),y==="failed"||y==="aborted"?te.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(te.failure_reason=null),ee.mutate(te)};return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:o.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:Q=>Q.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:G,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),o.jsx("input",{type:"text",value:i,onChange:Q=>a(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",placeholder:"Print name"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),o.jsxs("select",{value:s??"",onChange:Q=>l(Q.target.value?Number(Q.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:[o.jsx("option",{value:"",children:"No printer"}),I?.map(Q=>o.jsx("option",{value:Q.id,children:Q.name},Q.id))]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(Uo,{className:"w-4 h-4 inline mr-1"}),"Project"]}),o.jsxs("select",{value:c??"",onChange:Q=>u(Q.target.value?Number(Q.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:[o.jsx("option",{value:"",children:"No project"}),L?.map(Q=>o.jsx("option",{value:Q.id,children:Q.name},Q.id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),o.jsx("textarea",{value:d,onChange:Q=>f(Q.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..."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),V.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:V.map(Q=>o.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[o.jsx(Ap,{className:"w-3 h-3"}),Q,o.jsx("button",{type:"button",onClick:()=>J(Q),className:"ml-0.5 text-bambu-gray hover:text-white",children:o.jsx(Gt,{className:"w-3 h-3"})})]},Q))}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{ref:F,type:"text",value:g,onChange:Q=>p(Q.target.value),onFocus:()=>{R.current!==null&&clearTimeout(R.current),N(!0)},onBlur:()=>{R.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:V.length>0?"Add more tags...":"Add tags..."}),C&&K.length>0&&o.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:[o.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),o.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:K.map(Q=>o.jsx("button",{type:"button",onClick:()=>W(Q),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:Q},Q))})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),o.jsx("select",{value:y,onChange:Q=>{b(Q.target.value),Q.target.value==="completed"&&v("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ZUe.map(Q=>o.jsx("option",{value:Q.value,children:Q.label},Q.value))})]}),(y==="failed"||y==="aborted")&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),o.jsxs("select",{value:x,onChange:Q=>v(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"Select reason..."}),YUe.map(Q=>o.jsx("option",{value:Q,children:Q},Q))]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(C0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),o.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[E.map(Q=>o.jsxs("div",{className:"relative group",children:[o.jsx("img",{src:Se.getArchivePhotoUrl(t.id,Q),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),o.jsx("button",{type:"button",onClick:()=>B(Q),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(En,{className:"w-3 h-3 text-white"})})]},Q)),o.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:[o.jsx("input",{ref:k,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:Z,className:"hidden",disabled:T}),T?o.jsx(xt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):o.jsx(sr,{className:"w-6 h-6 text-bambu-gray"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:ee.isPending,className:"flex-1",children:[o.jsx(Ts,{className:"w-4 h-4"}),ee.isPending?"Saving...":"Save"]})]})]})]})})}function JUe({x:t,y:e,items:n,onClose:r}){const i=M.useRef(null),[a,s]=M.useState(null),l=M.useRef(null),[c,u]=M.useState({x:t,y:e,visible:!1}),[d,f]=M.useState(!1);M.useEffect(()=>{const x=b=>{i.current&&!i.current.contains(b.target)&&r()},v=b=>{b.key==="Escape"&&r()},y=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),document.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v),document.removeEventListener("scroll",y,!0),l.current&&clearTimeout(l.current)}},[r]),M.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),v=window.innerWidth,y=window.innerHeight,b=8;let E=t,w=e;t+x.width>v-b&&(E=Math.max(b,v-x.width-b)),E<b&&(E=b),e+x.height>y-b&&(w=Math.max(b,y-x.height-b)),w<b&&(w=b);const T=180,A=v-E-x.width,C=E;f(A<T&&C>T),u({x:E,y:w,visible:!0})}},[t,e]);const g=x=>{l.current&&(clearTimeout(l.current),l.current=null),s(x)},p=()=>{l.current=window.setTimeout(()=>{s(null)},150)};return o.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,v)=>{if(x.divider)return o.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const y=x.submenu&&x.submenu.length>0;return o.jsxs("div",{className:"relative",onMouseEnter:()=>y&&g(v),onMouseLeave:()=>y&&p(),children:[o.jsxs("button",{onMouseEnter:()=>y&&g(v),onClick:()=>{y?s(a===v?null:v):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${y&&a===v?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),o.jsx("span",{className:"flex-1",children:x.label}),y&&o.jsx(Xc,{className:"w-4 h-4 text-bambu-gray"})]}),y&&a===v&&o.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:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>p(),children:x.submenu.map((b,E)=>o.jsxs("button",{onClick:()=>{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"}`,children:[b.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),b.label]},E))})]},v)})})}function eze({selectedIds:t,existingTags:e,onClose:n}){const r=mn(),{showToast:i}=Sr(),[a,s]=M.useState(""),[l,c]=M.useState(new Set),[u,d]=M.useState("add");M.useEffect(()=>{const v=y=>{y.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=vt({mutationFn:async()=>{const v=Array.from(l);let y=0;for(const b of t)try{const E=await Se.getArchive(b),w=E.tags?E.tags.split(",").map(A=>A.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...w,...v])]:T=w.filter(A=>!l.has(A)),await Se.updateArchive(b,{tags:T.join(", ")}),y++}catch(E){throw console.error(`Failed to update archive ${b}:`,E),new Error(`Failed on archive ${b}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:y,mode:u,tags:v}},onSuccess:({count:v,mode:y,tags:b})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${y==="add"?"Added":"Removed"} ${b.length} tag${b.length!==1?"s":""} ${y==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),g=v=>{c(y=>{const b=new Set(y);return b.has(v)?b.delete(v):b.add(v),b})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),s(""))},x=v=>{v.key==="Enter"&&(v.preventDefault(),p())};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(wt,{className:"w-full max-w-md",children:o.jsxs(Et,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ap,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),o.jsx(ke,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:v=>s(v.target.value),onKeyDown:x}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:o.jsx(sr,{className:"w-4 h-4"})})]}),e.length>0&&o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(v=>o.jsx("button",{onClick:()=>g(v),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),l.size>0&&o.jsxs("div",{children:[o.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),o.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(v=>o.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[v,o.jsx("button",{onClick:()=>g(v),className:"hover:opacity-70",children:o.jsx(Gt,{className:"w-3 h-3"})})]},v))})]})]}),o.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[o.jsx(ke,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(ke,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ap,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function tze(t,e){return new Date(t,e+1,0).getDate()}function nze(t,e){return new Date(t,e,1).getDay()}const rze=["January","February","March","April","May","June","July","August","September","October","November","December"],ize=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function aze({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=M.useState(n.getMonth()),[a,s]=M.useState(n.getFullYear()),[l,c]=M.useState(null),u=M.useMemo(()=>{const b=new Map;return t.forEach(E=>{const w=new Date(E.completed_at||E.created_at),T=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,A=b.get(T)||[];A.push(E),b.set(T,A)}),b},[t]),d=tze(a,r),f=nze(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},p=()=>{r===11?(i(0),s(a+1)):i(r+1)},x=()=>{i(n.getMonth()),s(n.getFullYear())},v=[];for(let b=0;b<f;b++)v.push(null);for(let b=1;b<=d;b++)v.push(b);const y=l?u.get(l)||[]:[];return o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Yh,{className:"w-5 h-5 text-bambu-gray"})}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white",children:[rze[r]," ",a]}),o.jsx("button",{onClick:x,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"})]}),o.jsx("button",{onClick:p,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Xc,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:ize.map(b=>o.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:b},b))}),o.jsx("div",{className:"grid grid-cols-7 gap-1",children:v.map((b,E)=>{if(b===null)return o.jsx("div",{className:"aspect-square"},`empty-${E}`);const w=`${a}-${String(r+1).padStart(2,"0")}-${String(b).padStart(2,"0")}`,T=u.get(w)||[],A=T.length>0,C=b===n.getDate()&&r===n.getMonth()&&a===n.getFullYear(),N=w===l,F=T.filter(R=>R.status==="completed").length,k=T.filter(R=>R.status==="failed").length;return o.jsxs("button",{onClick:()=>c(N?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${N?"bg-bambu-green text-white":C?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":A?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[o.jsx("span",{className:`text-sm font-medium ${C&&!N?"text-bambu-green":""}`,children:b}),A&&o.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${k>0&&F===0?"bg-red-400":k>0?"bg-yellow-400":"bg-green-400"}`}),o.jsx("span",{className:"text-xs font-medium",children:T.length})]})]},b)})}),o.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a}).length}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a&&b.status==="completed"}).length}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a&&b.status==="failed"}).length}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),o.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:l?o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(l+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),y.length>0?o.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:y.map(b=>o.jsxs("button",{onClick:()=>e?.(b),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[b.thumbnail_path?o.jsx("img",{src:Se.getArchiveThumbnail(b.id),alt:"",className:"w-12 h-12 rounded object-cover"}):o.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:o.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-white truncate",children:b.print_name||b.filename}),o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("span",{className:b.status==="failed"?"text-red-400":"text-green-400",children:b.status==="failed"?"Failed":"Completed"}),b.filament_color&&o.jsx("div",{className:"flex gap-0.5",children:b.filament_color.split(",").map((E,w)=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},w))})]})]})]},b.id))}):o.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):o.jsx("div",{className:"text-center py-8",children:o.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function sze({archiveId:t,archiveName:e,onClose:n}){const r=Se.getArchiveQRCodeUrl(t,300);M.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 o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"p-6 flex flex-col items-center",children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),o.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:o.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),o.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),o.jsxs(ke,{onClick:i,className:"w-full",children:[o.jsx(is,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function oze({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,s]=M.useState(0),[l,c]=M.useState(!1);if(M.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&s(v=>Math.max(0,v-1)),x.key==="ArrowRight"&&s(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),M.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=Se.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},g=()=>{i&&c(!0)};return o.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[o.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:f,children:[o.jsx(is,{className:"w-4 h-4"}),"Download"]}),i&&o.jsx(ke,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:o.jsx(En,{className:"w-4 h-4"})}),o.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-6 h-6"})})]})]}),o.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&o.jsx("button",{onClick:()=>s(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:o.jsx(Yh,{className:"w-8 h-8 text-white"})}),o.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&&o.jsx("button",{onClick:()=>s(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:o.jsx(Xc,{className:"w-8 h-8 text-white"})})]}),n.length>1&&o.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>o.jsx("button",{onClick:()=>s(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:o.jsx("img",{src:Se.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&o.jsx(kr,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function ta(t){this.content=t}ta.prototype={constructor:ta,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 ta(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 ta(n)},addToStart:function(t,e){return new ta([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ta(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 ta(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=ta.from(t),t.size?new ta(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ta.from(t),t.size?new ta(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ta.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}};ta.from=function(t){if(t instanceof ta)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ta(e)};function PQ(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=PQ(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function jQ(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),l=e.child(--a),c=s.nodeSize;if(s==l){n-=c,r-=c;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,d=Math.min(s.text.length,l.text.length);for(;u<d&&s.text[s.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let u=jQ(s.content,l.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,l=0;l<n;s++){let c=this.content[s],u=l+c.nodeSize;if(u>e&&r(c,i+l,a||null,s)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(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 l=this.content[a],c=s+l.nodeSize;c>e&&((s<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.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 PQ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return jQ(this,e,n,r)}findIndex(e){if(e==0)return G_(0,e);if(e==this.size)return G_(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?G_(n+1,a):G_(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 XC={index:0,offset:0};function G_(t,e){return XC.index=t,XC.offset=e,XC}function Jw(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(!Jw(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Jw(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let or=class lj{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&&Jw(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 lj.none;if(e instanceof lj)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};or.none=[];class eS extends Error{}class Pt{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=DQ(this.content,e+this.openStart,n);return r&&new Pt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Pt(RQ(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 Pt.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 Pt(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 Pt(e,r,i)}}Pt.empty=new Pt(pt.empty,0,0);function RQ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(i==e||a.isText){if(l!=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(RQ(a.content,e-i-1,n-i-1)))}function DQ(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 l=DQ(s.content,e-a-1,n,s);return l&&t.replaceChild(i,s.copy(l))}function lze(t,e,n){if(n.openStart>t.depth)throw new eS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new eS("Inconsistent open depths");return OQ(t,e,n,0)}function OQ(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=OQ(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,l=s.content;return $h(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=cze(n,t);return $h(a,IQ(t,s,l,e,r))}else return $h(a,tS(t,e,r))}function LQ(t,e){if(!e.type.compatibleContent(t.type))throw new eS("Cannot join "+e.type.name+" onto "+t.type.name)}function cj(t,e,n){let r=t.node(n);return LQ(r,e.node(n)),r}function Hh(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 u0(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&&(Hh(t.nodeAfter,r),a++));for(let l=a;l<s;l++)Hh(i.child(l),r);e&&e.depth==n&&e.textOffset&&Hh(e.nodeBefore,r)}function $h(t,e){return t.type.checkContent(e),t.copy(e)}function IQ(t,e,n,r,i){let a=t.depth>i&&cj(t,e,i+1),s=r.depth>i&&cj(n,r,i+1),l=[];return u0(null,t,i,l),a&&s&&e.index(i)==n.index(i)?(LQ(a,s),Hh($h(a,IQ(t,e,n,r,i+1)),l)):(a&&Hh($h(a,tS(t,e,i+1)),l),u0(e,n,i,l),s&&Hh($h(s,tS(n,r,i+1)),l)),u0(r,null,i,l),new pt(l)}function tS(t,e,n){let r=[];if(u0(null,t,n,r),t.depth>n){let i=cj(t,e,n+1);Hh($h(i,tS(t,e,n+1)),r)}return u0(e,null,n,r),new pt(r)}function cze(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 sb{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 or.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let a=r.marks;for(var 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 nS(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:l,offset:c}=s.content.findIndex(a),u=a-c;if(r.push(s,l,i+c),!u||(s=s.child(l),s.isText))break;a=u-1,i+=c+1}return new sb(n,r,a)}static resolveCached(e,n){let r=l7.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 l7.set(e,r=new uze);let i=r.elts[r.i]=sb.resolve(e,n);return r.i=(r.i+1)%dze,i}}class uze{constructor(){this.elts=[],this.i=0}}const dze=12,l7=new WeakMap;class nS{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const hze=Object.create(null);let ud=class uj{constructor(e,n,r,i=or.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&&Jw(this.attrs,n||e.defaultAttrs||hze)&&or.sameSet(this.marks,r||or.none)}copy(e=null){return e==this.content?this:new uj(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new uj(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 Pt.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),l=i.start(s),u=i.node(s).content.cut(i.pos-l,a.pos-l);return new Pt(u,i.depth-s,a.depth-s)}replace(e,n,r){return lze(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 sb.resolveCached(this,e)}resolveNoCache(e){return sb.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()+")"),FQ(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),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),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=or.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(!or.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}};ud.prototype.text=void 0;class rS extends ud{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):FQ(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 rS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new rS(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 FQ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class pf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new fze(e,n);if(r.next==null)return pf.empty;let i=UQ(r);r.next&&r.err("Unexpected trailing text");let a=vze(yze(i));return _ze(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,l){let c=s.matchFragment(e,r);if(c&&(!n||c.validEnd))return pt.from(l.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,l.concat(d));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:l,next:c}=a.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
- `)}}pf.empty=new pf(!0);class fze{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 UQ(t){let e=[];do e.push(mze(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function mze(t){let e=[];do e.push(pze(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function pze(t){let e=bze(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=gze(t,e);else break;return e}function c7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function gze(t,e){let n=c7(t),r=n;return t.eat(",")&&(t.next!="}"?r=c7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function xze(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 bze(t){if(t.eat("(")){let e=UQ(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=xze(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 yze(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,c){let u={term:c,to:l};return e[s].push(u),u}function i(s,l){s.forEach(c=>c.to=l)}function a(s,l){if(s.type=="choice")return s.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(s.type=="seq")for(let c=0;;c++){let u=a(s.exprs[c],l);if(c==s.exprs.length-1)return u;i(u,l=n())}else if(s.type=="star"){let c=n();return r(l,c),i(a(s.expr,c),c),[r(c)]}else if(s.type=="plus"){let c=n();return i(a(s.expr,l),c),i(a(s.expr,c),c),[r(c)]}else{if(s.type=="opt")return[r(l)].concat(a(s.expr,l));if(s.type=="range"){let c=l;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(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function zQ(t,e){return e-t}function u7(t,e){let n=[];return r(e),n.sort(zQ);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:l,to:c}=a[s];!l&&n.indexOf(c)==-1&&r(c)}}}function vze(t){let e=Object.create(null);return n(u7(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<i.length;d++)i[d][0]==l&&(u=i[d][1]);u7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new pf(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(zQ);a.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return a}}function _ze(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];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 BQ(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 HQ(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 $Q(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 Sze(t,r,e[r]);return n}let d7=class GQ{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=BQ(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==pf.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:HQ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ud(this,this.computeAttrs(e),pt.from(n),or.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new ud(this,this.computeAttrs(e),n,or.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 ud(this,e,n.append(a),or.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){$Q(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:or.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new GQ(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 wze(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 Sze{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?wze(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class sE{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=BQ(this.attrs);this.instance=a?new or(this,a):null}create(e=null){return!e&&this.instance?this.instance:new or(this,HQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new sE(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){$Q(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=ta.from(e.nodes),n.marks=ta.from(e.marks||{}),this.nodes=d7.compile(this.spec.nodes,this),this.marks=sE.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||"",l=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=pf.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=l=="_"?null:l?h7(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:h7(this,s.split(" "))}this.nodeFromJSON=i=>ud.fromJSON(this,i),this.markFromJSON=i=>or.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 d7){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 rS(r,r.defaultAttrs,e,or.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 h7(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 l in t.marks){let c=t.marks[l];(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 Mze(t){return t.tag!=null}function Eze(t){return t.style!=null}let d0=class dj{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Mze(i))this.tags.push(i);else if(Eze(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 m7(this,n,!1);return r.addAll(e,or.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new m7(this,n,!0);return r.addAll(e,or.none,n.from,n.to),Pt.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(Nze(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],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.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 l=n[s];if((l.priority==null?50:l.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=p7(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=p7(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new dj(e,dj.schemaRules(e)))}};const qQ={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},Tze={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},KQ={ol:!0,ul:!0},ob=1,hj=2,h0=4;function f7(t,e,n){return e!=null?(e?ob:0)|(e==="full"?hj:0):t&&t.whitespace=="pre"?ob|hj:n&~h0}class W_{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=or.none,this.match=a||(s&h0?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&ob)){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&&!qQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class m7{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=f7(null,n.preserveWhitespace,0)|(r?h0:0);i?a=new W_(i.type,i.attrs,or.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new W_(null,null,or.none,!0,null,s):a=new W_(e.schema.topNodeType,null,or.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&hj?"full":this.localPreserveWS||(i.options&ob)>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,`
- `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(s.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(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(),l;KQ.hasOwnProperty(s)&&this.parser.normalizeLists&&Aze(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:Tze.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(qQ.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?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],s=r.getPropertyValue(a);if(s)for(let l=void 0;;){let c=this.parser.matchStyle(a,s,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,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 l=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(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;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,l=0;s>=0;s--){let c=this.nodes[s],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let 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=or.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):g7(l.type,e.type))&&(s=l.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 l=f7(e,a,s.options);s.options&h0&&s.content.length==0&&(l|=h0);let c=or.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):g7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new W_(e,n,c,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ob)}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=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=a;c--)if(s(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return 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 Aze(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&KQ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Nze(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function p7(t){let e={};for(let n in t)e[n]=t[n];return e}function g7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class Ef{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=YC(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let l=0,c=0;for(;l<a.length&&c<s.marks.length;){let u=s.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<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}=T1(YC(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&&T1(YC(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return T1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ef(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=x7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return x7(e.marks)}}function x7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function YC(t){return t.document||window.document}const b7=new WeakMap;function Cze(t){let e=b7.get(t);return e===void 0&&b7.set(t,e=kze(t)),e}function kze(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 T1(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=Cze(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 l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:x}=T1(t,g,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const XQ=65535,YQ=Math.pow(2,16);function Pze(t,e){return t+e*YQ}function y7(t){return t&XQ}function jze(t){return(t-(t&XQ))/YQ}const ZQ=1,QQ=2,A1=4,JQ=8;class fj{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&JQ)>0}get deletedBefore(){return(this.delInfo&(ZQ|A1))>0}get deletedAfter(){return(this.delInfo&(QQ|A1))>0}get deletedAcross(){return(this.delInfo&A1)>0}}class Ms{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ms.empty)return Ms.empty}recover(e){let n=0,r=y7(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+jze(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 l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+a],d=this.ranges[l+s],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,p=c+i+(g<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:Pze(l/3,e-c),v=e==c?QQ:e==f?ZQ:A1;return(n<0?e!=c:e!=f)&&(v|=JQ),new fj(p,v,x)}i+=d-u}return r?e+i:new fj(e+i,0,null)}touches(e,n){let r=0,i=y7(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+a],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+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],l=s-(this.inverted?a:0),c=s+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=d-u}}invert(){return new Ms(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ms.empty:new Ms(e<0?[0,-e,0]:[0,0,e])}}Ms.empty=new Ms([]);class lb{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 lb(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 lb;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],l=s.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new fj(e,i,null)}}const ZC=Object.create(null);class Ma{getMap(){return Ms.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ZC[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 ZC)throw new RangeError("Duplicate use of step JSON ID "+e);return ZC[e]=n,n.prototype.jsonID=e,n}}class ui{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ui(e,null)}static fail(e){return new ui(null,e)}static fromReplace(e,n,r,i){try{return ui.ok(e.replace(n,r,i))}catch(a){if(a instanceof eS)return ui.fail(a.message);throw a}}}function KO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(KO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return pt.fromArray(r)}class td extends Ma{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 Pt(KO(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return ui.fromReplace(e,this.from,this.to,a)}invert(){return new Fo(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 td(n.pos,r.pos,this.mark)}merge(e){return e instanceof td&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new td(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 td(n.from,n.to,e.markFromJSON(n.mark))}}Ma.jsonID("addMark",td);class Fo extends Ma{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 Pt(KO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ui.fromReplace(e,this.from,this.to,r)}invert(){return new td(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 Fo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Fo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fo(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 Fo(n.from,n.to,e.markFromJSON(n.mark))}}Ma.jsonID("removeMark",Fo);class nd extends Ma{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ui.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ui.fromReplace(e,this.pos,this.pos+1,new Pt(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 nd(this.pos,n.marks[i]);return new nd(this.pos,this.mark)}}return new gf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new nd(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 nd(n.pos,e.markFromJSON(n.mark))}}Ma.jsonID("addNodeMark",nd);class gf extends Ma{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ui.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ui.fromReplace(e,this.pos,this.pos+1,new Pt(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 nd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new gf(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 gf(n.pos,e.markFromJSON(n.mark))}}Ma.jsonID("removeNodeMark",gf);class zi extends Ma{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&mj(e,this.from,this.to)?ui.fail("Structure replace would overwrite content"):ui.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ms([this.from,this.to-this.from,this.slice.size])}invert(e){return new zi(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 zi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof zi)||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?Pt.empty:new Pt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new zi(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?Pt.empty:new Pt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new zi(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 zi(n.from,n.to,Pt.fromJSON(e,n.slice),!!n.structure)}}Ma.jsonID("replace",zi);class Hi extends Ma{constructor(e,n,r,i,a,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=l}apply(e){if(this.structure&&(mj(e,this.from,this.gapFrom)||mj(e,this.gapTo,this.to)))return ui.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ui.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ui.fromReplace(e,this.from,this.to,r):ui.fail("Content does not fit in gap")}getMap(){return new Ms([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 Hi(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 Hi(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 Hi(n.from,n.to,n.gapFrom,n.gapTo,Pt.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ma.jsonID("replaceAround",Hi);function mj(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 Rze(t,e,n,r){let i=[],a=[],s,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(x)||(s&&s.to==g&&s.mark.eq(f[v])?s.to=p:i.push(s=new Fo(g,p,f[v])));l&&l.to==g?l.to=p:a.push(l=new td(g,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function Dze(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;a++;let c=null;if(r instanceof sE){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(l+s.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],g;for(let p=0;p<i.length;p++){let x=i[p];x.step==a-1&&f.eq(i[p].style)&&(g=x)}g?(g.to=u,g.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(s=>t.step(new Fo(s.from,s.to,s.style)))}function XO(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)s.push(new zi(l,d,Pt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Fo(l,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,p=/\r?\n|\r/g,x;for(;g=p.exec(u.text);)x||(x=new Pt(pt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new zi(l+g.index,l+g.index+g[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(pt.empty,!0);t.replace(l,l,new Pt(c,0,0))}for(let c=s.length-1;c>=0;c--)t.step(s[c])}function Oze(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function wg(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),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(l,c,n))return r;if(r==0||s.type.spec.isolating||!Oze(s,l,c))break;l&&(i=1),c<s.childCount&&(a=1)}return null}function Lze(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),l=i.after(a+1),c=s,u=l,d=pt.empty,f=0;for(let x=a,v=!1;x>n;x--)v||r.index(x)>0?(v=!0,d=pt.from(r.node(x).copy(d)),f++):c--;let g=pt.empty,p=0;for(let x=a,v=!1;x>n;x--)v||i.after(x+1)<i.end(x)?(v=!0,g=pt.from(i.node(x).copy(g)),p++):u++;t.step(new Hi(c,u,s,l,new Pt(d.append(g),f,p),d.size-f,!0))}function YO(t,e,n=null,r=t){let i=Ize(t,e),a=i&&Fze(r,e);return a?i.map(v7).concat({type:e,attrs:n}).concat(a.map(v7)):null}function v7(t){return{type:t,attrs:null}}function Ize(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 Fze(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 Uze(t,e,n){let r=pt.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=pt.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Hi(i,a,i,a,new Pt(r,0,0),n.length,!0))}function zze(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,l)=>{let c=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,c)&&Bze(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&tJ(t,s,l,a),XO(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),g=d.map(l+s.nodeSize,1);return t.step(new Hi(f,g,f+1,g-1,new Pt(pt.from(r.create(c,null,s.marks)),0,0),1,!0)),u===!0&&eJ(t,s,l,a),!1}})}function eJ(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.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 tJ(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(`
- `))}})}function Bze(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Hze(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 Hi(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Pt(pt.from(s),0,0),1,!0))}function Oc(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 p=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let v=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!v.type.validContent(p))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function $ze(t,e,n=1,r){let i=t.doc.resolve(e),a=pt.empty,s=pt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=pt.from(i.node(l).copy(a));let d=r&&r[u];s=pt.from(d?d.type.create(d.attrs,s):i.node(l).copy(s))}t.step(new zi(e,e,new Pt(a.append(s),n,n),!0))}function Rd(t,e){let n=t.resolve(e),r=n.index();return nJ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Vze(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 nJ(t,e){return!!(t&&e&&!t.isLeaf&&Vze(t,e))}function oE(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,s,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,s=r.nodeAfter):n>0?(a=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),s=r.node(i+1)),a&&!a.isTextblock&&nJ(a,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function Gze(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 l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);tJ(t,d.node(),d.before(),l)}s.inlineContent&&XO(t,e+n-1,s,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new zi(u,c.map(e+n,-1),Pt.empty,!0)),r===!0){let d=t.doc.resolve(u);eJ(t,d.node(),d.before(),t.steps.length)}return t}function Wze(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 rJ(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 l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(l>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 l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function lE(t,e,n=e,r=Pt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return iJ(i,a,r)?new zi(e,n,r):new qze(i,a,r).fit()}function iJ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class qze{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,l=i.depth;for(;s&&l&&a.childCount==1;)a=a.firstChild.content,s--,l--;let c=new Pt(a,s,l);return e>-1?new Hi(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new zi(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=QC(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],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:l,parent:a,inject:f};if(n==2&&s&&(d=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=QC(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Pt(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=QC(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Pt(Zx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Pt(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 v=0;v<a.length;v++)this.openFrontierNode(a[v]);let s=this.unplaced,l=r?r.content:s.content,c=s.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let p=l.size+e-(s.content.size-s.openEnd);for(;u<l.childCount;){let v=l.child(u),y=f.matchType(v.type);if(!y)break;u++,(u>1||c==0||v.content.size)&&(f=y,d.push(aJ(v.mark(g.allowedMarks(v.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=Qx(this.placed,n,pt.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,y=l;v<p;v++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=x?e==0?Pt.empty:new Pt(Zx(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Pt(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||!JC(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=JC(e,n,i,r,a);if(s){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=JC(e,l,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=Qx(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=Qx(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=Qx(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 Qx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Qx(t.lastChild.content,e-1,n)))}function QC(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function aJ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,aJ(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 JC(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 l=r.fillBefore(a.content,!0,s);return l&&!Kze(n,a.content,s)?l:null}function Kze(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 Yze(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(iJ(i,a,r))return t.step(new zi(e,n,r));let s=oJ(i,a);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let g=i.depth,p=i.pos-1;g>0;g--,p--){let x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;s.indexOf(g)>-1?l=g:i.before(g)==p&&s.splice(1,0,-g)}let c=s.indexOf(l),u=[],d=r.openStart;for(let g=r.content,p=0;;p++){let x=g.firstChild;if(u.push(x),p==r.openStart)break;g=x.content}for(let g=d-1;g>=0;g--){let p=u[g],x=Xze(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(x||!p.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let p=(g+d+1)%(r.openStart+1),x=u[p];if(x)for(let v=0;v<s.length;v++){let y=s[(v+c)%s.length],b=!0;y<0&&(b=!1,y=-y);let E=i.node(y-1),w=i.index(y-1);if(E.canReplaceWith(w,w,x.type,x.marks))return t.replace(i.before(y),b?a.after(y):n,new Pt(sJ(r.content,0,r.openStart,p),p,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 p=s[g];p<0||(e=i.before(p),n=a.after(p))}}function sJ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(sJ(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 Zze(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Wze(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Pt(pt.from(r),0,0))}function Qze(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=oJ(r,i);for(let s=0;s<a.length;s++){let l=a[s],c=s==a.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let 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 oJ(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 xp extends Ma{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 ui.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 ui.fromReplace(e,this.pos,this.pos+1,new Pt(pt.from(i),0,n.isLeaf?0:1))}getMap(){return Ms.empty}invert(e){return new xp(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 xp(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 xp(n.pos,n.attr,n.value)}}Ma.jsonID("attr",xp);class cb extends Ma{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 ui.ok(r)}getMap(){return Ms.empty}invert(e){return new cb(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 cb(n.attr,n.value)}}Ma.jsonID("docAttr",cb);let Gp=class extends Error{};Gp=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Gp.prototype=Object.create(Error.prototype);Gp.prototype.constructor=Gp;Gp.prototype.name="TransformError";class lJ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new lb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Gp(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=Pt.empty){let i=lE(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Pt(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,Pt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Yze(this,e,n,r),this}replaceRangeWith(e,n,r){return Zze(this,e,n,r),this}deleteRange(e,n){return Qze(this,e,n),this}lift(e,n){return Lze(this,e,n),this}join(e,n=1){return Gze(this,e,n),this}wrap(e,n){return Uze(this,e,n),this}setBlockType(e,n=e,r,i=null){return zze(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Hze(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new xp(e,n,r)),this}setDocAttribute(e,n){return this.step(new cb(e,n)),this}addNodeMark(e,n){return this.step(new nd(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 or)n.isInSet(r.marks)&&this.step(new gf(e,n));else{let i=r.marks,a,s=[];for(;a=n.isInSet(i);)s.push(new gf(e,a)),i=a.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return $ze(this,e,n,r),this}addMark(e,n,r){return Rze(this,e,n,r),this}removeMark(e,n,r){return Dze(this,e,n,r),this}clearIncompatible(e,n,r){return XO(this,e,n,r),this}}const ek=Object.create(null);class hn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Jze(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=Pt.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:c,$to:u}=s[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Pt.empty:n),l==0&&S7(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:l}=i[a],c=e.mapping.slice(r),u=c.map(s.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),S7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Xt(e):Ym(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?Ym(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Ym(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 Ps(e.node(0))}static atStart(e){return Ym(e,e,0,0,1)||new Ps(e)}static atEnd(e){return Ym(e,e,e.content.size,e.childCount,-1)||new Ps(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ek[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 ek)throw new RangeError("Duplicate use of selection JSON ID "+e);return ek[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Xt.between(this.$anchor,this.$head).getBookmark()}}hn.prototype.visible=!0;class Jze{constructor(e,n){this.$from=e,this.$to=n}}let _7=!1;function w7(t){!_7&&!t.parent.inlineContent&&(_7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Xt extends hn{constructor(e,n=e){w7(e),w7(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 hn.near(r);let i=e.resolve(n.map(this.anchor));return new Xt(i.parent.inlineContent?i:r,r)}replace(e,n=Pt.empty){if(super.replace(e,n),n==Pt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Xt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new cE(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 Xt(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=hn.findFrom(n,r,!0)||hn.findFrom(n,-r,!0);if(a)n=a.$head;else return hn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(hn.findFrom(e,-r,!0)||hn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Xt(e,n)}}hn.jsonID("text",Xt);class cE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new cE(e.map(this.anchor),e.map(this.head))}resolve(e){return Xt.between(e.resolve(this.anchor),e.resolve(this.head))}}class $t extends hn{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?hn.near(a):new $t(a)}content(){return new Pt(pt.from(this.node),0,0)}eq(e){return e instanceof $t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ZO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $t(e.resolve(n.anchor))}static create(e,n){return new $t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}$t.prototype.visible=!1;hn.jsonID("node",$t);class ZO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new cE(r,r):new ZO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&$t.isSelectable(r)?new $t(n):hn.near(n)}}class Ps extends hn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Pt.empty){if(n==Pt.empty){e.delete(0,e.doc.content.size);let r=hn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ps(e)}map(e){return new Ps(e)}eq(e){return e instanceof Ps}getBookmark(){return eBe}}hn.jsonID("all",Ps);const eBe={map(){return this},resolve(t){return new Ps(t)}};function Ym(t,e,n,r,i,a=!1){if(e.inlineContent)return Xt.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!a&&$t.isSelectable(l))return $t.create(t,n-(i<0?l.nodeSize:0))}else{let c=Ym(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function S7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof zi||i instanceof Hi))return;let a=t.mapping.maps[r],s;a.forEach((l,c,u,d)=>{s==null&&(s=d)}),t.setSelection(hn.near(t.doc.resolve(s),n))}const M7=1,q_=2,E7=4;class tBe extends lJ{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|M7)&~q_,this.storedMarks=null,this}get selectionSet(){return(this.updated&M7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=q_,this}ensureMarks(e){return or.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&q_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~q_,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)||or.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(hn.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|=E7,this}get scrolledIntoView(){return(this.updated&E7)>0}}function T7(t,e){return!e||!t?t:t.bind(e)}class Jx{constructor(e,n,r){this.name=e,this.init=T7(n.init,r),this.apply=T7(n.apply,r)}}const nBe=[new Jx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Jx("selection",{init(t,e){return t.selection||hn.atStart(e.doc)},apply(t){return t.selection}}),new Jx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Jx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class tk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=nBe.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 Jx(r.key,r.spec.state,r))})}}class sp{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 l=this.config.plugins[s];if(l.spec.appendTransaction){let c=i?i[s].n:0,u=i?i[s].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,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 sp(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 tBe(this)}static create(e){let n=new tk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new sp(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 tk(this.schema,e.plugins),r=n.fields,i=new sp(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 tk(e.schema,e.plugins),a=new sp(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=ud.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=hn.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 l in r){let c=r[l],u=c.spec.state;if(c.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[s.name]=u.fromJSON.call(c,e,n[l],a);return}}a[s.name]=s.init(e,a)}}),a}}function cJ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=cJ(i,e,{})),n[r]=i}return n}class Or{constructor(e){this.spec=e,this.props={},e.props&&cJ(e.props,this,this.props),this.key=e.key?e.key.key:uJ("plugin")}getState(e){return e[this.key]}}const nk=Object.create(null);function uJ(t){return t in nk?t+"$"+ ++nk[t]:(nk[t]=0,t+"$")}class Ci{constructor(e="key"){this.key=uJ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const QO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function dJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const hJ=(t,e,n)=>{let r=dJ(t,n);if(!r)return!1;let i=JO(r);if(!i){let s=r.blockRange(),l=s&&wg(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(_J(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Wp(a,"end")||$t.isSelectable(a)))for(let s=r.depth;;s--){let l=lE(t.doc,r.before(s),r.after(s),Pt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Wp(a,"end")?hn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):$t.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},rBe=(t,e,n)=>{let r=dJ(t,n);if(!r)return!1;let i=JO(r);return i?fJ(t,i,e):!1},iBe=(t,e,n)=>{let r=pJ(t,n);if(!r)return!1;let i=eL(r);return i?fJ(t,i,e):!1};function fJ(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,l=s,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=lE(t.doc,a,c,Pt.empty);if(!u||u.from!=a||u instanceof zi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(Xt.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Wp(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 mJ=(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=JO(r)}let s=a&&a.nodeBefore;return!s||!$t.isSelectable(s)?!1:(e&&e(t.tr.setSelection($t.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function JO(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function pJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const gJ=(t,e,n)=>{let r=pJ(t,n);if(!r)return!1;let i=eL(r);if(!i)return!1;let a=i.nodeAfter;if(_J(t,i,e,1))return!0;if(r.parent.content.size==0&&(Wp(a,"start")||$t.isSelectable(a))){let s=lE(t.doc,r.before(),r.after(),Pt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(Wp(a,"start")?hn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):$t.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},xJ=(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=eL(r)}let s=a&&a.nodeAfter;return!s||!$t.isSelectable(s)?!1:(e&&e(t.tr.setSelection($t.create(t.doc,a.pos)).scrollIntoView()),!0)};function eL(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 aBe=(t,e)=>{let n=t.selection,r=n instanceof $t,i;if(r){if(n.node.isTextblock||!Rd(t.doc,n.from))return!1;i=n.from}else if(i=oE(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection($t.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},sBe=(t,e)=>{let n=t.selection,r;if(n instanceof $t){if(n.node.isTextblock||!Rd(t.doc,n.to))return!1;r=n.to}else if(r=oE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},oBe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&wg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},bJ=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function tL(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 lBe=(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=tL(i.contentMatchAt(a));if(!s||!i.canReplaceWith(a,a,s))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,s.createAndFill());c.setSelection(hn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},yJ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ps||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=tL(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,l=t.tr.insert(s,a.createAndFill());l.setSelection(Xt.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},vJ=(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(Oc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&wg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function cBe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof $t&&e.selection.node.isBlock)return!r.parentOffset||!Oc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],s,l,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=tL(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&l?{type:l}:null),s=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof Xt||e.selection instanceof Ps)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Oc(d.doc,f,a.length,a);if(g||(a[0]=l?{type:l}:null,g=Oc(d.doc,f,a.length,a)),!g)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(s).type!=l){let p=d.mapping.map(r.before(s)),x=d.doc.resolve(p);l&&r.node(s-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return n&&n(d.scrollIntoView()),!0}}const uBe=cBe(),dBe=(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($t.create(t.doc,i))),!0)};function hBe(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||Rd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function _J(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&hBe(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&l.matchType(s[0]||a.type).validEnd){if(n){let p=e.pos+a.nodeSize,x=pt.empty;for(let b=s.length-1;b>=0;b--)x=pt.from(s[b].create(null,x));x=pt.from(i.copy(x));let v=t.tr.step(new Hi(e.pos-1,p,e.pos,p,new Pt(x,1,0),s.length,!0)),y=v.doc.resolve(p+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&Rd(v.doc,y.pos)&&v.join(y.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:hn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&wg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&Wp(a,"start",!0)&&Wp(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let v=a,y=1;for(;!v.isTextblock;v=v.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let b=pt.empty;for(let w=x.length-1;w>=0;w--)b=pt.from(x[w].copy(b));let E=t.tr.step(new Hi(e.pos-x.length,e.pos+a.nodeSize,e.pos+y,e.pos+a.nodeSize-y,new Pt(b,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function wJ(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(Xt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const fBe=wJ(-1),mBe=wJ(1);function pBe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),l=s&&YO(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function A7(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:l}}=n.selection.ranges[a];n.doc.nodesBetween(s,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[s];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function nL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}nL(QO,hJ,mJ);nL(QO,gJ,xJ);nL(bJ,yJ,vJ,uBe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function gBe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a);if(!s)return!1;let l=r?n.tr:null;return xBe(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function xBe(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 nS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new nS(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=YO(a,n,r,e);return l?(t&&bBe(t,e,l,i,n),!0):!1}function bBe(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 Hi(e.start-(r?2:0),e.end,e.start,e.end,new Pt(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 l=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&&Oc(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function yBe(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?vBe(e,n,t,a):_Be(e,n,a):!0:!1}}function vBe(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new Hi(a-1,s,a,s,new Pt(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new nS(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const l=wg(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return Rd(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function _Be(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,v=n.startIndex;x>v;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let a=r.doc.resolve(n.start),s=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,s.content.append(c?pt.empty:pt.from(i))))return!1;let f=a.pos,g=f+s.nodeSize;return r.step(new Hi(f-(l?1:0),g+(c?1:0),f+1,g-1,new Pt((l?pt.empty:pt.from(i.copy(pt.empty))).append(c?pt.empty:pt.from(i.copy(pt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function wBe(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 l=a.parent,c=l.child(s-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=pt.from(u?t.create():null),f=new Pt(pt.from(t.create(null,pt.from(l.type.create(null,d)))),u?3:1,0),g=a.start,p=a.end;n(e.tr.step(new Hi(g-(u?3:1),p,g,p,f,1,!0)).scrollIntoView())}return!0}}const aa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},qp=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let pj=null;const gc=function(t,e,n){let r=pj||(pj=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},SBe=function(){pj=null},xf=function(t,e,n,r){return n&&(N7(t,e,n,r,-1)||N7(t,e,n,r,1))},MBe=/^(img|br|input|textarea|hr)$/i;function N7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:io(t))){let s=t.parentNode;if(!s||s.nodeType!=1||sy(t)||MBe.test(t.nodeName)||t.contentEditable=="false")return!1;e=aa(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?io(t):0}else return!1}}function io(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function EBe(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=io(t)}else if(t.parentNode&&!sy(t))e=aa(t),t=t.parentNode;else return null}}function TBe(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&&!sy(t))e=aa(t)+1,t=t.parentNode;else return null}}function ABe(t,e,n){for(let r=e==0,i=e==io(t);r||i;){if(t==n)return!0;let a=aa(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==io(t)}}function sy(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 uE=function(t){return t.focusNode&&xf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function wh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function NBe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function CBe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(io(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(io(r.startContainer),r.startOffset)}}}const El=typeof navigator<"u"?navigator:null,C7=typeof document<"u"?document:null,Dd=El&&El.userAgent||"",gj=/Edge\/(\d+)/.exec(Dd),SJ=/MSIE \d/.exec(Dd),xj=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dd),rs=!!(SJ||xj||gj),dd=SJ?document.documentMode:xj?+xj[1]:gj?+gj[1]:0,ho=!rs&&/gecko\/(\d+)/i.test(Dd);ho&&+(/Firefox\/(\d+)/.exec(Dd)||[0,0])[1];const bj=!rs&&/Chrome\/(\d+)/.exec(Dd),ya=!!bj,MJ=bj?+bj[1]:0,Ia=!rs&&!!El&&/Apple Computer/.test(El.vendor),Kp=Ia&&(/Mobile\/\w+/.test(Dd)||!!El&&El.maxTouchPoints>2),Qs=Kp||(El?/Mac/.test(El.platform):!1),kBe=El?/Win/.test(El.platform):!1,Nc=/Android \d/.test(Dd),oy=!!C7&&"webkitFontSmoothing"in C7.documentElement.style,PBe=oy?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jBe(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 uc(t,e){return typeof t=="number"?t:t[e]}function RBe(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 k7(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=qp(s);continue}let l=s,c=l==a.body,u=c?jBe(a):RBe(l),d=0,f=0;if(e.top<u.top+uc(r,"top")?f=-(u.top-e.top+uc(i,"top")):e.bottom>u.bottom-uc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+uc(i,"top")-u.top:e.bottom-u.bottom+uc(i,"bottom")),e.left<u.left+uc(r,"left")?d=-(u.left-e.left+uc(i,"left")):e.right>u.right-uc(r,"right")&&(d=e.right-u.right+uc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let v=l.scrollLeft-p,y=l.scrollTop-x;e={left:e.left-v,top:e.top-y,right:e.right-v,bottom:e.bottom-y}}let g=c?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:qp(s)}}function DBe(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 l=t.root.elementFromPoint(a,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:EJ(t.dom)}}function EJ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=qp(r));return e}function OBe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;TJ(n,r==0?0:r-e)}function TJ(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 $m=null;function LBe(t){if(t.setActive)return t.setActive();if($m)return t.focus($m);let e=EJ(t);t.focus($m==null?{get preventScroll(){return $m={preventScroll:!0},!0}}:void 0),$m||($m=!1,TJ(e,0))}function AJ(t,e){let n,r=2e8,i,a=0,s=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=gc(d).getClientRects();else continue;for(let p=0;p<g.length;p++){let x=g[p];if(x.top<=s&&x.bottom>=l){s=Math.max(x.bottom,s),l=Math.min(x.top,l);let v=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?IBe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:AJ(n,i)}function IBe(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=Fu(r,1);if(a.top!=a.bottom&&rL(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function rL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function FBe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function UBe(t,e,n){let{node:r,offset:i}=AJ(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 zBe(t,e,n,r){let i=-1;for(let a=e,s=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&c.left>r.left||c.top>r.top?i=l.posBefore:(!s&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function NJ(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 l=s.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(rL(e,u))return NJ(s,e,u)}}if((a=(a+1)%r)==i)break}return t}function BBe(t,e){let n=t.dom.ownerDocument,r,i=0,a=CBe(n,e.left,e.top);a&&({node:r,offset:i}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let u=t.dom.getBoundingClientRect();if(!rL(e,u)||(s=NJ(t.dom,e,u),!s))return null}if(Ia)for(let u=s;r&&u;u=qp(u))u.draggable&&(r=void 0);if(s=FBe(s,e),r){if(ho&&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;oy&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=zBe(t,r,i,e))}l==null&&(l=UBe(t,s,e));let c=t.docView.nearestDesc(s,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function P7(t){return t.top<t.bottom||t.left<t.right}function Fu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(P7(r))return r}return Array.prototype.find.call(n,P7)||t.getBoundingClientRect()}const HBe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function CJ(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=oy||ho;if(r.nodeType==3)if(s&&(HBe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Fu(gc(r,i,i),n);if(ho&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Fu(gc(r,i-1,i-1),-1);if(u.top==c.top){let d=Fu(gc(r,i,i+1),-1);if(d.top!=c.top)return zx(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++,zx(Fu(gc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==io(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return rk(c.getBoundingClientRect(),!1)}if(a==null&&i<io(r)){let c=r.childNodes[i];if(c.nodeType==1)return rk(c.getBoundingClientRect(),!0)}return rk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==io(r))){let c=r.childNodes[i-1],u=c.nodeType==3?gc(c,io(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return zx(Fu(u,1),!1)}if(a==null&&i<io(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?gc(c,0,s?0:1):c.nodeType==1?c:null:null;if(u)return zx(Fu(u,-1),!0)}return zx(Fu(r.nodeType==3?gc(r):r,-n),n>=0)}function zx(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 rk(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 kJ(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 $Be(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return kJ(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let s=CJ(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=gc(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const VBe=/[\u0590-\u08ac]/;function GBe(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,l=t.domSelection();return l?!VBe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:s:kJ(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:v}=t.domSelectionRange(),y=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==v;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return g!=null&&(l.caretBidiLevel=g),y}):r.pos==r.start()||r.pos==r.end()}let j7=null,R7=null,D7=!1;function WBe(t,e,n){return j7==e&&R7==n?D7:(j7=e,R7=n,D7=n=="up"||n=="down"?$Be(t,e,n):GBe(t,e,n))}const fo=0,O7=1,Nh=2,Tl=3;class ly{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=fo,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>aa(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 l=i.children[s];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let s=this.children[r],l=a+s.size;if(l>e||s instanceof jJ){i=e-a;break}a=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof PJ&&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?aa(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?aa(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,l=0;;l++){let c=this.children[l],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=l;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=aa(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=aa(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 p=0,x=0;p<this.children.length;p++){let v=this.children[p],y=x+v.size;if(a>x&&s<y)return v.setSelection(e-x-v.border,n-x-v.border,r,i);x=y}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((ho||Ia)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
- `),f&&x==p.nodeValue.length)for(let v=p,y;v;v=v.parentNode){if(y=v.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:aa(y)+1});break}let b=v.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let v=p.childNodes[x-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(ho&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ia)&&xf(l.node,l.offset,d.anchorNode,d.anchorOffset)&&xf(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&ho)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],s=r+a.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+a.border,c=s-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==s?Nh:O7,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Tl:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Nh:Tl}r=s}this.dirty=Nh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Nh:O7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class PJ extends ly{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 l=document.createElement("span");l.appendChild(s),s=l}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==fo&&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 qBe extends ly{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 bf extends ly{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=Ef.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new bf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Tl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Tl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=fo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=fo}}slice(e,n,r){let i=bf.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=vj(a,n,s,r)),e>0&&(a=vj(a,0,e,r));for(let l=0;l<a.length;l++)a[l].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class hd extends ly{constructor(e,n,r,i,a,s,l,c,u){super(e,[],a,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,s){let l=a.nodeViews[n.type.name],c,u=l&&l(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}=Ef.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=OJ(d,r,n),u?c=new KBe(e,n,r,i,d,f||null,g,u,a,s+1):n.isText?new dE(e,n,r,i,d,g,a):new hd(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==fo&&e.eq(this.node)&&iS(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,l=a&&a.pos<0,c=new YBe(this,s&&s.node,e);JBe(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?or.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,g)=>{c.syncToMarks(u.marks,r,e);let p;c.findNodeMatch(u,d,f,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,g,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Nh)&&(s&&this.protectLocalComposition(e,s),RJ(this.contentDOM,this.children,e),Kp&&e8e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Xt)||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,l=t8e(this.node.content,s,r-n,i-n);return l<0?null:{node:a,pos:l,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 qBe(this,a,n,i);e.input.compositionNodes.push(s),this.children=vj(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Tl||!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=fo}updateOuterDeco(e){if(iS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=DJ(this.dom,this.nodeDOM,yj(this.outerDeco,this.node,n),yj(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 L7(t,e,n,r,i){OJ(r,e,t);let a=new hd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class dE extends hd{constructor(e,n,r,i,a,s,l){super(e,n,r,i,a,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Tl||this.dirty!=fo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=fo||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=fo,!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 dE(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=Tl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class jJ extends ly{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==fo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class KBe extends hd{constructor(e,n,r,i,a,s,l,c,u,d){super(e,n,r,i,a,s,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==Tl)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 RJ(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let s=e[a],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=I7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof bf){let c=r?r.previousSibling:t.lastChild;RJ(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=I7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const f0=function(t){t&&(this.nodeName=t)};f0.prototype=Object.create(null);const Ch=[new f0];function yj(t,e,n){if(t.length==0)return Ch;let r=n?Ch[0]:new f0,i=[r];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&i.push(r=new f0(s.nodeName));for(let l in s){let c=s[l];c!=null&&(n&&i.length==1&&i.push(r=new f0(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function DJ(t,e,n,r){if(n==Ch&&r==Ch)return e;let i=e;for(let a=0;a<r.length;a++){let s=r[a],l=n[a];if(a){let c;l&&l.nodeName==s.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||(c=document.createElement(s.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Ch[0]),i=c}XBe(i,l||Ch[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 OJ(t,e,n){return DJ(t,t,Ch,yj(e,n,t.nodeType!=1))}function iS(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 I7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class YBe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ZBe(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=fo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=bf.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 l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let s=this.top.children[i];return s.dirty==Tl&&s.dom==s.contentDOM&&(s.dirty=Nh),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 l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof hd){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!=Tl&&iS(n,c.outerDeco));if(!g&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(c,e,n,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Nh,f.updateChildren(i,s+1),f.dirty=fo),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)||!iS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=hd.create(this.top,n,r,i,a,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,a){let s=hd.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 PJ(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 bf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof dE)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ia||ya)&&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 jJ(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 ZBe(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof bf)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,a.set(l,i),s.push(l)}}return{index:i,matched:a,matches:s.reverse()}}function QBe(t,e){return t.type.side-e.type.side}function JBe(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,l=[],c=null;for(let u=0;;){let d,f;for(;s<i.length&&i[s].to==a;){let y=i[s++];y.widget&&(d?(f||(f=[d])).push(y):d=y)}if(d)if(f){f.sort(QBe);for(let y=0;y<f.length;y++)n(f[y],u,!!c)}else n(d,u,!!c);let g,p;if(c)p=-1,g=c,c=null;else if(u<t.childCount)p=u,g=t.child(u++);else break;for(let y=0;y<l.length;y++)l[y].to<=a&&l.splice(y--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)l.push(i[s++]);let x=a+g.nodeSize;if(g.isText){let y=x;s<i.length&&i[s].from<y&&(y=i[s].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<x&&(c=g.cut(y-a),g=g.cut(0,y-a),x=y,p=-1)}else for(;s<i.length&&i[s].to<x;)s++;let v=g.isInline&&!g.isLeaf?l.filter(y=>!y.inline):l.slice();r(g,v,e.forChild(a,g),p),a=x}}function e8e(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 t8e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let s=t.child(i++),l=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-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function vj(t,e,n,r,i){let a=[];for(let s=0,l=0;s<t.length;s++){let c=t[s],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function iL(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 l=r.resolve(s),c,u;if(uE(n)){for(c=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&$t.isSelectable(f)&&i.parent&&!(f.isInline&&ABe(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new $t(s==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,g=s;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,s]=g==t.state.selection.anchor?[g,f]:[f,g],l=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<l.pos&&!a?1:-1;u=aL(t,d,l,f)}return u}function LJ(t){return t.editable?t.hasFocus():FJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Lc(t,e=!1){let n=t.state.selection;if(IJ(t,n),!!LJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ya){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&xf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)r8e(t);else{let{anchor:r,head:i}=n,a,s;F7&&!(n instanceof Xt)&&(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),F7&&(a&&z7(a),s&&z7(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&n8e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const F7=Ia||ya&&MJ<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(Ia&&i&&i.contentEditable=="false")return ik(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return ik(i);if(a)return ik(a)}}function ik(t){return t.contentEditable="true",Ia&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function z7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function n8e(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(()=>{(!LJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function r8e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,aa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&rs&&dd<=11&&(n.disabled=!0,n.disabled=!1)}function IJ(t,e){if(e instanceof $t){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(B7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else B7(t)}function B7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function aL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Xt.between(e,n,r)}function H7(t){return t.editable&&!t.hasFocus()?!1:FJ(t)}function FJ(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 i8e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return xf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function _j(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&&hn.findFrom(a,e)}function $u(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function $7(t,e,n){let r=t.state.selection;if(r instanceof Xt)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 $u(t,new Xt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=_j(t.state,e);return i&&i instanceof $t?$u(t,i):!1}else if(!(Qs&&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 l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?$t.isSelectable(a)?$u(t,new $t(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):oy?$u(t,new Xt(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $t&&r.node.isInline)return $u(t,new Xt(e>0?r.$to:r.$from));{let i=_j(t.state,e);return i?$u(t,i):!1}}}function aS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function m0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Vm(t,e){return e<0?a8e(t):s8e(t)}function a8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(ho&&n.nodeType==1&&r<aS(n)&&m0(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(m0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(UJ(n))break;{let l=n.previousSibling;for(;l&&m0(l,-1);)i=n.parentNode,a=aa(l),l=l.previousSibling;if(l)n=l,r=aS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?wj(t,n,r):i&&wj(t,i,a)}function s8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=aS(n),a,s;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(m0(l,1))a=n,s=++r;else break}else{if(UJ(n))break;{let l=n.nextSibling;for(;l&&m0(l,1);)a=l.parentNode,s=aa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=aS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&wj(t,a,s)}function UJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function o8e(t,e){for(;t&&e==t.childNodes.length&&!sy(t);)e=aa(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 l8e(t,e){for(;t&&!e&&!sy(t);)e=aa(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 wj(t,e,n){if(e.nodeType!=3){let a,s;(s=o8e(e,n))?(e=s,n=0):(a=l8e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(uE(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&&Lc(t)},50)}function V7(t,e){let n=t.state.doc.resolve(e);if(!(ya||kBe)&&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 Xt&&!r.empty||n.indexOf("s")>-1||Qs&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=_j(t.state,e);if(s&&s instanceof $t)return $u(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,l=r instanceof Ps?hn.near(s,e):hn.findFrom(s,e);return l?$u(t,l):!1}return!1}function W7(t,e){if(!(t.state.selection instanceof Xt))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 q7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function c8e(t){if(!Ia||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;q7(t,r,"true"),setTimeout(()=>q7(t,r,"false"),20)}return!1}function u8e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function d8e(t,e){let n=e.keyCode,r=u8e(e);if(n==8||Qs&&n==72&&r=="c")return W7(t,-1)||Vm(t,-1);if(n==46&&!e.shiftKey||Qs&&n==68&&r=="c")return W7(t,1)||Vm(t,1);if(n==13||n==27)return!0;if(n==37||Qs&&n==66&&r=="c"){let i=n==37?V7(t,t.state.selection.from)=="ltr"?-1:1:-1;return $7(t,i,r)||Vm(t,i)}else if(n==39||Qs&&n==70&&r=="c"){let i=n==39?V7(t,t.state.selection.from)=="ltr"?1:-1:1;return $7(t,i,r)||Vm(t,i)}else{if(n==38||Qs&&n==80&&r=="c")return G7(t,-1,r)||Vm(t,-1);if(n==40||Qs&&n==78&&r=="c")return c8e(t)||G7(t,1,r)||Vm(t,1);if(r==(Qs?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function sL(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||Ef.fromSchema(t.state.schema),l=GJ(),c=l.createElement("div");c.appendChild(s.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=VJ[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:g,slice:e}}function zJ(t,e,n,r,i){let a=i.parent.type.spec.code,s,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return l=new Pt(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",g=>{l=g(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)l=f;else{let g=i.marks(),{schema:p}=t.state,x=Ef.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let y=s.appendChild(document.createElement("p"));v&&y.appendChild(x.serializeNode(p.text(v,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=p8e(n),oy&&g8e(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(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||d0.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!h8e.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=x8e(K7(l,+d[1],+d[2]),d[4]);else if(l=Pt.maxOpen(f8e(l.content,i),!0),l.openStart||l.openEnd){let f=0,g=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;g<l.openEnd&&!p.type.spec.isolating;g++,p=p.lastChild);l=K7(l,f,g)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const h8e=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function f8e(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(l=>{if(!s)return;let c=i.findWrapping(l.type),u;if(!c)return s=null;if(u=s.length&&a.length&&HJ(c,a,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=$J(s[s.length-1],a.length));let d=BJ(l,c);s.push(d),i=i.matchType(d.type),a=c}}),s)return pt.from(s)}return t}function BJ(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function HJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=HJ(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(BJ(n,t,i+1))))}}function $J(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,$J(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function Sj(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(a=0),i<r-1&&(l=Sj(l,e,n,r,i+1,a)),i>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,a<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(pt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function K7(t,e,n){return e<t.openStart&&(t=new Pt(Sj(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Pt(Sj(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 X7=null;function GJ(){return X7||(X7=document.implementation.createHTMLDocument("title"))}let ak=null;function m8e(t){let e=window.trustedTypes;return e?(ak||(ak=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ak.createHTML(t)):t}function p8e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=GJ().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=m8e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function g8e(t){let e=t.querySelectorAll(ya?"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 x8e(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 l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=pt.from(c.create(r[l+1],i)),a++,s++}return new Pt(i,a,s)}const Fa={},Ua={},b8e={touchstart:!0,touchmove:!0};class y8e{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 v8e(t){for(let e in Fa){let n=Fa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{w8e(t,r)&&!oL(t,r)&&(t.editable||!(r.type in Ua))&&n(t,r)},b8e[e]?{passive:!0}:void 0)}Ia&&t.dom.addEventListener("input",()=>null),Mj(t)}function rd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function _8e(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 Mj(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>oL(t,r))})}function oL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function w8e(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 S8e(t,e){!oL(t,e)&&Fa[e.type]&&(t.editable||!(e.type in Ua))&&Fa[e.type](t,e)}Ua.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!qJ(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Nc&&ya&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Kp&&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,wh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||d8e(t,n)?n.preventDefault():rd(t,"key")};Ua.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ua.keypress=(t,e)=>{let n=e;if(qJ(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Qs&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Xt)||!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 hE(t){return{left:t.clientX,top:t.clientY}}function M8e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function lL(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,l=>s>a.depth?l(t,n,a.nodeAfter,a.before(s),i,!0):l(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function bp(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 E8e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&$t.isSelectable(r)?(bp(t,new $t(n)),!0):!1}function T8e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof $t&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let l=s>a.depth?a.nodeAfter:a.node(s);if($t.isSelectable(l)){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?(bp(t,$t.create(t.state.doc,i)),!0):!1}function A8e(t,e,n,r,i){return lL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?T8e(t,n):E8e(t,n))}function N8e(t,e,n,r){return lL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function C8e(t,e,n,r){return lL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||k8e(t,n,r)}function k8e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(bp(t,Xt.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),l=i.before(a);if(s.inlineContent)bp(t,Xt.create(r,l+1,l+1+s.content.size));else if($t.isSelectable(s))bp(t,$t.create(r,l));else continue;return!0}}function cL(t){return sS(t)}const WJ=Qs?"metaKey":"ctrlKey";Fa.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=cL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&M8e(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(hE(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new P8e(t,s,n,!!r)):(a=="doubleClick"?N8e:C8e)(t,s.pos,s.inside,n)?n.preventDefault():rd(t,"pointer"))};class P8e{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 l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof $t&&u.from<=s&&u.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ho&&!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)),rd(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(()=>Lc(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(hE(e))),this.updateAllowDefault(e),this.allowDefault||!n?rd(this.view,"pointer"):A8e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ia&&this.mightDrag&&!this.mightDrag.node.isAtom||ya&&!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)?(bp(this.view,hn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):rd(this.view,"pointer")}move(e){this.updateAllowDefault(e),rd(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)}}Fa.touchstart=t=>{t.input.lastTouch=Date.now(),cL(t),rd(t,"pointer")};Fa.touchmove=t=>{t.input.lastTouch=Date.now(),rd(t,"pointer")};Fa.contextmenu=t=>cL(t);function qJ(t,e){return t.composing?!0:Ia&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const j8e=Nc?5e3:-1;Ua.compositionstart=Ua.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Xt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),sS(t,!0),t.markCursor=null;else if(sS(t,!e.selection.empty),ho&&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 l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}KJ(t,j8e)};Ua.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++,KJ(t,20))};function KJ(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>sS(t),e))}function XJ(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=D8e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function R8e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=EBe(e.focusNode,e.focusOffset),r=TBe(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 D8e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function sS(t,e=!1){if(!(Nc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),XJ(t),e||t.docView&&t.docView.dirty){let n=iL(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 O8e(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 ub=rs&&dd<15||Kp&&PBe<604;Fa.copy=Ua.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ub?null:n.clipboardData,s=r.content(),{dom:l,text:c}=sL(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):O8e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function L8e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function I8e(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?db(t,r.value,null,i,e):db(t,r.textContent,r.innerHTML,i,e)},50)}function db(t,e,n,r,i){let a=zJ(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Pt.empty)))return!0;if(!a)return!1;let s=L8e(a),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function YJ(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," "):""}Ua.paste=(t,e)=>{let n=e;if(t.composing&&!Nc)return;let r=ub?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&db(t,YJ(r),r.getData("text/html"),i,n)?n.preventDefault():I8e(t,n)};class ZJ{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const F8e=Qs?"altKey":"ctrlKey";function QJ(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[F8e]}Fa.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(hE(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof $t?i.to-1:i.to))){if(r&&r.mightDrag)s=$t.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=$t.create(t.state.doc,f.posBefore))}}let l=(s||t.state.selection).content(),{dom:c,text:u,slice:d}=sL(t,l);(!n.dataTransfer.files.length||!ya||MJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ub?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",ub||n.dataTransfer.setData("text/plain",u),t.dragging=new ZJ(d,QJ(t,n),s)};Fa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ua.dragover=Ua.dragenter=(t,e)=>e.preventDefault();Ua.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(hE(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",x=>{s=x(s,t,!1)}):s=zJ(t,YJ(n.dataTransfer),ub?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&QJ(t,n));if(t.someProp("handleDrop",x=>x(t,n,s||Pt.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let c=s?rJ(t.state.doc,a.pos,s):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=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 p=u.doc.resolve(d);if(f&&$t.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new $t(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,y,b,E)=>x=E),u.setSelection(aL(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Fa.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())&&Lc(t)},20))};Fa.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)};Fa.beforeinput=(t,e)=>{if(ya&&Nc&&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,wh(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 Ua)Fa[t]=Ua[t];function hb(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 oS{constructor(e,n){this.toDOM=e,this.spec=n||Vh,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 Ra(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof oS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hb(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class fd{constructor(e,n){this.attrs=e,this.spec=n||Vh}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 Ra(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof fd&&hb(this.attrs,e.attrs)&&hb(this.spec,e.spec)}static is(e){return e.type instanceof fd}destroy(){}}class uL{constructor(e,n){this.attrs=e,this.spec=n||Vh}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 Ra(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 uL&&hb(this.attrs,e.attrs)&&hb(this.spec,e.spec)}destroy(){}}class Ra{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ra(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 Ra(e,e,new oS(n,r))}static inline(e,n,r,i){return new Ra(e,n,new fd(r,i))}static node(e,n,r,i){return new Ra(e,n,new uL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof fd}get widget(){return this.type instanceof oS}}const Zm=[],Vh={};class Nr{constructor(e,n){this.local=e.length?e:Zm,this.children=n.length?n:Zm}static create(e,n){return n.length?lS(n,e,0,Vh):ga}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 l=this.local[s];l.from<=n&&l.to>=e&&(!a||a(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,a)}}map(e,n,r){return this==ga||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Vh)}mapInner(e,n,r,i,a){let s;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(s||(s=[])).push(c):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?U8e(this.children,s||[],e,n,r,i,a):s?new Nr(s.sort(Gh),Zm):ga}add(e,n){return n.length?this==ga?Nr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=eee(n,l,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(l,d,u+1):i.splice(a,0,c,c+l.nodeSize,lS(d,l,u+1,Vh)),a+=3}});let s=JJ(a?tee(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new Nr(s.length?this.local.concat(s).sort(Gh):this.local,i||this.children)}remove(e){return e.length==0||this==ga?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,l=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(s,l+1);u!=ga?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 l=0;l<i.length;l++)i[l].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Nr(i,r):ga}forChild(e,n){if(this==ga)return this;if(n.isLeaf)return Nr.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let a=e+1,s=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<s&&c.to>a&&c.type instanceof fd){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 l=new Nr(i.sort(Gh),Zm);return r?new Xu([l,r]):l}return r||ga}eq(e){if(this==e)return!0;if(!(e instanceof Nr)||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 dL(this.localsInner(e))}localsInner(e){if(this==ga)return Zm;if(e.inlineContent||!this.local.some(fd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof fd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Nr.empty=new Nr([],[]);Nr.removeOverlap=dL;const ga=Nr.empty;class Xu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Vh));return Xu.from(r)}forChild(e,n){if(n.isLeaf)return Nr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=ga&&(a instanceof Xu?r=r.concat(a.members):r.push(a))}return Xu.from(r)}eq(e){if(!(e instanceof Xu)||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?dL(r?n:n.sort(Gh)):Zm}static from(e){switch(e.length){case 0:return ga;case 1:return e[0];default:return new Xu(e.every(n=>n instanceof Nr)?e:e.reduce((n,r)=>n.concat(r instanceof Nr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function U8e(t,e,n,r,i,a,s){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,p,x,v)=>{let y=v-x-(p-g);for(let b=0;b<l.length;b+=3){let E=l[b+1];if(E<0||g>E+d-f)continue;let w=l[b]+d-f;p>=w?l[b+1]=g<=w?-2:-1:g>=d&&y&&(l[b]+=y,l[b+1]+=y)}f+=y}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let g=n.map(t[u+1]+a,-1),p=g-i,{index:x,offset:v}=r.content.findIndex(f),y=r.maybeChild(x);if(y&&v==f&&v+y.nodeSize==p){let b=l[u+2].mapInner(n,y,d+1,t[u]+a+1,s);b!=ga?(l[u]=f,l[u+1]=p,l[u+2]=b):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=z8e(l,t,e,n,i,a,s),d=lS(u,r,0,s);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let p=d.children[f];for(;g<l.length&&l[g]<p;)g+=3;l.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Nr(e.sort(Gh),l)}function JJ(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 Ra(i.from+e,i.to+e,i.type))}return n}function z8e(t,e,n,r,i,a,s){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):s.onRemove&&s.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+a+1);return n}function eee(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 tee(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function lS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=eee(t,l,c+n);if(u){a=!0;let d=lS(u,l,n+c+1,r);d!=ga&&i.push(c,c+l.nodeSize,d)}});let s=JJ(a?tee(t):t,-n).sort(Gh);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new Nr(s,i):ga}function Gh(t,e){return t.from-e.from||t.to-e.to}function dL(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),Y7(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),Y7(e,i,r.copy(a.from,r.to)));break}}}return e}function Y7(t,e,n){for(;e<t.length&&Gh(n,t[e])>0;)e++;t.splice(e,0,n)}function sk(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ga&&e.push(r)}),t.cursorWrapper&&e.push(Nr.create(t.state.doc,[t.cursorWrapper.deco])),Xu.from(e)}const B8e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},H8e=rs&&dd<=11;class $8e{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 V8e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $8e,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]);rs&&dd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),H8e&&(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,B8e)),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(H7(this.view)){if(this.suppressingSelectionUpdates)return Lc(this.view);if(rs&&dd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xf(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=qp(a))n.add(a);for(let a=e.anchorNode;a;a=qp(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)&&H7(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(ho&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let p=g.parentNode;p&&p.nodeName=="LI"&&(!f||q8e(e,f)!=p)&&g.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&uE(r)&&(u=iL(e))&&u.eq(hn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Lc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),G8e(e)),this.handleDOMChange(a,s,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Lc(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(rs&&dd<=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?aa(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),c=a&&a.parentNode==e.target?aa(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Z7=new WeakMap,Q7=!1;function G8e(t){if(!Z7.has(t)&&(Z7.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ho,Q7)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."),Q7=!0}}function J7(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return xf(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function W8e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return J7(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?J7(t,n):null}function q8e(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 K8e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],uE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ya&&t.input.lastKeyCode===8)for(let y=a;y>i;y--){let b=r.childNodes[y-1],E=b.pmViewDesc;if(b.nodeName=="BR"&&!E){a=y;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||d0.fromSchema(t.state.schema),p=f.resolve(s),x=null,v=g.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:X8e,context:p});if(u&&u[0].pos!=null){let y=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=y),x={anchor:y+s,head:b+s}}return{doc:v,sel:x,from:s,to:l}}function X8e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ia&&/^(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||Ia&&/^(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 Y8e=/^(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 Z8e(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,F=iL(t,N);if(F&&!t.state.selection.eq(F)){if(ya&&Nc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,wh(13,"Enter"))))return;let k=t.state.tr.setSelection(F);N=="pointer"?k.setMeta("pointer",!0):N=="key"&&k.scrollIntoView(),a&&k.setMeta("composition",a),t.dispatch(k)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=K8e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),g,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,p="end"):(g=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=e6e(f.content,u.doc.content,u.from,g,p);if(x&&t.input.domChangeCount++,(Kp&&t.input.lastIOSEnter>Date.now()-225||Nc)&&i.some(N=>N.nodeType==1&&!Y8e.test(N.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",N=>N(t,wh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof Xt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let N=e9(t,t.state.doc,u.sel);if(N&&!N.eq(t.state.selection)){let F=t.state.tr.setSelection(N);a&&F.setMeta("composition",a),t.dispatch(F)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof Xt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),rs&&dd<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)==" "&&(x.start--,x.endA--,x.endB--);let v=u.doc.resolveNoCache(x.start-u.from),y=u.doc.resolveNoCache(x.endB-u.from),b=d.resolve(x.start),E=v.sameParent(y)&&v.parent.inlineContent&&b.end()>=x.endA;if((Kp&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!E&&v.pos<u.doc.content.size&&(!v.sameParent(y)||!v.parent.inlineContent)&&v.pos<y.pos&&!/\S/.test(u.doc.textBetween(v.pos,y.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,wh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&J8e(d,x.start,x.endA,v,y)&&t.someProp("handleKeyDown",N=>N(t,wh(8,"Backspace")))){Nc&&ya&&t.domObserver.suppressSelectionUpdates();return}ya&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Nc&&!E&&v.start()!=y.start()&&y.parentOffset==0&&v.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,y=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,wh(13,"Enter"))})},20));let w=x.start,T=x.endA,A=N=>{let F=N||t.state.tr.replace(w,T,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let k=e9(t,F.doc,u.sel);k&&!(ya&&t.composing&&k.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(k.head==w||k.head==F.mapping.map(T)-1)||rs&&k.empty&&k.head==w)&&F.setSelection(k)}return a&&F.setMeta("composition",a),F.scrollIntoView()},C;if(E)if(v.pos==y.pos){rs&&dd<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Lc(t),20));let N=A(t.state.tr.delete(w,T)),F=d.resolve(x.start).marksAcross(d.resolve(x.endA));F&&N.ensureMarks(F),t.dispatch(N)}else if(x.endA==x.endB&&(C=Q8e(v.parent.content.cut(v.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,x.endA-b.start())))){let N=A(t.state.tr);C.type=="add"?N.addMark(w,T,C.mark):N.removeMark(w,T,C.mark),t.dispatch(N)}else if(v.parent.child(v.index()).isText&&v.index()==y.index()-(y.textOffset?0:1)){let N=v.parent.textBetween(v.parentOffset,y.parentOffset),F=()=>A(t.state.tr.insertText(N,w,T));t.someProp("handleTextInput",k=>k(t,w,T,N,F))||t.dispatch(F())}else t.dispatch(A());else t.dispatch(A())}function e9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:aL(t,e.resolve(n.anchor),e.resolve(n.head))}function Q8e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],s="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[0],s="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(pt.from(u).eq(t))return{mark:l,type:s}}function J8e(t,e,n,r,i){if(n-e<=i.pos-r.pos||ok(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(ok(a,!0,!0));return!s.parent.isTextblock||s.pos>n||ok(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function ok(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 e6e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(s,l));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&&t9(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-s),s=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&t9(t.textBetween(a-1,a+1))&&(a+=c?1:-1),s=a+(s-l),l=a}return{start:a,endA:s,endB:l}}function t9(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 nee{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 y8e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(s9),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=i9(this),r9(this),this.nodeViews=a9(this),this.docView=L7(this.state.doc,n9(this),sk(this),this.dom,this),this.domObserver=new V8e(this,(r,i,a,s)=>Z8e(this,r,i,a,s)),this.domObserver.start(),v8e(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&&Mj(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(s9),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&&(XJ(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=a9(this);n6e(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Mj(this),this.editable=i9(this),r9(this);let c=sk(this),u=n9(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&&DBe(this);if(s){this.domObserver.stop();let p=f&&(rs||ya)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&t6e(i.selection,e.selection);if(f){let x=ya?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=R8e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=L7(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&i8e(this))?Lc(this,p):(IJ(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&&OBe(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 $t){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&k7(this,n.getBoundingClientRect(),e)}else k7(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 ZJ(e.slice,e.move,i<0?void 0:$t.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 l=this.directPlugins[s].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let l=a[s].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(rs){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&&LBe(this.dom),Lc(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 BBe(this,e)}coordsAtPos(e,n=1){return CJ(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 WBe(this,n||this.state,e)}pasteHTML(e,n){return db(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return db(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return sL(this,e)}destroy(){this.docView&&(_8e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],sk(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,SBe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return S8e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ia&&this.root.nodeType===11&&NBe(this.dom.ownerDocument)==this.dom&&W8e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}nee.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function n9(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"),[Ra.node(0,t.state.doc.content.size,e)]}function r9(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:Ra.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function i9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function t6e(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 a9(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 n6e(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 s9(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 Td={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:"'"},cS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},r6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),i6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var sa=0;sa<10;sa++)Td[48+sa]=Td[96+sa]=String(sa);for(var sa=1;sa<=24;sa++)Td[sa+111]="F"+sa;for(var sa=65;sa<=90;sa++)Td[sa]=String.fromCharCode(sa+32),cS[sa]=String.fromCharCode(sa);for(var lk in Td)cS.hasOwnProperty(lk)||(cS[lk]=Td[lk]);function a6e(t){var e=r6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||i6e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?cS:Td)[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 s6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),o6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function l6e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let l=0;l<e.length-1;l++){let c=e[l];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))s6e?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 c6e(t){let e=Object.create(null);for(let n in t)e[l6e(n)]=t[n];return e}function ck(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 u6e(t){return new Or({props:{handleKeyDown:ree(t)}})}function ree(t){let e=c6e(t);return function(n,r){let i=a6e(r),a,s=e[ck(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[ck(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(o6e&&r.ctrlKey&&r.altKey)&&(a=Td[r.keyCode])&&a!=i){let l=e[ck(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var d6e=Object.defineProperty,hL=(t,e)=>{for(var n in e)d6e(t,n,{get:e[n],enumerable:!0})};function fE(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 mE=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,l])=>[s,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),s.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const v=this.buildProps(c,e),y=g(...x)(v);return s.push(y),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s={tr:t,editor:r,view:a,state:fE({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(s)]))}};return s}},iee={};hL(iee,{blur:()=>h6e,clearContent:()=>f6e,clearNodes:()=>m6e,command:()=>p6e,createParagraphNear:()=>g6e,cut:()=>x6e,deleteCurrentNode:()=>b6e,deleteNode:()=>y6e,deleteRange:()=>v6e,deleteSelection:()=>_6e,enter:()=>w6e,exitCode:()=>S6e,extendMarkRange:()=>M6e,first:()=>E6e,focus:()=>A6e,forEach:()=>N6e,insertContent:()=>C6e,insertContentAt:()=>j6e,joinBackward:()=>O6e,joinDown:()=>D6e,joinForward:()=>L6e,joinItemBackward:()=>I6e,joinItemForward:()=>F6e,joinTextblockBackward:()=>U6e,joinTextblockForward:()=>z6e,joinUp:()=>R6e,keyboardShortcut:()=>H6e,lift:()=>$6e,liftEmptyBlock:()=>V6e,liftListItem:()=>G6e,newlineInCode:()=>W6e,resetAttributes:()=>q6e,scrollIntoView:()=>K6e,selectAll:()=>X6e,selectNodeBackward:()=>Y6e,selectNodeForward:()=>Z6e,selectParentNode:()=>Q6e,selectTextblockEnd:()=>J6e,selectTextblockStart:()=>eHe,setContent:()=>tHe,setMark:()=>yHe,setMeta:()=>vHe,setNode:()=>_He,setNodeSelection:()=>wHe,setTextDirection:()=>SHe,setTextSelection:()=>MHe,sinkListItem:()=>EHe,splitBlock:()=>THe,splitListItem:()=>AHe,toggleList:()=>NHe,toggleMark:()=>CHe,toggleNode:()=>kHe,toggleWrap:()=>PHe,undoInputRule:()=>jHe,unsetAllMarks:()=>RHe,unsetMark:()=>DHe,unsetTextDirection:()=>OHe,updateAttributes:()=>LHe,wrapIn:()=>IHe,wrapInList:()=>FHe});var h6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),f6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),m6e=()=>({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,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(g);if(!p)return;const x=wg(p);if(l.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(x||x===0)&&e.lift(p,x)})}),!0},p6e=t=>e=>t(e),g6e=()=>({state:t,dispatch:e})=>yJ(t,e),x6e=(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 Xt(r.doc.resolve(Math.max(s-1,0)))),!0},b6e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const l=i.before(a),c=i.after(a);t.delete(l,c).scrollIntoView()}return!0}return!1};function fi(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 y6e=t=>({tr:e,state:n,dispatch:r})=>{const i=fi(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},v6e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},_6e=()=>({state:t,dispatch:e})=>QO(t,e),w6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),S6e=()=>({state:t,dispatch:e})=>lBe(t,e);function fL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function uS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:fL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function aee(t,e,n={}){return t.find(r=>r.type===e&&uS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function o9(t,e,n={}){return!!aee(t,e,n)}function mL(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),!aee([...i.node.marks],e,n)))return;let s=i.index,l=t.start()+i.offset,c=s+1,u=l+i.node.nodeSize;for(;s>0&&o9([...t.parent.child(s-1).marks],e,n);)s-=1,l-=t.parent.child(s).nodeSize;for(;c<t.parent.childCount&&o9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function eu(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 M6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=eu(t,r.schema),{doc:s,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=mL(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=Xt.create(s,f.from,f.to);n.setSelection(g)}}return!0},E6e=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 see(t){return t instanceof Xt}function kh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function oee(t,e=null){if(!e)return null;const n=hn.atStart(t),r=hn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Xt.create(t,kh(0,i,a),kh(t.content.size,i,a)):Xt.create(t,kh(e,i,a),kh(e,i,a))}function T6e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function pL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var A6e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(pL()||T6e())&&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&&!see(n.state.selection))return s(),!0;const l=oee(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return a&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},N6e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),C6e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),lee=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&&lee(r)}return t};function K_(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 lee(n)}function fb(t,e,n){if(t instanceof ud||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(l=>e.nodeFromJSON(l)));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),fb("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,l="";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,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?d0.fromSchema(c).parseSlice(K_(t),n.parseOptions):d0.fromSchema(c).parse(K_(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=d0.fromSchema(e);return n.slice?a.parseSlice(K_(t),n.parseOptions).content:a.parse(K_(t),n.parseOptions)}return fb("",e,n)}function k6e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof zi||i instanceof Hi))return;const a=t.mapping.maps[r];let s=0;a.forEach((l,c,u,d)=>{s===0&&(s=d)}),t.setSelection(hn.near(t.doc.resolve(s),n))}var P6e=t=>!("type"in t),j6e=(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 l;const c=y=>{a.emit("contentError",{editor:a,error:y,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{fb(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=fb(e,a.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,p=!0;if((P6e(l)?l:[l]).forEach(y=>{y.check(),g=g?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),d===f&&p){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let v;if(g){if(Array.isArray(e))v=e.map(y=>y.text||"").join("");else if(e instanceof pt){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),v=y}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=l;const y=r.doc.resolve(d),b=y.node(),E=y.parentOffset===0,w=b.isText||b.isTextblock,T=b.content.size>0;E&&w&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&k6e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},R6e=()=>({state:t,dispatch:e})=>aBe(t,e),D6e=()=>({state:t,dispatch:e})=>sBe(t,e),O6e=()=>({state:t,dispatch:e})=>hJ(t,e),L6e=()=>({state:t,dispatch:e})=>gJ(t,e),I6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=oE(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},F6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=oE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},U6e=()=>({state:t,dispatch:e})=>rBe(t,e),z6e=()=>({state:t,dispatch:e})=>iBe(t,e);function cee(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function B6e(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let l=0;l<e.length-1;l+=1){const c=e[l];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))pL()||cee()?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 H6e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=B6e(t).split(/-(?!$)/),s=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=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,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Ad(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?fi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const p=Math.max(r,g),x=Math.min(i,g+f.nodeSize);l.push({node:f,from:p,to:x})});const c=i-r,u=l.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>uS(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var $6e=(t,e={})=>({state:n,dispatch:r})=>{const i=fi(t,n.schema);return Ad(n,i,e)?oBe(n,r):!1},V6e=()=>({state:t,dispatch:e})=>vJ(t,e),G6e=t=>({state:e,dispatch:n})=>{const r=fi(t,e.schema);return yBe(r)(e,n)},W6e=()=>({state:t,dispatch:e})=>bJ(t,e);function pE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function l9(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 q6e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const l=pE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=fi(t,r.schema)),l==="mark"&&(s=eu(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,l9(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(l9(g.attrs,e))))})})}),c},K6e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),X6e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ps(t.doc);t.setSelection(n)}return!0},Y6e=()=>({state:t,dispatch:e})=>mJ(t,e),Z6e=()=>({state:t,dispatch:e})=>xJ(t,e),Q6e=()=>({state:t,dispatch:e})=>dBe(t,e),J6e=()=>({state:t,dispatch:e})=>mBe(t,e),eHe=()=>({state:t,dispatch:e})=>fBe(t,e);function Ej(t,e,n={},r={}){return fb(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var tHe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=Ej(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),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function uee(t,e){const n=eu(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 l=s.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function dee(t,e){const n=new lJ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function nHe(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function rHe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function iHe(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 gE(t){return e=>iHe(e.$from,t)}function Ht(t,e,n){return t.config[e]===void 0&&t.parent?Ht(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ht(t.parent,e,n):null}):t.config[e]}function gL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Ht(e,"addExtensions",n);return r?[e,...gL(r())]:e}).flat(10)}function xL(t,e){const n=Ef.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function hee(t){return typeof t=="function"}function $n(t,e=void 0,...n){return hee(t)?e?t.bind(e)(...n):t(...n):t}function aHe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Xp(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 fee(t){const e=[],{nodeExtensions:n,markExtensions:r}=Xp(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 l={name:s.name,options:s.options,storage:s.storage,extensions:i},c=Ht(s,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,p])=>{e.push({type:f,name:g,attribute:{...a,...p}})})})})}),i.forEach(s=>{const l={name:s.name,options:s.options,storage:s.storage},c=Ht(s,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const g={...a,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:s.name,name:d,attribute:g})})}),e}function Vr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),l.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function dS(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)=>Vr(n,r),{})}function sHe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function c9(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 l=s.attribute.parseHTML?s.attribute.parseHTML(n):sHe(n.getAttribute(s.name));return l==null?a:{...a,[s.name]:l}},{});return{...r,...i}}}}function u9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&aHe(n)?!1:n!=null))}function d9(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 oHe(t,e){var n;const r=fee(t),{nodeExtensions:i,markExtensions:a}=Xp(t),s=(n=i.find(u=>Ht(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,E)=>{const w=Ht(E,"extendNodeSchema",f);return{...b,...w?w(u):{}}},{}),p=u9({...g,content:$n(Ht(u,"content",f)),marks:$n(Ht(u,"marks",f)),group:$n(Ht(u,"group",f)),inline:$n(Ht(u,"inline",f)),atom:$n(Ht(u,"atom",f)),selectable:$n(Ht(u,"selectable",f)),draggable:$n(Ht(u,"draggable",f)),code:$n(Ht(u,"code",f)),whitespace:$n(Ht(u,"whitespace",f)),linebreakReplacement:$n(Ht(u,"linebreakReplacement",f)),defining:$n(Ht(u,"defining",f)),isolating:$n(Ht(u,"isolating",f)),attrs:Object.fromEntries(d.map(d9))}),x=$n(Ht(u,"parseHTML",f));x&&(p.parseDOM=x.map(b=>c9(b,d)));const v=Ht(u,"renderHTML",f);v&&(p.toDOM=b=>v({node:b,HTMLAttributes:dS(b,d)}));const y=Ht(u,"renderText",f);return y&&(p.toText=y),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((y,b)=>{const E=Ht(b,"extendMarkSchema",f);return{...y,...E?E(u):{}}},{}),p=u9({...g,inclusive:$n(Ht(u,"inclusive",f)),excludes:$n(Ht(u,"excludes",f)),group:$n(Ht(u,"group",f)),spanning:$n(Ht(u,"spanning",f)),code:$n(Ht(u,"code",f)),attrs:Object.fromEntries(d.map(d9))}),x=$n(Ht(u,"parseHTML",f));x&&(p.parseDOM=x.map(y=>c9(y,d)));const v=Ht(u,"renderHTML",f);return v&&(p.toDOM=y=>v({mark:y,HTMLAttributes:dS(y,d)})),[u.name,p]}));return new WQ({topNode:s,nodes:l,marks:c})}function lHe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function bL(t){return t.sort((n,r)=>{const i=Ht(n,"priority")||100,a=Ht(r,"priority")||100;return i>a?-1:i<a?1:0})}function mee(t){const e=bL(gL(t)),n=lHe(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 pee(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,textSerializers:s={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var g;c.isBlock&&u>r&&(l+=a);const p=s?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(g=c?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),l}function cHe(t,e){const n={from:0,to:t.content.size};return pee(t,n,e)}function gee(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function uHe(t,e){const n=fi(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const s=a.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function xee(t,e){const n=pE(typeof e=="string"?e:e.name,t.schema);return n==="node"?uHe(t,e):n==="mark"?uee(t,e):{}}function dHe(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function hHe(t){const e=dHe(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 bee(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((l,c)=>{s.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;s.push({from:l,to:c})}s.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),hHe(r)}function yL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=mL(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 fHe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const l=i.node(a);l?.type.name===e?s=l:a-=1}return[s,a]};function uk(t,e){return e.nodes[t]||e.marks[t]||null}function N1(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 mHe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:s,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function Tj(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?eu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>uS(f.attrs,n,{strict:!1}));let s=0;const l=[];if(i.forEach(({$from:f,$to:g})=>{const p=f.pos,x=g.pos;t.doc.nodesBetween(p,x,(v,y)=>{if(!v.isText&&!v.marks.length)return;const b=Math.max(p,y),E=Math.min(x,y+v.nodeSize),w=E-b;s+=w,l.push(...v.marks.map(T=>({mark:T,from:b,to:E})))})}),s===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>uS(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=s}function pHe(t,e,n={}){if(!e)return Ad(t,null,n)||Tj(t,null,n);const r=pE(e,t.schema);return r==="node"?Ad(t,e,n):r==="mark"?Tj(t,e,n):!1}var gHe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=gE(l=>l.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)},xHe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function h9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function f9(t,e){const{nodeExtensions:n}=Xp(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=$n(Ht(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function xE(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&&(xE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function yee(t){return t instanceof $t}function bHe(t,e,n){var r;const{selection:i}=e;let a=null;if(see(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const p=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=p&&x}return!u}),u})}var yHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:l}=a,c=eu(t,r.schema);if(i)if(s){const u=uee(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,p)=>{const x=Math.max(p,d),v=Math.min(p+g.nodeSize,f);g.marks.find(b=>b.type===c)?g.marks.forEach(b=>{c===b.type&&n.addMark(x,v,c.create({...b.attrs,...e}))}):n.addMark(x,v,c.create(e))})});return bHe(r,n,c)},vHe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),_He=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=fi(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>A7(a,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>A7(a,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=kh(t,0,r.content.size),a=$t.create(r,i);e.setSelection(a)}return!0},SHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=a.from,l=a.to),i&&n.doc.nodesBetween(s,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},MHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Xt.atStart(r).from,l=Xt.atEnd(r).to,c=kh(i,s,l),u=kh(a,s,l),d=Xt.create(r,c,u);e.setSelection(d)}return!0},EHe=t=>({state:e,dispatch:n})=>{const r=fi(t,e.schema);return wBe(r)(e,n)};function m9(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 THe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=N1(u,l.node().type.name,l.node().attrs);if(a instanceof $t&&a.node.isBlock)return!l.parentOffset||!Oc(s,l.pos)?!1:(r&&(t&&m9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=l.depth===0?void 0:nHe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&g?[{type:g,attrs:d}]:void 0,x=Oc(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&Oc(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(x=!0,p=g?[{type:g,attrs:d}]:void 0),r){if(x&&(a instanceof Xt&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),g&&!f&&!l.parentOffset&&l.parent.type!==g)){const v=e.mapping.map(l.before()),y=e.doc.resolve(v);l.node(-1).canReplaceWith(y.index(),y.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&m9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},AHe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const l=fi(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const g=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let b=pt.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let F=c.depth-E;F>=c.depth-3;F-=1)b=pt.from(c.node(F).copy(b));const w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...N1(g,c.node().type.name,c.node().attrs),...e},A=((s=l.contentMatch.defaultType)==null?void 0:s.createAndFill(T))||void 0;b=b.append(pt.from(l.createAndFill(null,A)||void 0));const C=c.before(c.depth-(E-1));n.replace(C,c.after(-w),new Pt(b,4-E,0));let N=-1;n.doc.nodesBetween(C,n.doc.content.size,(F,k)=>{if(N>-1)return!1;F.isTextblock&&F.content.size===0&&(N=k+1)}),N>-1&&n.setSelection(Xt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...N1(g,f.type.name,f.attrs),...e},v={...N1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const y=p?[{type:l,attrs:x},{type:p,attrs:v}]:[{type:l,attrs:x}];if(!Oc(n.doc,c.pos,2))return!1;if(i){const{selection:b,storedMarks:E}=r,{splittableMarks:w}=a.extensionManager,T=E||b.$to.parentOffset&&b.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!T||!i)return!0;const A=T.filter(C=>w.includes(C.type.name));n.ensureMarks(A)}return!0},dk=(t,e)=>{const n=gE(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&&Rd(t.doc,n.pos)&&t.join(n.pos),!0},hk=(t,e)=>{const n=gE(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&&Rd(t.doc,r)&&t.join(r),!0},NHe=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,p=fi(t,s.schema),x=fi(e,s.schema),{selection:v,storedMarks:y}=s,{$from:b,$to:E}=v,w=b.blockRange(E),T=y||v.$to.parentOffset&&v.$from.marks();if(!w)return!1;const A=gE(C=>f9(C.type.name,f))(v);if(w.depth>=1&&A&&w.depth-A.depth<=1){if(A.node.type===p)return u.liftListItem(x);if(f9(A.node.type.name,f)&&p.validContent(A.node.content)&&l)return c().command(()=>(a.setNodeMarkup(A.pos,p),!0)).command(()=>dk(a,p)).command(()=>hk(a,p)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>dk(a,p)).command(()=>hk(a,p)).run():c().command(()=>{const C=d().wrapInList(p,r),N=T.filter(F=>g.includes(F.type.name));return a.ensureMarks(N),C?!0:u.clearNodes()}).wrapInList(p,r).command(()=>dk(a,p)).command(()=>hk(a,p)).run()},CHe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=eu(t,r.schema);return Tj(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},kHe=(t,e,n={})=>({state:r,commands:i})=>{const a=fi(t,r.schema),s=fi(e,r.schema),l=Ad(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(s,c):i.setNode(a,{...c,...n})},PHe=(t,e={})=>({state:n,commands:r})=>{const i=fi(t,n.schema);return Ad(n,i,e)?r.lift(i):r.wrapIn(i,e)},jHe=()=>({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,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)s.step(l.steps[c].invert(l.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},RHe=()=>({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},DHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,c=eu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&s){let{from:g,to:p}=l;const x=(a=u.marks().find(y=>y.type===c))==null?void 0:a.attrs,v=mL(u,c,x);v&&(g=v.from,p=v.to),n.removeMark(g,p,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},OHe=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,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},LHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const l=pE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=fi(t,r.schema)),l==="mark"&&(s=eu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,p,x,v;n.selection.empty?r.doc.nodesBetween(d,f,(y,b)=>{a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,p=y)}):r.doc.nodesBetween(d,f,(y,b)=>{b<d&&a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,p=y),b>=d&&b<=f&&(a&&a===y.type&&(c=!0,i&&n.setNodeMarkup(b,void 0,{...y.attrs,...e})),s&&y.marks.length&&y.marks.forEach(E=>{if(s===E.type&&(c=!0,i)){const w=Math.max(b,d),T=Math.min(b+y.nodeSize,f);n.addMark(w,T,s.create({...E.attrs,...e}))}}))}),p&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...p.attrs,...e}),s&&p.marks.length&&p.marks.forEach(y=>{s===y.type&&i&&n.addMark(x,v,s.create({...y.attrs,...e}))}))}),c},IHe=(t,e={})=>({state:n,dispatch:r})=>{const i=fi(t,n.schema);return pBe(i,e)(n,r)},FHe=(t,e={})=>({state:n,dispatch:r})=>{const i=fi(t,n.schema);return gBe(i,e)(n,r)},UHe=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={}}},bE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},zHe=(t,e)=>{if(fL(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 X_(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=mHe(u)+a;return s.forEach(g=>{if(d)return;const p=zHe(f,g.find);if(!p)return;const x=c.state.tr,v=fE({state:c.state,transaction:x}),y={from:r-(p[0].length-a.length),to:i},{commands:b,chain:E,can:w}=new mE({editor:n,state:v});g.handler({state:v,range:y,match:p,commands:b,chain:E,can:w})===null||!x.steps.length||(g.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function BHe(t){const{editor:e,rules:n}=t,r=new Or({state:{init(){return null},apply(i,a,s){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=xL(pt.from(d),s.schema);const{from:f}=c,g=f+d.length;X_({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,l){return X_({editor:e,from:a,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&X_({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?X_({editor:e,from:s.pos,to:s.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function HHe(t){return Object.prototype.toString.call(t).slice(8,-1)}function Y_(t){return HHe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function vee(t,e){const n={...t};return Y_(t)&&Y_(e)&&Object.keys(e).forEach(r=>{Y_(e[r])&&Y_(t[r])?n[r]=vee(t[r],e[r]):n[r]=e[r]}),n}var vL=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{...$n(Ht(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...$n(Ht(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>vee(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}},Od=class _ee extends vL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new _ee(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 $He(t){return typeof t=="number"}var VHe=class{constructor(t){this.find=t.find,this.handler=t.handler}},GHe=(t,e,n)=>{if(fL(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 WHe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:l}=t,{commands:c,chain:u,can:d}=new mE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var v,y,b,E,w;if((y=(v=p.type)==null?void 0:v.spec)!=null&&y.code||!(p.isText||p.isTextblock||p.isInline))return;const T=(w=(E=(b=p.content)==null?void 0:b.size)!=null?E:p.nodeSize)!=null?w:0,A=Math.max(r,x),C=Math.min(i,x+T);if(A>=C)return;const N=p.isText?p.text||"":p.textBetween(A-x,C-x,void 0,"");GHe(N,a.find,s).forEach(k=>{if(k.index===void 0)return;const R=A+k.index+1,I=R+k[0].length,L={from:n.tr.mapping.map(R),to:n.tr.mapping.map(I)},q=a.handler({state:n,range:L,match:k,commands:c,chain:u,can:d,pasteEvent:s,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var Z_=null,qHe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function KHe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:g,rule:p,pasteEvt:x})=>{const v=d.tr,y=fE({state:d,transaction:v});if(!(!WHe({editor:e,state:y,from:Math.max(f-1,0),to:g.b-1,rule:p,pasteEvent:x,dropEvent:l})||!v.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Or({view(f){const g=x=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(x.target)?f.dom.parentElement:null,r&&(Z_=e)},p=()=>{Z_&&(Z_=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(a=r===f.dom.parentElement,l=g,!a){const p=Z_;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var p;const x=(p=g.clipboardData)==null?void 0:p.getData("text/html");return s=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,p)=>{const x=f[0],v=x.getMeta("uiEvent")==="paste"&&!i,y=x.getMeta("uiEvent")==="drop"&&!a,b=x.getMeta("applyPasteRules"),E=!!b;if(!v&&!y&&!E)return;if(E){let{text:A}=b;typeof A=="string"?A=A:A=xL(pt.from(A),p.schema);const{from:C}=b,N=C+A.length,F=qHe(A);return c({rule:d,state:p,from:C,to:{b:N},pasteEvt:F})}const w=g.doc.content.findDiffStart(p.doc.content),T=g.doc.content.findDiffEnd(p.doc.content);if(!(!$He(w)||!T||w===T.b))return c({rule:d,state:p,from:w,to:T,pasteEvt:s})}}))}var yE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=mee(t),this.schema=oHe(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:uk(e.name,this.schema)},r=Ht(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return bL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:uk(r.name,this.schema)},a=[],s=Ht(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Ht(r,"exitable",i)&&(l.ArrowRight=()=>Od.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...g}}const c=u6e(l);a.push(c);const u=Ht(r,"addInputRules",i);if(h9(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const p=BHe({editor:t,rules:g}),x=Array.isArray(p)?p:[p];a.push(...x)}}const d=Ht(r,"addPasteRules",i);if(h9(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const p=KHe({editor:t,rules:g});a.push(...p)}}const f=Ht(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return fee(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Xp(this.extensions);return Object.fromEntries(e.filter(n=>!!Ht(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:fi(n.name,this.schema)},a=Ht(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const l=(c,u,d,f,g)=>{const p=dS(c,r);return s({node:c,view:u,getPos:d,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Xp(this.extensions);return Object.fromEntries(e.filter(n=>!!Ht(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:eu(n.name,this.schema)},a=Ht(n,"addMarkView",i);if(!a)return[];const s=(l,c,u)=>{const d=dS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{c$e(l,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:uk(e.name,this.schema)};e.type==="mark"&&((n=$n(Ht(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Ht(e,"onBeforeCreate",r),a=Ht(e,"onCreate",r),s=Ht(e,"onUpdate",r),l=Ht(e,"onSelectionUpdate",r),c=Ht(e,"onTransaction",r),u=Ht(e,"onFocus",r),d=Ht(e,"onBlur",r),f=Ht(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};yE.resolve=mee;yE.sort=bL;yE.flatten=gL;var XHe={};hL(XHe,{ClipboardTextSerializer:()=>See,Commands:()=>Mee,Delete:()=>Eee,Drop:()=>Tee,Editable:()=>Aee,FocusEvents:()=>Cee,Keymap:()=>kee,Paste:()=>Pee,Tabindex:()=>jee,TextDirection:()=>Ree,focusEventsPluginKey:()=>Nee});var ir=class wee extends vL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new wee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},See=ir.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Or({key:new Ci("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)),l=Math.max(...a.map(d=>d.$to.pos)),c=gee(n);return pee(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Mee=ir.create({name:"commands",addCommands(){return{...iee}}}),Eee=ir.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,l,c,u;if((u=(c=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=dee(t.before,[t,...e]);bee(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,v)=>{const y=v+x.nodeSize-2,b=p.oldRange.from<=v&&y<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:v,to:y,newFrom:d.mapping.map(v),newTo:d.mapping.map(y),deletedRange:p.oldRange,newRange:p.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((p,x)=>{var v,y;if(p instanceof Fo){const b=g.slice(x).map(p.from,-1),E=g.slice(x).map(p.to),w=g.invert().map(b,-1),T=g.invert().map(E),A=(v=d.doc.nodeAt(b-1))==null?void 0:v.marks.some(N=>N.eq(p.mark)),C=(y=d.doc.nodeAt(E))==null?void 0:y.marks.some(N=>N.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:w,to:T},newRange:{from:b,to:E},partial:!!(C||A),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()}}),Tee=ir.create({name:"drop",addProseMirrorPlugins(){return[new Or({key:new Ci("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Aee=ir.create({name:"editable",addProseMirrorPlugins(){return[new Or({key:new Ci("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Nee=new Ci("focusEvents"),Cee=ir.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Or({key:Nee,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}}}})]}}),kee=ir.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:g,parent:p}=f,x=f.parent.isTextblock&&g>0?l.doc.resolve(g-1):f,v=x.parent.type.spec.isolating,y=f.pos-f.parentOffset,b=v&&x.parent.childCount===1?y===f.pos:hn.atStart(u).from===g;return!d||!p.type.isTextblock||p.textContent.length||!b||b&&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 pL()||cee()?a:i},addProseMirrorPlugins(){return[new Or({key:new Ci("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:l}=e.selection,c=hn.atStart(e.doc).from,u=hn.atEnd(e.doc).to;if(a||!(s===c&&l===u)||!xE(n.doc))return;const g=n.tr,p=fE({state:n,transaction:g}),{commands:x}=new mE({editor:this.editor,state:p});if(x.clearNodes(),!!g.steps.length)return g}})]}}),Pee=ir.create({name:"paste",addProseMirrorPlugins(){return[new Or({key:new Ci("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),jee=ir.create({name:"tabindex",addProseMirrorPlugins(){return[new Or({key:new Ci("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ree=ir.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Xp(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 Or({key:new Ci("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),YHe=class Qm{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 Qm(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 Qm(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 Qm(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 l=this.resolvedPos.doc.resolve(s);if(!i&&l.depth<=this.depth)return;const c=new Qm(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Qm(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){const c=s[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(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)}},ZHe=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function QHe(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 JHe=class extends UHe{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=oee(e,this.options.autofocus);this.editorState=sp.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=QHe(ZHe,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=hee(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?[Aee,See.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Mee,Cee,kee,jee,Tee,Pee,Eee,Ree.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 yE(r,this)}createCommandManager(){this.commandManager=new mE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Ej(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=Ej(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new nee(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")),l=s?.getMeta("focus"),c=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.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 xee(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return pHe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return xL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return cHe(this.state.doc,{blockSeparator:e,textSerializers:{...gee(this.schema),...n}})}get isEmpty(){return xE(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 YHe(e,this)}get $doc(){return this.$pos(0)}};function Yp(t){return new bE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=$n(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,s=r[r.length-1],l=r[0];if(s){const c=l.search(/\S/),u=n.from+l.indexOf(s),d=u+s.length;if(yL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const g=n.from+c+s.length;a.addMark(n.from+c,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function Dee(t){return new bE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=$n(t.getAttributes,void 0,r)||{},{tr:a}=e,s=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=s+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,s+r[0].length-1),a.replaceWith(d,l,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(l))}a.scrollIntoView()},undoable:t.undoable})}function Aj(t){return new bE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=$n(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 Zp(t){return new bE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=$n(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),c=s.doc.resolve(n.from).blockRange(),u=c&&YO(c,t.type,a);if(!u)return null;if(s.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:p}=t.editor.extensionManager,x=g||f.$to.parentOffset&&f.$from.marks();if(x){const v=x.filter(y=>p.includes(y.type.name));s.ensureMarks(v)}}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&&Rd(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)},undoable:t.undoable})}var e$e=t=>"touches"in t,t$e=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=s=>{if(!this.isResizing||!this.activeHandle)return;const l=s.clientX-this.startX,c=s.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const l=s.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(s,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=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,e$e(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),s=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:s&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,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 l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function n$e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof $t){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var r$e={};hL(r$e,{createAtomBlockMarkdownSpec:()=>i$e,createBlockMarkdownSpec:()=>a$e,createInlineMarkdownSpec:()=>l$e,parseAttributes:()=>_L,parseIndentedBlocks:()=>Nj,renderNestedMarkdownContent:()=>SL,serializeAttributes:()=>wL});function _L(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),p=n[g];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function wL(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 i$e(t){const{nodeName:e,name:n,parseAttributes:r=_L,serializeAttributes:i=wL,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...a,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(g))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,g){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const v=x[1]||"",y=r(v);if(!s.find(E=>!(E in y)))return{type:e,raw:x[0],attributes:y}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),p=g?` {${g}}`:"";return`:::${c}${p} :::`}}}function a$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=_L,serializeAttributes:a=wL,defaultAttributes:s={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const g={};return c.forEach(p=>{p in f&&(g[p]=f[p])}),g};return{parseMarkdown:(f,g)=>{let p;if(r){const v=r(f);p=typeof v=="string"?[{type:"text",text:v}]:v}else l==="block"?p=g.parseChildren(f.tokens||[]):p=g.parseInline(f.tokens||[]);const x={...s,...f.attributes};return g.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var g;const p=new RegExp(`^:::${u}`,"m"),x=(g=f.match(p))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(f,g,p){var x;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(v);if(!y)return;const[b,E=""]=y,w=i(E);let T=1;const A=b.length;let C="";const N=/^:::([\w-]*)(\s.*)?/gm,F=f.slice(A);for(N.lastIndex=0;;){const k=N.exec(F);if(k===null)break;const R=k.index,I=k[1];if(!((x=k[2])!=null&&x.endsWith(":::"))){if(I)T+=1;else if(T-=1,T===0){const L=F.slice(0,R);C=L.trim();const q=f.slice(0,A+R+k[0].length);let j=[];if(C)if(l==="block")for(j=p.blockTokens(L),j.forEach(V=>{V.text&&(!V.tokens||V.tokens.length===0)&&(V.tokens=p.inlineTokens(V.text))});j.length>0;){const V=j[j.length-1];if(V.type==="paragraph"&&(!V.text||V.text.trim()===""))j.pop();else break}else j=p.inlineTokens(C);return{type:e,raw:q,attributes:w,content:C,tokens:j}}}}}},renderMarkdown:(f,g)=>{const p=d(f.attrs||{}),x=a(p),v=x?` {${x}}`:"",y=g.renderChildren(f.content||[],`
- `);return`:::${u}${v}
- ${y}
- :::`}}}function s$e(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 o$e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function l$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=s$e,serializeAttributes:a=o$e,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const p={};return c.forEach(x=>{x in g&&(p[x]=g[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,p)=>{const x={...s,...g.attributes};if(l)return p.createNode(e,x);const v=r?r(g):g.content||"";return v?p.createNode(e,x,[p.createTextNode(v)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=g.match(p),v=x?.index;return v!==void 0?v:-1},tokenize(g,p,x){const v=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=g.match(v);if(!y)return;let b="",E="";if(l){const[,T]=y;E=T}else{const[,T,A]=y;E=T,b=A||""}const w=i(E.trim());return{type:e,raw:y[0],content:b.trim(),attributes:w}}},renderMarkdown:g=>{let p="";r?p=r(g):g.content&&g.content.length>0&&(p=g.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const x=d(g.attrs||{}),v=a(x),y=v?` ${v}`:"";return l?`[${u}${y}]`:`[${u}${y}]${p}[/${u}]`}}}function Nj(t,e,n){var r,i,a,s;const l=t.split(`
- `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const g=l[d],p=g.match(e.itemPattern);if(!p){if(c.length>0)break;if(g.trim()===""){d+=1,u=`${u}${g}
- `;continue}else return}const x=e.extractItemData(p),{indentLevel:v,mainContent:y}=x;u=`${u}${g}
- `;const b=[y];for(d+=1;d<l.length;){const A=l[d];if(A.trim()===""){const N=l.slice(d+1).findIndex(R=>R.trim()!=="");if(N===-1)break;if((((i=(r=l[d+1+N].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){b.push(A),u=`${u}${A}
- `,d+=1;continue}else break}if((((s=(a=A.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>v)b.push(A),u=`${u}${A}
- `,d+=1;else break}let E;const w=b.slice(1);if(w.length>0){const A=w.map(C=>C.slice(v+f)).join(`
- `);A.trim()&&(e.customNestedParser?E=e.customNestedParser(A):E=n.blockTokens(A))}const T=e.createToken(x,E);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function SL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return s&&s.length>0&&s.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(g=>g?e.indent(g):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function c$e(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(p=>{if(p!==s)return!1;f=p}),!f)return;let g=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(g=!0)}),g){const p=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,p)}}),a.docChanged&&e.view.dispatch(a)}var ls=class Oee extends vL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Oee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function yf(t){return new VHe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=$n(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),g=f+l.length;if(yL(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(y=>y===t.type&&y!==x.mark.type)).filter(x=>x.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+l.length,s.addMark(n.from+d,u,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var fk,p9;function u$e(){return p9||(p9=1,fk=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}),fk}var d$e=u$e();const h$e=bo(d$e);var f$e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},m$e=({contentComponent:t})=>{const e=Xj.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return o.jsx(o.Fragment,{children:Object.values(e)})};function p$e(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Ose.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 g$e=class extends _r.Component{constructor(t){var e;super(t),this.editorContentRef=_r.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=p$e(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:f$e(e,this.editorContentRef),...n}),t?.contentComponent&&o.jsx(m$e,{contentComponent:t.contentComponent})]})}},x$e=M.forwardRef((t,e)=>{const n=_r.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return _r.createElement(g$e,{key:n,innerRef:e,...t})}),b$e=_r.memo(x$e),y$e=typeof window<"u"?M.useLayoutEffect:M.useEffect,v$e=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function _$e(t){var e;const[n]=M.useState(()=>new v$e(t.editor)),r=RW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:h$e);return y$e(()=>n.watch(t.editor),[t.editor,n]),M.useDebugValue(r),r}var w$e=!1,Cj=typeof window>"u",S$e=Cj||!!(typeof window<"u"&&window.next),M$e=class Lee{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?Cj||S$e?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new JHe(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?Lee.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 E$e(t={},e=[]){const n=M.useRef(t);n.current=t;const[r]=M.useState(()=>new M$e(n)),i=Xj.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(i),M.useEffect(r.onRender(e)),_$e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var T$e=M.createContext({editor:null});T$e.Consumer;var A$e=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),N$e=()=>M.useContext(A$e);_r.forwardRef((t,e)=>{const{onDragStart:n}=N$e(),r=t.as||"div";return o.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});_r.createContext({markViewContentRef:()=>{}});var hS=(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]},C$e=/^\s*>\s$/,k$e=ls.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return hS("blockquote",{...Vr(this.options.HTMLAttributes,t),children:hS("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Zp({find:C$e,type:this.type})]}}),P$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,j$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,R$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,D$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,O$e=Od.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 hS("strong",{...Vr(this.options.HTMLAttributes,t),children:hS("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[Yp({find:P$e,type:this.type}),Yp({find:R$e,type:this.type})]},addPasteRules(){return[yf({find:j$e,type:this.type}),yf({find:D$e,type:this.type})]}}),L$e=/(^|[^`])`([^`]+)`(?!`)$/,I$e=/(^|[^`])`([^`]+)`(?!`)/g,F$e=Od.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Vr(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[Yp({find:L$e,type:this.type})]},addPasteRules(){return[yf({find:I$e,type:this.type})]}}),mk=4,U$e=/^```([a-z]+)?[\s\n]$/,z$e=/^~~~([a-z]+)?[\s\n]$/,B$e=ls.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:mk,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",Vr(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:mk,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;if(a.parent.type!==this.type)return!1;const l=" ".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,p=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>l+x).join(`
- `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:mk,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),p=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,v=0;const y=u-d;for(let C=0;C<p.length;C+=1){if(v+p[C].length>=y){x=C;break}v+=p[C].length+1}const E=((c=p[x].match(/^ */))==null?void 0:c[0])||"",w=Math.min(E.length,n);if(w===0)return!0;let T=d;for(let C=0;C<x;C+=1)T+=p[C].length+1;return l.delete(T,T+w),u-T<=w&&l.setSelection(Xt.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(p=>{var x;const v=((x=p.match(/^ */))==null?void 0:x[0])||"",y=Math.min(v.length,n);return p.slice(y)}).join(`
- `);return l.replaceWith(c,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
- `);return!a||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(hn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Aj({find:U$e,type:this.type,getAttributes:t=>({language:t[1]})}),Aj({find:z$e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Or({key:new Ci("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:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return s.replaceSelectionWith(this.type.create({language:a},c)),s.selection.$from.parent.type!==this.type&&s.setSelection(Xt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),H$e=ls.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),$$e=ls.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",Vr(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&s){const f=c.filter(g=>l.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),V$e=ls.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]}`,Vr(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=>Aj({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),G$e=ls.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Vr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!n$e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return yee(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:s,dispatch:l})=>{if(l){const{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Xt.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection($t.create(s.doc,c.pos)):s.setSelection(Xt.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(Xt.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Dee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),W$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,q$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,K$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,X$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Y$e=Od.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",Vr(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[Yp({find:W$e,type:this.type}),Yp({find:K$e,type:this.type})]},addPasteRules(){return[yf({find:q$e,type:this.type}),yf({find:X$e,type:this.type})]}});const Z$e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Q$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",kj="numeric",Pj="ascii",jj="alpha",p0="asciinumeric",e0="alphanumeric",Rj="domain",Iee="emoji",J$e="scheme",eVe="slashscheme",pk="whitespace";function tVe(t,e){return t in e||(e[t]=[]),e[t]}function Ph(t,e,n){e[kj]&&(e[p0]=!0,e[e0]=!0),e[Pj]&&(e[p0]=!0,e[jj]=!0),e[p0]&&(e[e0]=!0),e[jj]&&(e[e0]=!0),e[e0]&&(e[Rj]=!0),e[Iee]&&(e[Rj]=!0);for(const r in e){const i=tVe(r,n);i.indexOf(t)<0&&i.push(t)}}function nVe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Qa(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Qa.groups={};Qa.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||Qa.groups;let i;return e&&e.j?i=e:(i=new Qa(e),n&&r&&Ph(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||Qa.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let s,l=i.go(t);if(l?(s=new Qa,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Qa,a){if(r)if(s.t&&typeof s.t=="string"){const c=Object.assign(nVe(s.t,r),n);Ph(a,c,r)}else n&&Ph(a,n,r);s.t=a}return i.j[t]=s,s}};const ln=(t,e,n,r,i)=>t.ta(e,n,r,i),zr=(t,e,n,r,i)=>t.tr(e,n,r,i),g9=(t,e,n,r,i)=>t.ts(e,n,r,i),yt=(t,e,n,r,i)=>t.tt(e,n,r,i),pc="WORD",Dj="UWORD",Fee="ASCIINUMERICAL",Uee="ALPHANUMERICAL",mb="LOCALHOST",Oj="TLD",Lj="UTLD",C1="SCHEME",Jm="SLASH_SCHEME",ML="NUM",Ij="WS",EL="NL",g0="OPENBRACE",x0="CLOSEBRACE",fS="OPENBRACKET",mS="CLOSEBRACKET",pS="OPENPAREN",gS="CLOSEPAREN",xS="OPENANGLEBRACKET",bS="CLOSEANGLEBRACKET",yS="FULLWIDTHLEFTPAREN",vS="FULLWIDTHRIGHTPAREN",_S="LEFTCORNERBRACKET",wS="RIGHTCORNERBRACKET",SS="LEFTWHITECORNERBRACKET",MS="RIGHTWHITECORNERBRACKET",ES="FULLWIDTHLESSTHAN",TS="FULLWIDTHGREATERTHAN",AS="AMPERSAND",NS="APOSTROPHE",CS="ASTERISK",Vu="AT",kS="BACKSLASH",PS="BACKTICK",jS="CARET",Yu="COLON",TL="COMMA",RS="DOLLAR",rl="DOT",DS="EQUALS",AL="EXCLAMATION",Xs="HYPHEN",b0="PERCENT",OS="PIPE",LS="PLUS",IS="POUND",y0="QUERY",NL="QUOTE",zee="FULLWIDTHMIDDLEDOT",CL="SEMI",il="SLASH",v0="TILDE",FS="UNDERSCORE",Bee="EMOJI",US="SYM";var Hee=Object.freeze({__proto__:null,ALPHANUMERICAL:Uee,AMPERSAND:AS,APOSTROPHE:NS,ASCIINUMERICAL:Fee,ASTERISK:CS,AT:Vu,BACKSLASH:kS,BACKTICK:PS,CARET:jS,CLOSEANGLEBRACKET:bS,CLOSEBRACE:x0,CLOSEBRACKET:mS,CLOSEPAREN:gS,COLON:Yu,COMMA:TL,DOLLAR:RS,DOT:rl,EMOJI:Bee,EQUALS:DS,EXCLAMATION:AL,FULLWIDTHGREATERTHAN:TS,FULLWIDTHLEFTPAREN:yS,FULLWIDTHLESSTHAN:ES,FULLWIDTHMIDDLEDOT:zee,FULLWIDTHRIGHTPAREN:vS,HYPHEN:Xs,LEFTCORNERBRACKET:_S,LEFTWHITECORNERBRACKET:SS,LOCALHOST:mb,NL:EL,NUM:ML,OPENANGLEBRACKET:xS,OPENBRACE:g0,OPENBRACKET:fS,OPENPAREN:pS,PERCENT:b0,PIPE:OS,PLUS:LS,POUND:IS,QUERY:y0,QUOTE:NL,RIGHTCORNERBRACKET:wS,RIGHTWHITECORNERBRACKET:MS,SCHEME:C1,SEMI:CL,SLASH:il,SLASH_SCHEME:Jm,SYM:US,TILDE:v0,TLD:Oj,UNDERSCORE:FS,UTLD:Lj,UWORD:Dj,WORD:pc,WS:Ij});const dc=/[a-z]/,Bx=new RegExp("\\p{L}","u"),gk=new RegExp("\\p{Emoji}","u"),hc=/\d/,xk=/\s/,x9="\r",bk=`
- `,rVe="️",iVe="",yk="";let Q_=null,J_=null;function aVe(t=[]){const e={};Qa.groups=e;const n=new Qa;Q_==null&&(Q_=b9(Z$e)),J_==null&&(J_=b9(Q$e)),yt(n,"'",NS),yt(n,"{",g0),yt(n,"}",x0),yt(n,"[",fS),yt(n,"]",mS),yt(n,"(",pS),yt(n,")",gS),yt(n,"<",xS),yt(n,">",bS),yt(n,"(",yS),yt(n,")",vS),yt(n,"「",_S),yt(n,"」",wS),yt(n,"『",SS),yt(n,"』",MS),yt(n,"<",ES),yt(n,">",TS),yt(n,"&",AS),yt(n,"*",CS),yt(n,"@",Vu),yt(n,"`",PS),yt(n,"^",jS),yt(n,":",Yu),yt(n,",",TL),yt(n,"$",RS),yt(n,".",rl),yt(n,"=",DS),yt(n,"!",AL),yt(n,"-",Xs),yt(n,"%",b0),yt(n,"|",OS),yt(n,"+",LS),yt(n,"#",IS),yt(n,"?",y0),yt(n,'"',NL),yt(n,"/",il),yt(n,";",CL),yt(n,"~",v0),yt(n,"_",FS),yt(n,"\\",kS),yt(n,"・",zee);const r=zr(n,hc,ML,{[kj]:!0});zr(r,hc,r);const i=zr(r,dc,Fee,{[p0]:!0}),a=zr(r,Bx,Uee,{[e0]:!0}),s=zr(n,dc,pc,{[Pj]:!0});zr(s,hc,i),zr(s,dc,s),zr(i,hc,i),zr(i,dc,i);const l=zr(n,Bx,Dj,{[jj]:!0});zr(l,dc),zr(l,hc,a),zr(l,Bx,l),zr(a,hc,a),zr(a,dc),zr(a,Bx,a);const c=yt(n,bk,EL,{[pk]:!0}),u=yt(n,x9,Ij,{[pk]:!0}),d=zr(n,xk,Ij,{[pk]:!0});yt(n,yk,d),yt(u,bk,c),yt(u,yk,d),zr(u,xk,d),yt(d,x9),yt(d,bk),zr(d,xk,d),yt(d,yk,d);const f=zr(n,gk,Bee,{[Iee]:!0});yt(f,"#"),zr(f,gk,f),yt(f,rVe,f);const g=yt(f,iVe);yt(g,"#"),zr(g,gk,f);const p=[[dc,s],[hc,i]],x=[[dc,null],[Bx,l],[hc,a]];for(let v=0;v<Q_.length;v++)Iu(n,Q_[v],Oj,pc,p);for(let v=0;v<J_.length;v++)Iu(n,J_[v],Lj,Dj,x);Ph(Oj,{tld:!0,ascii:!0},e),Ph(Lj,{utld:!0,alpha:!0},e),Iu(n,"file",C1,pc,p),Iu(n,"mailto",C1,pc,p),Iu(n,"http",Jm,pc,p),Iu(n,"https",Jm,pc,p),Iu(n,"ftp",Jm,pc,p),Iu(n,"ftps",Jm,pc,p),Ph(C1,{scheme:!0,ascii:!0},e),Ph(Jm,{slashscheme:!0,ascii:!0},e),t=t.sort((v,y)=>v[0]>y[0]?1:-1);for(let v=0;v<t.length;v++){const y=t[v][0],E=t[v][1]?{[J$e]:!0}:{[eVe]:!0};y.indexOf("-")>=0?E[Rj]=!0:dc.test(y)?hc.test(y)?E[p0]=!0:E[Pj]=!0:E[kj]=!0,g9(n,y,y,E)}return g9(n,"localhost",mb,{ascii:!0}),n.jd=new Qa(US),{start:n,tokens:Object.assign({groups:e},Hee)}}function $ee(t,e){const n=sVe(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,s=0;for(;s<r;){let l=t,c=null,u=0,d=null,f=-1,g=-1;for(;s<r&&(c=l.go(n[s]));)l=c,l.accepts()?(f=0,g=0,d=l):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 sVe(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 Iu(t,e,n,r,i){let a;const s=e.length;for(let l=0;l<s-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new Qa(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Qa(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function b9(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 pb={defaultProtocol:"http",events:null,format:y9,formatHref:y9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function kL(t,e=null){let n=Object.assign({},pb);t&&(n=Object.assign(n,t instanceof kL?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}kL.prototype={o:pb,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]:pb[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 y9(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=pb.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={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),c&&(s.target=c),u&&(s.rel=u),d&&Object.assign(s,d),{tagName:i,attributes:s,content:a,eventListeners:f}}};function vE(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 v9=vE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),_9=vE("text"),oVe=vE("nl"),e1=vE("url",{isLink:!0,toHref(t=pb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==mb&&t[1].t===Yu}}),Ws=t=>new Qa(t);function lVe({groups:t}){const e=t.domain.concat([AS,CS,Vu,kS,PS,jS,RS,DS,Xs,ML,b0,OS,LS,IS,il,US,v0,FS]),n=[NS,Yu,TL,rl,AL,b0,y0,NL,CL,xS,bS,g0,x0,mS,fS,pS,gS,yS,vS,_S,wS,SS,MS,ES,TS],r=[AS,NS,CS,kS,PS,jS,RS,DS,Xs,g0,x0,b0,OS,LS,IS,y0,il,US,v0,FS],i=Ws(),a=yt(i,v0);ln(a,r,a),ln(a,t.domain,a);const s=Ws(),l=Ws(),c=Ws();ln(i,t.domain,s),ln(i,t.scheme,l),ln(i,t.slashscheme,c),ln(s,r,a),ln(s,t.domain,s);const u=yt(s,Vu);yt(a,Vu,u),yt(l,Vu,u),yt(c,Vu,u);const d=yt(a,rl);ln(d,r,a),ln(d,t.domain,a);const f=Ws();ln(u,t.domain,f),ln(f,t.domain,f);const g=yt(f,rl);ln(g,t.domain,f);const p=Ws(v9);ln(g,t.tld,p),ln(g,t.utld,p),yt(u,mb,p);const x=yt(f,Xs);yt(x,Xs,x),ln(x,t.domain,f),ln(p,t.domain,f),yt(p,rl,g),yt(p,Xs,x);const v=yt(p,Yu);ln(v,t.numeric,v9);const y=yt(s,Xs),b=yt(s,rl);yt(y,Xs,y),ln(y,t.domain,s),ln(b,r,a),ln(b,t.domain,s);const E=Ws(e1);ln(b,t.tld,E),ln(b,t.utld,E),ln(E,t.domain,s),ln(E,r,a),yt(E,rl,b),yt(E,Xs,y),yt(E,Vu,u);const w=yt(E,Yu),T=Ws(e1);ln(w,t.numeric,T);const A=Ws(e1),C=Ws();ln(A,e,A),ln(A,n,C),ln(C,e,A),ln(C,n,C),yt(E,il,A),yt(T,il,A);const N=yt(l,Yu),F=yt(c,Yu),k=yt(F,il),R=yt(k,il);ln(l,t.domain,s),yt(l,rl,b),yt(l,Xs,y),ln(c,t.domain,s),yt(c,rl,b),yt(c,Xs,y),ln(N,t.domain,A),yt(N,il,A),yt(N,y0,A),ln(R,t.domain,A),ln(R,e,A),yt(R,il,A);const I=[[g0,x0],[fS,mS],[pS,gS],[xS,bS],[yS,vS],[_S,wS],[SS,MS],[ES,TS]];for(let L=0;L<I.length;L++){const[q,j]=I[L],V=yt(A,q);yt(C,q,V),yt(V,j,A);const K=Ws(e1);ln(V,e,K);const W=Ws();ln(V,n),ln(K,e,K),ln(K,n,W),ln(W,e,K),ln(W,n,W),yt(K,j,A),yt(W,j,A)}return yt(i,mb,E),yt(i,EL,oVe),{start:i,tokens:Hee}}function cVe(t,e,n){let r=n.length,i=0,a=[],s=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(c=l.go(n[i].t));)s.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(g=0,f=l):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(s.push(n[i]),i++);else{s.length>0&&(a.push(vk(_9,e,s)),s=[]),i-=g,d-=g;const p=f.t,x=n.slice(i-d,i);a.push(vk(p,e,x))}}return s.length>0&&a.push(vk(_9,e,s)),a}function vk(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 uVe=typeof console<"u"&&console&&console.warn||(()=>{}),dVe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",pr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function hVe(){return Qa.groups={},pr.scanner=null,pr.parser=null,pr.tokenQueue=[],pr.pluginQueue=[],pr.customSchemes=[],pr.initialized=!1,pr}function w9(t,e=!1){if(pr.initialized&&uVe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${dVe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);pr.customSchemes.push([t,e])}function fVe(){pr.scanner=aVe(pr.customSchemes);for(let t=0;t<pr.tokenQueue.length;t++)pr.tokenQueue[t][1]({scanner:pr.scanner});pr.parser=lVe(pr.scanner.tokens);for(let t=0;t<pr.pluginQueue.length;t++)pr.pluginQueue[t][1]({scanner:pr.scanner,parser:pr.parser});return pr.initialized=!0,pr}function PL(t){return pr.initialized||fVe(),cVe(pr.parser.start,t,$ee(pr.scanner.start,t))}PL.scan=$ee;function Gee(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 kL(n),i=PL(t),a=[];for(let s=0;s<i.length;s++){const l=i[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var jL="[\0- -\u2029 ]",mVe=new RegExp(jL),pVe=new RegExp(`${jL}$`),gVe=new RegExp(jL,"g");function xVe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function bVe(t){return new Or({key:new Ci("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,l=dee(n.doc,[...e]);if(bee(l).forEach(({newRange:u})=>{const d=rHe(r.doc,u,p=>p.isTextblock);let f,g;if(d.length>1)f=d[0],g=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!pVe.test(p))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const p=g.split(mVe).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],v=f.pos+g.lastIndexOf(x);if(!x)return!1;const y=PL(x).map(b=>b.toObject(t.defaultProtocol));if(!xVe(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:v+b.start+1,to:v+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{yL(b.from,b.to,r.doc).some(E=>E.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function yVe(t){return new Or({key:new Ci("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 l=xee(e.state,t.type.name),c=(i=s?.href)!=null?i:l.href,u=(a=s?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&c?(window.open(c,u),!0):!1}}})}function vVe(t){return new Or({key:new Ci("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:s}=a,{empty:l}=s;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Gee(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 ch(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(gVe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Wee=Od.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"){w9(t);return}w9(t.scheme,t.optionalSlashes)})},onDestroy(){hVe()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!ch(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=>!!ch(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=>!!ch(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Vr(this.options.HTMLAttributes,t),0]:["a",Vr(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=>!!ch(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=>!!ch(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[yf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Gee(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!ch(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(bVe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!ch(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(yVe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(vVe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),_Ve=Wee,wVe=Object.defineProperty,SVe=(t,e)=>{for(var n in e)wVe(t,n,{get:e[n],enumerable:!0})},MVe="listItem",S9="textStyle",M9=/^\s*([-+*])\s$/,qee=ls.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",Vr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(MVe,this.editor.getAttributes(S9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Zp({find:M9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Zp({find:M9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(S9),editor:this.editor})),[t]}}),Kee=ls.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Vr(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),l=e.parseChildren(s);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>SL(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)}}}),EVe={};SVe(EVe,{findListItemPos:()=>cy,getNextListDepth:()=>RL,handleBackspace:()=>Fj,handleDelete:()=>Uj,hasListBefore:()=>Xee,hasListItemAfter:()=>TVe,hasListItemBefore:()=>Yee,listItemHasSubList:()=>Zee,nextListIsDeeper:()=>Qee,nextListIsHigher:()=>Jee});var cy=(t,e)=>{const{$from:n}=e.selection,r=fi(t,e.schema);let i=null,a=n.depth,s=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},RL=(t,e)=>{const n=cy(t,e);if(!n)return!1;const[,r]=fHe(e,t,n.$pos.pos+4);return r},Xee=(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))},Yee=(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)},Zee=(t,e,n)=>{if(!n)return!1;const r=fi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},Fj=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ad(t.state,e)&&Xee(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((g,p)=>{g.type.name===e&&u.push({node:g,pos:p})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Ad(t.state,e)||!xHe(t.state))return!1;const r=cy(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=Zee(e,t.state,a);return Yee(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Qee=(t,e)=>{const n=RL(t,e),r=cy(t,e);return!r||!n?!1:n>r.depth},Jee=(t,e)=>{const n=RL(t,e),r=cy(t,e);return!r||!n?!1:n<r.depth},Uj=(t,e)=>{if(!Ad(t.state,e)||!gHe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Qee(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Jee(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},TVe=(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)},ete=ir.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&&Uj(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&&Uj(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&&Fj(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&&Fj(t,n,r)&&(e=!0)}),e}}}}),E9=/^(\s*)(\d+)\.\s+(.*)$/,AVe=/^\s/;function NVe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(E9);if(!a)break;const[,s,l,c]=a,u=s.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const p=t[f];if(p.match(E9))break;if(p.trim()==="")g.push(p),d+=`
- `,f+=1;else if(p.match(AVe))g.push(p),d+=`
- ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:g.join(`
- `)}),r=f,n=f}return[e,r]}function tte(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const l=s.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const p=Math.min(...g.map(v=>v.indent)),x=tte(g,p,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(v=>v.raw).join(`
- `)})}i.push({type:"list_item",raw:s.raw,tokens:u}),a=f}else a+=1}return i}function CVe(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 kVe="listItem",T9="textStyle",A9=/^(\d+)\.\s$/,nte=ls.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",Vr(this.options.HTMLAttributes,n),0]:["ol",Vr(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?CVe(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[a,s]=NVe(i);if(a.length===0)return;const l=tte(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,s).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kVe,this.editor.getAttributes(T9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Zp({find:A9,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Zp({find:A9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(T9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),PVe=/^\s*(\[([( |x])?\])\s$/,jVe=ls.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",Vr(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 SL(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"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,g;l.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const p=n();if(typeof p!="number")return!1;const x=g.doc.nodeAt(p);return g.setNodeMarkup(p,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,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,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Zp({find:PVe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),RVe=ls.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",Vr(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=Nj(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=Nj(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()}}});ir.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(qee.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Kee.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(ete.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(nte.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(jVe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(RVe.configure(this.options.taskList)),t}});var DVe=ls.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Vr(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()}}}),OVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,LVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,IVe=Od.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",Vr(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[Yp({find:OVe,type:this.type})]},addPasteRules(){return[yf({find:LVe,type:this.type})]}}),FVe=ls.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),rte=Od.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",Vr(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()}}}),UVe=rte;function zVe(t={}){return new Or({view(e){return new BVe(e,t)}})}class BVe{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,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),v=f?x.bottom:x.top;f&&g&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:x.left,right:x.right,top:v-y,bottom:v+y}}}}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,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,d=f.top-c.scrollTop*p}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=rJ(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}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 Hr extends hn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Hr.valid(r)?new Hr(r):hn.near(r)}content(){return Pt.empty}eq(e){return e instanceof Hr&&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 Hr(e.resolve(n.pos))}getBookmark(){return new DL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!HVe(e)||!$Ve(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&&Hr.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){a=l.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(Hr.valid(c))return c}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!$t.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let l=e.doc.resolve(i);if(Hr.valid(l))return l}return null}}}Hr.prototype.visible=!1;Hr.findFrom=Hr.findGapCursorFrom;hn.jsonID("gapcursor",Hr);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 Hr.valid(n)?new Hr(n):hn.near(n)}}function ite(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function HVe(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||ite(i.type))return!0;if(i.inlineContent)return!1}}return!0}function $Ve(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||ite(i.type))return!0;if(i.inlineContent)return!1}}return!0}function VVe(){return new Or({props:{decorations:KVe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Hr.valid(n)?new Hr(n):null},handleClick:WVe,handleKeyDown:GVe,handleDOMEvents:{beforeinput:qVe}}})}const GVe=ree({ArrowLeft:t1("horiz",-1),ArrowRight:t1("horiz",1),ArrowUp:t1("vert",-1),ArrowDown:t1("vert",1)});function t1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,l=e>0?s.$to:s.$from,c=s.empty;if(s instanceof Xt){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Hr.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Hr(u))),!0):!1}}function WVe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Hr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&$t.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Hr(r))),!0)}function qVe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Hr))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 Pt(i,0,0));return a.setSelection(Xt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function KVe(t){if(!(t.selection instanceof Hr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Nr.create(t.doc,[Ra.widget(t.selection.head,e,{key:"gapcursor"})])}var zS=200,$i=function(){};$i.prototype.append=function(e){return e.length?(e=$i.from(e),!this.length&&e||e.length<zS&&this.leafAppend(e)||this.length<zS&&e.leafPrepend(this)||this.appendInner(e)):this};$i.prototype.prepend=function(e){return e.length?$i.from(e).append(this):this};$i.prototype.appendInner=function(e){return new XVe(this,e)};$i.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?$i.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};$i.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};$i.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)};$i.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};$i.from=function(e){return e instanceof $i?e:e&&e.length?new ate(e):$i.empty};var ate=(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,l){for(var c=a;c<s;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,l){for(var c=a-1;c>=s;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=zS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=zS)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})($i);$i.empty=new ate([]);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 l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),s)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,s+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),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})($i);const YVe=500;class Oo{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,l,c,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new al(f.map));let p=f.step.map(i.slice(a)),x;p&&s.maybeStep(p).doc&&(x=s.mapping.maps[s.mapping.maps.length-1],u.push(new al(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Oo(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:s,selection:l}}addTransform(e,n,r,i){let a=[],s=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new al(e.mapping.maps[d],f,n),p;(p=c&&c.merge(g))&&(g=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(g),n&&(s++,n=void 0),i||(c=g)}let u=s-r.depth;return u>QVe&&(l=ZVe(l,u),s-=u),new Oo(l.append(a),s)}remapping(e,n){let r=new lb;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 Oo(this.items.append(e.map(n=>new al(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,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},i);let c=n;this.items.forEach(g=>{let p=a.getMirror(--c);if(p==null)return;s=Math.min(s,p);let x=a.maps[p];if(g.step){let v=e.steps[p].invert(e.docs[p]),y=g.selection&&g.selection.map(a.slice(c+1,p));y&&l++,r.push(new al(x,v,y))}else r.push(new al(x))},i);let u=[];for(let g=n;g<s;g++)u.push(new al(a.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Oo(d,l);return f.emptyItemCount()>YVe&&(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,l)=>{if(l>=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 al(u.invert(),c,d),g,p=i.length-1;(g=i.length&&i[p].merge(f))?i[p]=g:i.push(f)}}else s.map&&r--},this.items.length,0),new Oo($i.from(i.reverse()),a)}}Oo.empty=new Oo($i.empty,0);function ZVe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class al{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 al(n.getMap().invert(),n,this.selection)}}}class Gu{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const QVe=20;function JVe(t,e,n,r){let i=n.getMeta(Wh),a;if(i)return i.historyState;n.getMeta(n7e)&&(t=new Gu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Wh))return s.getMeta(Wh).redo?new Gu(t.done.addTransform(n,void 0,r,k1(e)),t.undone,N9(n.mapping.maps),t.prevTime,t.prevComposition):new Gu(t.done,t.undone.addTransform(n,void 0,r,k1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!e7e(n,t.prevRanges)),u=s?_k(t.prevRanges,n.mapping):N9(n.mapping.maps);return new Gu(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,k1(e)),Oo.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Gu(t.done.rebased(n,a),t.undone.rebased(n,a),_k(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Gu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),_k(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function e7e(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 N9(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 _k(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 t7e(t,e,n){let r=k1(e),i=Wh.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),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new Gu(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(s).setMeta(Wh,{redo:n,historyState:c})}let wk=!1,C9=null;function k1(t){let e=t.plugins;if(C9!=e){wk=!1,C9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){wk=!0;break}}return wk}const Wh=new Ci("history"),n7e=new Ci("closeHistory");function r7e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Or({key:Wh,state:{init(){return new Gu(Oo.empty,Oo.empty,null,0,-1)},apply(e,n,r){return JVe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?ote:r=="historyRedo"?lte:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function ste(t,e){return(n,r)=>{let i=Wh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=t7e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const ote=ste(!1,!0),lte=ste(!0,!0);ir.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 Or({key:new Ci("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,l=0,c=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var i7e=ir.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[zVe(this.options)]}});ir.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Or({key:new Ci("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Nr.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 l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(Ra.node(u,u+c.nodeSize,{class:this.options.className}))}),Nr.create(t,a)}}})]}});var a7e=ir.create({name:"gapCursor",addProseMirrorPlugins(){return[VVe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=$n(Ht(t,"allowGapCursor",n)))!=null?e:null}}});ir.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Or({key:new Ci("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,l)=>{const c=r>=l&&r<=l+s.nodeSize,u=!s.isLeaf&&xE(s);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ra.node(l,l+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Nr.create(t,i)}}})]}});ir.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Or({key:new Ci("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||yee(n.selection)||t.view.dragging?null:Nr.create(n.doc,[Ra.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function k9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var s7e=ir.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ci(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 Or({key:e,appendTransaction:(i,a,s)=>{const{doc:l,tr:c,schema:u}=s,d=e.getState(s),f=l.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!k9({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!k9({node:s,types:r})}}})]}}),o7e=ir.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ote(t,e),redo:()=>({state:t,dispatch:e})=>lte(t,e)}},addProseMirrorPlugins(){return[r7e(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),l7e=ir.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(O$e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(k$e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(qee.configure(this.options.bulletList)),this.options.code!==!1&&i.push(F$e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(B$e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(H$e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(i7e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(a7e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push($$e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(V$e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(o7e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(G$e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(Y$e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Kee.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(ete.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(nte.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(DVe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(IVe.configure(this.options.strike)),this.options.text!==!1&&i.push(FVe.configure(this.options.text)),this.options.underline!==!1&&i.push(rte.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(s7e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),c7e=l7e,u7e=ir.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")}}}),d7e=u7e,h7e=20,cte=(t,e=0)=>{const n=[];return!t.children.length||e>h7e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...cte(r,e+1))}),n},f7e=t=>{if(!t.children.length)return;const e=cte(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}`)})},ute=Od.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&f7e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Vr(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}}}}),m7e=ir.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(),l=a.slice(1).join(":").trim();if(s==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),dte=ir.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(),l=a.slice(1).join(":").trim();if(s==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),p7e=ir.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()}}}),g7e=ir.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()}}}),x7e=ir.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()}}});ir.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(m7e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(dte.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(p7e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(g7e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(x7e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(ute.configure(this.options.textStyle)),t}});var b7e=dte,y7e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,v7e=ls.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",Vr(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 l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:s})=>{const l=document.createElement("img");Object.entries(s).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=s.src;const c=new t$e({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Dee({find:y7e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),_7e=v7e;function zj({content:t,onChange:e,placeholder:n}){const r=E$e({extensions:[c7e.configure({heading:!1,codeBlock:!1,code:!1}),UVe,_Ve.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),d7e.configure({types:["paragraph"]}),ute,b7e,_7e.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:l=!1,children:c,title:u})=>o.jsx("button",{type:"button",onClick:s,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${l?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const s=window.prompt("Enter URL:");s&&r.chain().focus().setLink({href:s}).run()};return o.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[o.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[o.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:o.jsx(joe,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:o.jsx(dce,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:o.jsx(rde,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),o.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:o.jsx(fR,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:o.jsx(IG,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),o.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:o.jsx(Xue,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:o.jsx(Gue,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:o.jsx(que,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),o.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:o.jsx(Tb,{className:"w-4 h-4"})}),r.isActive("link")&&o.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:o.jsx(GG,{className:"w-4 h-4"})})]}),o.jsx(b$e,{editor:r})]})}function w7e({archiveId:t,archiveName:e,onClose:n}){const r=mn(),[i,a]=M.useState(!1),[s,l]=M.useState(null),[c,u]=M.useState({}),{data:d,isLoading:f,error:g}=gt({queryKey:["archive-project-page",t],queryFn:()=>Se.getArchiveProjectPage(t)}),p=vt({mutationFn:A=>Se.updateArchiveProjectPage(t,A),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});M.useEffect(()=>{const A=C=>{C.key==="Escape"&&(s!==null?l(null):i?b():n())};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[s,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},y=()=>{p.mutate(c)},b=()=>{a(!1),u({})},E=A=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],N=new DOMParser().parseFromString(A,"text/html"),F=k=>{if(k.nodeType===Node.TEXT_NODE)return k.textContent||"";if(k.nodeType===Node.ELEMENT_NODE){const R=k,I=R.tagName.toLowerCase();if(!C.includes(I))return Array.from(R.childNodes).map(F).join("");let L="";if(I==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(L=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(I==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";L=` src="${j}" style="max-width: 100%; height: auto;"`}const q=Array.from(R.childNodes).map(F).join("");return["br","img"].includes(I)?`<${I}${L} />`:`<${I}${L}>${q}</${I}>`}return""};return Array.from(N.body.childNodes).map(F).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),T=A=>{A.target===A.currentTarget&&n()};return o.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Es,{className:"w-5 h-5 text-bambu-green"}),o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&o.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&o.jsxs(ke,{variant:"ghost",size:"sm",onClick:v,children:[o.jsx(Qh,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&o.jsxs(o.Fragment,{children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),o.jsxs(ke,{variant:"primary",size:"sm",onClick:y,disabled:p.isPending,children:[o.jsx(Ts,{className:"w-4 h-4 mr-1"}),"Save"]})]}),o.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&o.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&o.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[o.jsx(Es,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),o.jsx("p",{children:"No project page data found in this 3MF file."}),o.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-4",children:[i?o.jsx("input",{type:"text",value:c.title||"",onChange:A=>u({...c,title:A.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&&o.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),o.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(e3,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:c.designer||"",onChange:A=>u({...c,designer:A.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[o.jsx(e3,{className:"w-4 h-4"}),o.jsx("span",{children:d.designer}),d.designer_user_id&&o.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:o.jsx(ba,{className:"w-3 h-3"})})]}),d.creation_date&&o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[o.jsx(Qr,{className:"w-4 h-4"}),o.jsx("span",{children:d.creation_date})]}),i?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Es,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:c.license||"",onChange:A=>u({...c,license:A.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[o.jsx(Es,{className:"w-4 h-4"}),o.jsx("span",{children:d.license})]}),d.origin&&o.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?o.jsx(zj,{content:c.description||"",onChange:A=>u({...c,description:A}),placeholder:"Enter description..."}):o.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&o.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?o.jsxs("div",{className:"space-y-2",children:[o.jsx("input",{type:"text",value:c.profile_title||"",onChange:A=>u({...c,profile_title:A.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),o.jsx(zj,{content:c.profile_description||"",onChange:A=>u({...c,profile_description:A}),placeholder:"Profile description..."})]}):o.jsxs(o.Fragment,{children:[d.profile_title&&o.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&o.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&o.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[o.jsx(Eb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),o.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((A,C)=>o.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:o.jsx("img",{src:A.url,alt:A.name,className:"w-full h-full object-cover"})},A.path))})]}),d.design_model_id&&o.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:o.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:[o.jsx(ba,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&x[s]&&o.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[o.jsx("button",{onClick:A=>{A.stopPropagation(),l(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:o.jsx(Yh,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:x[s].url,alt:x[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:A=>A.stopPropagation()}),o.jsx("button",{onClick:A=>{A.stopPropagation(),l(Math.min(x.length-1,s+1))},disabled:s===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:o.jsx(Xc,{className:"w-6 h-6 text-white"})}),o.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:o.jsx(Gt,{className:"w-6 h-6 text-white"})}),o.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",x.length]})]})]})}const S7e=[.25,.5,.75,1,1.5,2,3,4];function Gm(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function M7e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Sr(),a=M.useRef(null),s=M.useRef(null),[l,c]=M.useState(!1),[u,d]=M.useState(0),[f,g]=M.useState(0),[p,x]=M.useState(0),[v,y]=M.useState(0),[b,E]=M.useState(1),[w,T]=M.useState(null),[A,C]=M.useState(null),[N,F]=M.useState(.8),[k,R]=M.useState(!1),{data:I,isLoading:L}=gt({queryKey:["timelapse-info",t],queryFn:()=>Se.getTimelapseInfo(t)}),{data:q}=gt({queryKey:["timelapse-thumbnails",t],queryFn:()=>Se.getTimelapseThumbnails(t,15)}),j=vt({mutationFn:()=>Se.processTimelapse(t,{trimStart:p,trimEnd:v,speed:b,saveMode:"replace"},w||void 0),onSuccess:B=>{i(B.message,"success"),r?.(),n()},onError:B=>{i(B.message||"Processing failed","error")}});M.useEffect(()=>{I?.duration&&v===0&&y(I.duration)},[I?.duration,v]),M.useEffect(()=>{const B=G=>{G.key==="Escape"&&n()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[n]),M.useEffect(()=>{const B=a.current;if(!B)return;const G=()=>{const oe=B.currentTime;d(oe),oe>=v&&(B.currentTime=p)},Q=()=>{g(B.duration),v===0&&y(B.duration)},te=()=>c(!0),he=()=>c(!1);return B.addEventListener("timeupdate",G),B.addEventListener("durationchange",Q),B.addEventListener("play",te),B.addEventListener("pause",he),()=>{B.removeEventListener("timeupdate",G),B.removeEventListener("durationchange",Q),B.removeEventListener("play",te),B.removeEventListener("pause",he)}},[p,v]),M.useEffect(()=>{const B=s.current,G=a.current;!B||!G||!A||(B.currentTime=G.currentTime,B.playbackRate=G.playbackRate,l&&!k?B.play().catch(()=>{}):B.pause())},[l,A,k]),M.useEffect(()=>{s.current&&(s.current.volume=k?0:N)},[N,k]),M.useEffect(()=>{a.current&&(a.current.playbackRate=b),s.current&&(s.current.playbackRate=b)},[b]);const V=M.useCallback(()=>{const B=a.current;B&&(l?B.pause():(B.currentTime<p&&(B.currentTime=p),B.play()))},[l,p]),K=B=>{const G=a.current;G&&(G.currentTime=Math.max(p,Math.min(v,B)))},W=B=>{const G=B.target.files?.[0];G&&(A&&URL.revokeObjectURL(A),T(G),C(URL.createObjectURL(G)))},J=()=>{A&&URL.revokeObjectURL(A),T(null),C(null)};M.useEffect(()=>()=>{A&&URL.revokeObjectURL(A)},[A]);const ee=v-p,Z=ee/b;return L?o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:o.jsxs("div",{className:"flex items-center gap-3 text-white",children:[o.jsx(xt,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:o.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[o.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Rh,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ke,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ts,{className:"w-4 h-4"}),"Save"]})}),o.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:o.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[o.jsxs("div",{className:"relative",children:[o.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:V,muted:!!A}),!l&&o.jsx("button",{onClick:V,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:o.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:o.jsx(Mp,{className:"w-8 h-8 text-white"})})}),A&&o.jsx("audio",{ref:s,src:A,loop:!0})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(vue,{className:"w-4 h-4"}),o.jsx("span",{children:"Trim"}),o.jsxs("span",{className:"ml-auto",children:[Gm(p)," - ",Gm(v)," (",Gm(ee),")"]})]}),o.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 flex",children:q?.thumbnails.map((B,G)=>o.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${B})`}},G))}),o.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),o.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-v)/f*100}%`}}),o.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-v)/f*100}%`}}),o.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),o.jsx("input",{type:"range",min:0,max:f,step:.1,value:p,onChange:B=>{const G=parseFloat(B.target.value);G<v-1&&(x(G),a.current&&a.current.currentTime<G&&(a.current.currentTime=G))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),o.jsx("input",{type:"range",min:0,max:f,step:.1,value:v,onChange:B=>{const G=parseFloat(B.target.value);G>p+1&&y(G)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),o.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:B=>K(parseFloat(B.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),o.jsx("div",{className:"flex items-center justify-center gap-2",children:o.jsx("button",{onClick:V,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?o.jsx(FG,{className:"w-5 h-5 text-white"}):o.jsx(Mp,{className:"w-5 h-5 text-white"})})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(ZS,{className:"w-4 h-4"}),o.jsx("span",{children:"Speed"}),o.jsxs("span",{className:"ml-auto",children:[b,"x (output: ",Gm(Z),")"]})]}),o.jsx("div",{className:"flex gap-1",children:S7e.map(B=>o.jsxs("button",{onClick:()=>E(B),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${b===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[B,"x"]},B))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(Jk,{className:"w-4 h-4"}),o.jsx("span",{children:"Music Overlay"})]}),w?o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[o.jsx(Jk,{className:"w-5 h-5 text-bambu-green"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-white truncate",children:w.name}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[(w.size/1024/1024).toFixed(1)," MB"]})]}),o.jsx("button",{onClick:()=>R(!k),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:k?o.jsx(fde,{className:"w-4 h-4 text-bambu-gray"}):o.jsx(dde,{className:"w-4 h-4 text-bambu-green"})}),o.jsx("input",{type:"range",min:0,max:1,step:.1,value:N,onChange:B=>F(parseFloat(B.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),o.jsx("button",{onClick:J,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:o.jsx(En,{className:"w-4 h-4 text-red-400"})})]}):o.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[o.jsx(oa,{className:"w-8 h-8 text-bambu-gray"}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),o.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),o.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:W,className:"hidden"})]})]}),o.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[o.jsxs("p",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white",children:"Original:"})," ",Gm(f)," @ ",I?.width,"x",I?.height]}),o.jsxs("p",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white",children:"Output:"})," ",Gm(Z)," @ ",b,"x speed",w&&" + music overlay"]})]})]}),j.isPending&&o.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[o.jsx(xt,{className:"w-12 h-12 text-bambu-green animate-spin"}),o.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),o.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const E7e=[.25,.5,.75,1,1.5,2,3,4];function T7e({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const s=M.useRef(null),[l,c]=M.useState(!0),[u,d]=M.useState(1),[f,g]=M.useState(0),[p,x]=M.useState(0),[v,y]=M.useState(!1);M.useEffect(()=>{const N=s.current;N&&(N.playbackRate=u)},[u]),M.useEffect(()=>{const N=F=>{F.key==="Escape"&&i()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[i]),M.useEffect(()=>{const N=s.current;if(!N)return;const F=()=>g(N.currentTime),k=()=>x(N.duration),R=()=>c(!0),I=()=>c(!1);return N.addEventListener("timeupdate",F),N.addEventListener("durationchange",k),N.addEventListener("play",R),N.addEventListener("pause",I),()=>{N.removeEventListener("timeupdate",F),N.removeEventListener("durationchange",k),N.removeEventListener("play",R),N.removeEventListener("pause",I)}},[]);const b=()=>{const N=s.current;N&&(l?N.pause():N.play())},E=N=>{const F=s.current;F&&(F.currentTime=parseFloat(N.target.value))},w=()=>{const N=s.current;N&&(N.currentTime=Math.max(0,N.currentTime-5))},T=()=>{const N=s.current;N&&(N.currentTime=Math.min(p,N.currentTime+5))},A=N=>{const F=Math.floor(N/60),k=Math.floor(N%60);return`${F}:${k.toString().padStart(2,"0")}`},C=()=>{const N=document.createElement("a");N.href=t,N.download=n,N.click()};return o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[o.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Rh,{className:"w-5 h-5 text-bambu-green"}),e]}),o.jsxs("div",{className:"flex items-center gap-2",children:[r&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>y(!0),children:[o.jsx(Uc,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:C,children:[o.jsx(is,{className:"w-4 h-4"}),"Download"]}),o.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:o.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),o.jsxs("div",{className:"p-4",children:[o.jsx("video",{ref:s,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:b}),o.jsxs("div",{className:"mt-4 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:A(f)}),o.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:E,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),o.jsx("span",{className:"text-xs text-bambu-gray w-12",children:A(p)})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:w,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:o.jsx(jue,{className:"w-5 h-5 text-bambu-gray"})}),o.jsx("button",{onClick:b,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?o.jsx(FG,{className:"w-5 h-5 text-white"}):o.jsx(Mp,{className:"w-5 h-5 text-white"})}),o.jsx("button",{onClick:T,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:o.jsx(B1,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),o.jsx("div",{className:"flex gap-1",children:E7e.map(N=>o.jsxs("button",{onClick:()=>d(N),className:`px-2 py-1 text-xs rounded transition-colors ${u===N?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[N,"x"]},N))})]})]})]})]})]}),v&&r&&o.jsx(M7e,{archiveId:r,timelapseSrc:t,onClose:()=>y(!1),onSave:a})]})}function hte({archiveId:t,archiveName:e,onClose:n}){const r=mn(),{showToast:i}=Sr(),[a,s]=M.useState(null),[l,c]=M.useState("asap"),[u,d]=M.useState(""),[f,g]=M.useState(!1),[p,x]=M.useState(!1),{data:v}=gt({queryKey:["printers"],queryFn:()=>Se.getPrinters()});M.useEffect(()=>{v?.length===1&&!a&&s(v[0].id)},[v,a]),M.useEffect(()=>{const w=T=>{T.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const y=vt({mutationFn:w=>Se.addToQueue(w),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:w=>{i(w.message||"Failed to add to queue","error")}}),b=w=>{if(w.preventDefault(),!a){i("Please select a printer","error");return}const T={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:p};l==="scheduled"&&u&&(T.scheduled_time=new Date(u).toISOString()),y.mutate(T)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:o.jsx(wt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:o.jsxs(Et,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Qr,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),o.jsx("p",{className:"text-white font-medium truncate",children:e})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[o.jsx(mo,{className:"w-4 h-4"}),"No printers configured"]}):o.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:w=>s(w.target.value?Number(w.target.value):null),required:!0,children:[o.jsx("option",{value:"",children:"Select printer..."}),v?.map(w=>o.jsx("option",{value:w.id,children:w.name},w.id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),o.jsxs("div",{className:"flex gap-2",children:[o.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 ${l==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[o.jsx(rr,{className:"w-4 h-4"}),"ASAP (when idle)"]}),o.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 ${l==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[o.jsx(Qr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),l==="scheduled"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),o.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:w=>d(w.target.value),min:E(),required:!0})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[o.jsx(kl,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:l==="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."}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",disabled:y.isPending||!a||v?.length===0,children:y.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function A7e({archiveIds:t,onClose:e}){M.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}=gt({queryKey:["archive-comparison",t],queryFn:()=>Se.compareArchives(t)});return o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:o.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:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?o.jsxs("div",{className:"text-center py-12 text-red-400",children:[o.jsx(Gn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),o.jsx("p",{children:"Failed to load comparison"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?o.jsx(N7e,{comparison:n}):null}),o.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:o.jsx(ke,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function N7e({comparison:t}){return o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{className:"overflow-x-auto",children:o.jsxs("table",{className:"w-full",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.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=>o.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[o.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),o.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))]})}),o.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>o.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[o.jsx("td",{className:"py-2 pr-4 text-sm",children:o.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&o.jsx(Gn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),o.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>o.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??o.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&o.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&o.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[o.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[o.jsx(Gn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),o.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>o.jsxs("li",{children:[o.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&o.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?o.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[o.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[o.jsx(xl,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[o.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),o.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?o.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>o.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[o.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",o.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):o.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):o.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:o.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function C7e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function k7e(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function P7e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[s,l]=M.useState(!1),[c,u]=M.useState(t.tags||""),[d,f]=M.useState(t.notes||""),[g,p]=M.useState(t.project_id);return o.jsx(wt,{children:o.jsxs(Et,{className:"py-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(OG,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white font-medium",children:t.filename}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[o.jsx("span",{children:C7e(t.file_size)}),o.jsx("span",{children:"·"}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(rr,{className:"w-3 h-3"}),k7e(t.uploaded_at)]}),t.source_ip&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>l(!s),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:s?o.jsx(Mb,{className:"w-5 h-5"}):o.jsx(Cl,{className:"w-5 h-5"})}),o.jsx(ke,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:g||void 0}),disabled:i,children:i?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(oo,{className:"w-4 h-4"}),"Archive"]})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>r(t.id),disabled:a,children:a?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(En,{className:"w-4 h-4 text-red-400"})})]})]}),s&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),o.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),o.jsx("textarea",{value:d,onChange:x=>f(x.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),o.jsxs("select",{value:g||"",onChange:x=>p(x.target.value?Number(x.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[o.jsx("option",{value:"",children:"No project"}),e.map(x=>o.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})]})})}function j7e(){const t=mn(),{showToast:e}=Sr(),[n,r]=M.useState(!1),[i,a]=M.useState(!1),[s,l]=M.useState(new Set),[c,u]=M.useState(new Set),{data:d,isLoading:f}=gt({queryKey:["pending-uploads"],queryFn:xx.list,refetchInterval:1e4}),{data:g}=gt({queryKey:["projects"],queryFn:()=>Se.getProjects()}),p=vt({mutationFn:({id:b,data:E})=>xx.archive(b,E),onMutate:({id:b})=>{l(E=>new Set(E).add(b))},onSettled:(b,E,{id:w})=>{l(T=>{const A=new Set(T);return A.delete(w),A})},onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${b.print_name}`)},onError:b=>{e(b.message||"Failed to archive","error")}}),x=vt({mutationFn:b=>xx.discard(b),onMutate:b=>{u(E=>new Set(E).add(b))},onSettled:(b,E,w)=>{u(T=>{const A=new Set(T);return A.delete(w),A})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:b=>{e(b.message||"Failed to discard","error")}}),v=vt({mutationFn:xx.archiveAll,onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${b.archived} files${b.failed>0?`, ${b.failed} failed`:""}`)},onError:b=>{e(b.message||"Failed to archive all","error")}}),y=vt({mutationFn:xx.discardAll,onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${b.discarded} files`)},onError:b=>{e(b.message||"Failed to discard all","error")}});return f?o.jsx(wt,{children:o.jsx(Et,{className:"py-8 flex justify-center",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:o.jsxs("div",{className:"mb-6",children:[o.jsxs(wt,{className:"border-l-4 border-l-yellow-500",children:[o.jsx(Ii,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(oa,{className:"w-5 h-5 text-yellow-500"}),o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ke,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(oo,{className:"w-4 h-4"}),"Archive All"]})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:y.isPending,children:y.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(En,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),o.jsxs(Et,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),o.jsx("div",{className:"space-y-3",children:d.map(b=>o.jsx(P7e,{upload:b,projects:g||[],onArchive:(E,w)=>p.mutate({id:E,data:w}),onDiscard:E=>x.mutate(E),isArchiving:s.has(b.id),isDiscarding:c.has(b.id)},b.id))})]})]}),n&&o.jsx(kr,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{v.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&o.jsx(kr,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{y.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function Bj(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Hx(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function P9(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function R7e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a}){const s=mn(),{showToast:l}=Sr(),c=XG(),[u,d]=M.useState(!1),[f,g]=M.useState(!1),[p,x]=M.useState(!1),[v,y]=M.useState(!1),[b,E]=M.useState(!1),[w,T]=M.useState(!1),[A,C]=M.useState([]),[N,F]=M.useState(!1),[k,R]=M.useState(!1),[I,L]=M.useState(!1),[q,j]=M.useState(!1),[V,K]=M.useState(!1),[W,J]=M.useState(null),ee=M.useRef(null),Z=vt({mutationFn:ce=>Se.uploadSource3mf(t.id,ce),onSuccess:ce=>{s.invalidateQueries({queryKey:["archives"]}),l(`Source 3MF attached: ${ce.filename}`)},onError:ce=>{l(ce.message||"Failed to upload source 3MF","error")}}),B=vt({mutationFn:()=>Se.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),l("Source 3MF removed")},onError:ce=>{l(ce.message||"Failed to remove source 3MF","error")}}),G=vt({mutationFn:()=>Se.scanArchiveTimelapse(t.id),onSuccess:ce=>{ce.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),l(`Timelapse attached: ${ce.filename}`)):ce.status==="exists"?l("Timelapse already attached"):ce.status==="not_found"&&ce.available_files&&ce.available_files.length>0?(C(ce.available_files),T(!0)):l(ce.message||"No matching timelapse found","warning")},onError:ce=>{l(ce.message||"Failed to scan for timelapse","error")}}),Q=vt({mutationFn:ce=>Se.selectArchiveTimelapse(t.id,ce),onSuccess:ce=>{s.invalidateQueries({queryKey:["archives"]}),l(`Timelapse attached: ${ce.filename}`),T(!1),C([])},onError:ce=>{l(ce.message||"Failed to attach timelapse","error")}}),te=vt({mutationFn:()=>Se.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),l("Archive deleted")},onError:()=>{l("Failed to delete archive","error")}}),he=vt({mutationFn:()=>Se.toggleFavorite(t.id),onSuccess:ce=>{s.invalidateQueries({queryKey:["archives"]}),l(ce.is_favorite?"Added to favorites":"Removed from favorites")}}),oe=vt({mutationFn:ce=>Se.updateArchive(t.id,{project_id:ce}),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),s.invalidateQueries({queryKey:["projects"]}),l("Project updated")},onError:()=>{l("Failed to update project","error")}}),xe=ce=>{ce.preventDefault(),J({x:ce.clientX,y:ce.clientY})},me=[...t.filename?.toLowerCase().includes(".gcode.")?[{label:"Print",icon:o.jsx(Vi,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"Schedule",icon:o.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"Open in Bambu Studio",icon:o.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{const ce=t.print_name||t.filename||"model",Ce=`${window.location.origin}${Se.getArchiveForSlicer(t.id,ce)}`;gh(Ce)}}]:[{label:"Slice",icon:o.jsx(ba,{className:"w-4 h-4"}),onClick:()=>{const ce=t.print_name||t.filename||"model",Ce=`${window.location.origin}${Se.getArchiveForSlicer(t.id,ce)}`;gh(Ce)}}],{label:"View on MakerWorld",icon:o.jsx(k0,{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:o.jsx(_p,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:o.jsx(Rh,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:o.jsx(bue,{className:"w-4 h-4"}),onClick:()=>G.mutate(),disabled:!t.printer_id||!!t.timelapse_path||G.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:o.jsx(Kk,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ce=document.createElement("a");ce.href=Se.getSource3mfDownloadUrl(t.id),ce.download=`${t.print_name||t.filename}_source.3mf`,ce.click()}else ee.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:o.jsx(oa,{className:"w-4 h-4"}),onClick:()=>ee.current?.click()},{label:"Remove Source 3MF",icon:o.jsx(En,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:o.jsx(is,{className:"w-4 h-4"}),onClick:()=>{const ce=document.createElement("a");ce.href=Se.getArchiveDownload(t.id),ce.download=`${t.print_name||t.filename}.3mf`,ce.click()}},{label:"Copy Download Link",icon:o.jsx(md,{className:"w-4 h-4"}),onClick:()=>{const ce=`${window.location.origin}${Se.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ce).then(()=>{l("Link copied to clipboard")}).catch(()=>{l("Failed to copy link","error")})}},{label:"QR Code",icon:o.jsx(due,{className:"w-4 h-4"}),onClick:()=>F(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:o.jsx(C0,{className:"w-4 h-4"}),onClick:()=>R(!0),disabled:!t.photos?.length},{label:"Project Page",icon:o.jsx(Es,{className:"w-4 h-4"}),onClick:()=>L(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:o.jsx(Tp,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>he.mutate()},{label:"Edit",icon:o.jsx(Uc,{className:"w-4 h-4"}),onClick:()=>y(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:o.jsx(Uo,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:o.jsx(Uo,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const ce=[];if(t.project_id&&ce.push({label:"Remove from Project",icon:o.jsx(Gt,{className:"w-4 h-4"}),onClick:()=>oe.mutate(null)}),!a)ce.push({label:"Loading...",icon:o.jsx(xt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Ce=a.filter(fe=>fe.status==="active");Ce.length===0?ce.push({label:"No projects available",icon:o.jsx(Uo,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Ce.forEach(fe=>{ce.push({label:fe.name,icon:o.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:fe.color||"#888"}}),onClick:()=>oe.mutate(fe.id),disabled:t.project_id===fe.id})})}return ce})()},{label:n?"Deselect":"Select",icon:n?o.jsx(Jh,{className:"w-4 h-4"}):o.jsx(Ep,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:o.jsx(En,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return o.jsxs(wt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:xe,onClick:i?()=>r(t.id):void 0,children:[i&&o.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ce=>{ce.stopPropagation(),r(t.id)},children:n?o.jsx(Jh,{className:"w-5 h-5 text-bambu-green"}):o.jsx(Ep,{className:"w-5 h-5 text-white"})}),o.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?o.jsx("img",{src:Se.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(Eb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),c&&o.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ce=>{ce.stopPropagation();const Ce=ce.currentTarget.getBoundingClientRect();J({x:Ce.left,y:Ce.bottom+4})},title:"Menu",children:o.jsx(cR,{className:"w-5 h-5 text-white"})}),o.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ce=>{ce.stopPropagation(),he.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:o.jsx(Tp,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&o.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&&o.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:[o.jsx(md,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&o.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ce=>{ce.stopPropagation();const Ce=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",fe=`${window.location.origin}${Se.getSource3mfForSlicer(t.id,Ce)}`;gh(fe)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:o.jsx(Kk,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&o.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ce=>{ce.stopPropagation(),E(!0)},title:"View timelapse",children:o.jsx(Rh,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&o.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:ce=>{ce.stopPropagation(),R(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[o.jsx(C0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&o.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})]})]}),o.jsxs(Et,{className:"p-4 flex-1 flex flex-col",children:[o.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),o.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:e}),o.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${t.filename?.toLowerCase().includes(".gcode.")?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:t.filename?.toLowerCase().includes(".gcode.")?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:t.filename?.toLowerCase().includes(".gcode.")?"GCODE":"SOURCE"}),t.project_name&&o.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(ce=>ce.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(ce=>ce.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),o.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)&&o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Hx(t.print_time_seconds||0)}
- Actual: ${Hx(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Hx(t.actual_time_seconds)}`:`Estimated: ${Hx(t.print_time_seconds||0)}`,children:[o.jsx(rr,{className:"w-3 h-3"}),Hx(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&o.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&&o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[o.jsx(Fc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[o.jsx(pd,{className:"w-3 h-3"}),t.total_layers&&o.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&o.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&o.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&o.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[o.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&o.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ce,Ce)=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ce},title:ce},Ce))})]})]}),(t.tags||t.notes)&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&o.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:o.jsx(zG,{className:"w-3 h-3"})}),t.tags?.split(",").map((ce,Ce)=>o.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ce.trim()},Ce))]}),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[o.jsx("span",{children:P9(t.created_at)}),o.jsx("span",{children:Bj(t.file_size)})]}),o.jsxs("div",{className:"flex gap-1 mt-3",children:[t.filename?.toLowerCase().includes(".gcode.")?o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[o.jsx(Vi,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),o.jsx(ke,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ce=t.print_name||t.filename||"model",Ce=`${window.location.origin}${Se.getArchiveForSlicer(t.id,ce)}`;gh(Ce)},title:"Open in Bambu Studio",children:o.jsx(ba,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):o.jsxs(ke,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const ce=t.print_name||t.filename||"model",Ce=`${window.location.origin}${Se.getArchiveForSlicer(t.id,ce)}`;gh(Ce)},title:"Open in Bambu Studio to slice",children:[o.jsx(ba,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),o.jsx(ke,{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:o.jsx(k0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),o.jsx(ke,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:o.jsx(_p,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(ke,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ce=document.createElement("a");ce.href=Se.getArchiveDownload(t.id),ce.download=`${t.print_name||t.filename}.3mf`,ce.click()},title:"Download",children:o.jsx(is,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>y(!0),title:"Edit",children:o.jsx(Uc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:o.jsx(En,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&o.jsx(QUe,{archive:t,onClose:()=>y(!1)}),u&&o.jsx(qUe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&o.jsx(KUe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),p&&o.jsx(kr,{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(),x(!1)},onCancel:()=>x(!1)}),V&&o.jsx(kr,{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:()=>{B.mutate(),K(!1)},onCancel:()=>K(!1)}),W&&o.jsx(JUe,{x:W.x,y:W.y,items:me,onClose:()=>J(null)}),b&&t.timelapse_path&&o.jsx(T7e,{src:Se.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{s.invalidateQueries({queryKey:["archives"]}),E(!1)}}),w&&A.length>0&&o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),o.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),o.jsx("button",{onClick:()=>{T(!1),C([])},className:"text-gray-400 hover:text-white p-1",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:A.map(ce=>o.jsxs("button",{onClick:()=>Q.mutate(ce.name),disabled:Q.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:[o.jsx(Rh,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-white font-medium truncate",children:ce.name}),o.jsxs("p",{className:"text-sm text-gray-400",children:[Bj(ce.size),ce.mtime&&` • ${P9(ce.mtime)}`]})]})]},ce.name))}),o.jsx("div",{className:"p-4 border-t border-gray-700",children:o.jsx(ke,{variant:"secondary",onClick:()=>{T(!1),C([])},className:"w-full",children:"Cancel"})})]})}),N&&o.jsx(sze,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>F(!1)}),k&&t.photos&&t.photos.length>0&&o.jsx(oze,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>R(!1),onDelete:async ce=>{try{await Se.deleteArchivePhoto(t.id,ce),s.invalidateQueries({queryKey:["archives"]}),l("Photo deleted")}catch{l("Failed to delete photo","error")}}}),I&&o.jsx(w7e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>L(!1)}),q&&o.jsx(hte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),o.jsx("input",{ref:ee,type:"file",accept:".3mf",className:"hidden",onChange:ce=>{const Ce=ce.target.files?.[0];Ce&&Z.mutate(Ce),ce.target.value=""}})]})}const D7e=[{id:"all",label:"All Archives",icon:o.jsx(Vle,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:o.jsx(rr,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:o.jsx(Qr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:o.jsx(Qr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:o.jsx(Tp,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:o.jsx(mo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:o.jsx(md,{className:"w-4 h-4"})}];function O7e(){const t=mn(),{showToast:e}=Sr(),n=M.useRef(null),[r,i]=M.useState(""),[a,s]=M.useState(()=>{const de=localStorage.getItem("archiveFilterPrinter");return de?Number(de):null}),[l,c]=M.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=M.useState(()=>{const de=localStorage.getItem("archiveFilterColors");return de?new Set(JSON.parse(de)):new Set}),[f,g]=M.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,x]=M.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[v,y]=M.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[b,E]=M.useState(()=>localStorage.getItem("archiveFilterTag")),[w,T]=M.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[A,C]=M.useState(!1),[N,F]=M.useState([]),[k,R]=M.useState(!1),[I,L]=M.useState(new Set),[q,j]=M.useState(!1),[V,K]=M.useState(!1),[W,J]=M.useState(!1),[ee,Z]=M.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[B,G]=M.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[Q,te]=M.useState(()=>localStorage.getItem("archiveCollection")||"all"),[he,oe]=M.useState(!1),[xe,Te]=M.useState(!1),[me,ce]=M.useState(!1),{data:Ce,isLoading:fe}=gt({queryKey:["archives",a],queryFn:()=>Se.getArchives(a||void 0)}),{data:Ie}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:z}=gt({queryKey:["projects"],queryFn:()=>Se.getProjects()}),H=vt({mutationFn:async de=>(await Promise.all(de.map(ae=>Se.deleteArchive(ae))),de.length),onSuccess:de=>{t.invalidateQueries({queryKey:["archives"]}),L(new Set),e(`${de} archive${de!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});M.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),M.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),M.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),M.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),M.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),M.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]),M.useEffect(()=>{b?localStorage.setItem("archiveFilterTag",b):localStorage.removeItem("archiveFilterTag")},[b]),M.useEffect(()=>{localStorage.setItem("archiveFilterFileType",w)},[w]),M.useEffect(()=>{localStorage.setItem("archiveViewMode",ee)},[ee]),M.useEffect(()=>{localStorage.setItem("archiveSortBy",B)},[B]),M.useEffect(()=>{localStorage.setItem("archiveCollection",Q)},[Q]);const re=new Map(Ie?.map(de=>[de.id,de.name])||[]),$=[...new Set(Ce?.flatMap(de=>de.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),Y=[...new Set(Ce?.flatMap(de=>de.filament_color?.split(",")||[]).filter(Boolean)||[])],se=[...new Set(Ce?.flatMap(de=>de.tags?.split(",").map(ae=>ae.trim())||[]).filter(Boolean)||[])].sort(),ue=Ce?.filter(de=>{const ae=new Date,ze=new Date(de.created_at);let Ue=!0;switch(Q){case"recent":Ue=ae.getTime()-ze.getTime()<1440*60*1e3;break;case"this-week":Ue=ae.getTime()-ze.getTime()<10080*60*1e3;break;case"this-month":Ue=ze.getMonth()===ae.getMonth()&&ze.getFullYear()===ae.getFullYear();break;case"favorites":Ue=de.is_favorite===!0;break;case"failed":Ue=de.status==="failed"||de.status==="aborted";break;case"duplicates":Ue=de.duplicate_count>0;break}const et=(de.print_name||de.filename).toLowerCase().includes(r.toLowerCase()),dt=!l||de.filament_type?.split(", ").includes(l),pe=de.filament_color?.split(",")||[],nt=u.size===0||(f==="or"?pe.some(St=>u.has(St)):[...u].every(St=>pe.includes(St))),ve=Q==="favorites"||!p||de.is_favorite,He=Q==="failed"||!v||de.status!=="failed"&&de.status!=="aborted",je=de.tags?.split(",").map(St=>St.trim())||[],we=!b||je.includes(b),Xe=de.filename?.toLowerCase().includes(".gcode.");return Ue&&et&&dt&&nt&&ve&&He&&we&&(w==="all"||w==="gcode"&&Xe||w==="source"&&!Xe)}).sort((de,ae)=>{switch(B){case"date-desc":return new Date(ae.created_at).getTime()-new Date(de.created_at).getTime();case"date-asc":return new Date(de.created_at).getTime()-new Date(ae.created_at).getTime();case"name-asc":return(de.print_name||de.filename).localeCompare(ae.print_name||ae.filename);case"name-desc":return(ae.print_name||ae.filename).localeCompare(de.print_name||de.filename);case"size-desc":return ae.file_size-de.file_size;case"size-asc":return de.file_size-ae.file_size;default:return 0}}),Ee=q||I.size>0,Me=de=>{L(ae=>{const ze=new Set(ae);return ze.has(de)?ze.delete(de):ze.add(de),ze})},U=()=>{ue&&L(new Set(ue.map(de=>de.id)))},O=()=>{L(new Set),j(!1)},ne=de=>{d(ae=>{const ze=new Set(ae);return ze.has(de)?ze.delete(de):ze.add(de),ze})},be=()=>{d(new Set)},ye=()=>{i(""),s(null),c(null),x(!1),y(!1),E(null),T("all")},_e=r||a||l||p||v||b||w!=="all",We=M.useCallback(de=>{de.preventDefault(),de.dataTransfer.types.includes("Files")&&R(!0)},[]),Ve=M.useCallback(de=>{de.preventDefault(),de.currentTarget===de.target&&R(!1)},[]),Ye=M.useCallback(de=>{de.preventDefault(),R(!1);const ae=Array.from(de.dataTransfer.files).filter(ze=>ze.name.endsWith(".3mf"));ae.length>0?(F(ae),C(!0)):de.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),lt=M.useCallback(de=>{const ae=de.target;if(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.isContentEditable){de.key==="Escape"&&ae.blur();return}switch(de.key){case"/":de.preventDefault(),n.current?.focus();break;case"u":case"U":!de.metaKey&&!de.ctrlKey&&(de.preventDefault(),C(!0));break;case"Escape":Ee&&O();break}},[Ee]);return M.useEffect(()=>(document.addEventListener("keydown",lt),()=>document.removeEventListener("keydown",lt)),[lt]),o.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:We,onDragLeave:Ve,onDrop:Ye,children:[k&&o.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:o.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[o.jsx(oa,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),o.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),o.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),Ee&&o.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:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:O,children:[o.jsx(Gt,{className:"w-4 h-4"}),"Close"]}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsxs("span",{className:"text-white font-medium",children:[I.size," selected"]}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:U,children:"Select All"}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[o.jsx(Ap,{className:"w-4 h-4"}),"Tags"]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>{const de=Array.from(I);Promise.all(de.map(ae=>Se.toggleFavorite(ae))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${de.length} archive${de.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[o.jsx(Tp,{className:"w-4 h-4"}),"Favorite"]}),o.jsxs(ke,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>K(!0),children:[o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]}),o.jsxs("div",{className:"flex items-center justify-between mb-8",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),o.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:Q,onChange:de=>te(de.target.value),children:D7e.map(de=>o.jsx("option",{value:de.id,children:de.label},de.id))})]}),o.jsxs("p",{className:"text-bambu-gray",children:[ue?.length||0," of ",Ce?.length||0," prints"]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"relative",children:[o.jsxs(ke,{variant:"secondary",onClick:()=>oe(!he),disabled:xe,children:[xe?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(F1,{className:"w-4 h-4"}),"Export"]}),he&&o.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:[o.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()=>{oe(!1),Te(!0);try{const{blob:de,filename:ae}=await Se.exportArchives({format:"csv",printerId:a||void 0,status:Q==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(de),Ue=document.createElement("a");Ue.href=ze,Ue.download=ae,Ue.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{Te(!1)}},children:[o.jsx(Es,{className:"w-4 h-4"}),"Export as CSV"]}),o.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()=>{oe(!1),Te(!0);try{const{blob:de,filename:ae}=await Se.exportArchives({format:"xlsx",printerId:a||void 0,status:Q==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(de),Ue=document.createElement("a");Ue.href=ze,Ue.download=ae,Ue.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{Te(!1)}},children:[o.jsx(F1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),I.size>=2&&I.size<=5&&o.jsxs(ke,{variant:"secondary",onClick:()=>ce(!0),children:[o.jsx(op,{className:"w-4 h-4"}),"Compare (",I.size,")"]}),!Ee&&o.jsxs(ke,{variant:"secondary",onClick:()=>j(!0),children:[o.jsx(Jh,{className:"w-4 h-4"}),"Select"]}),o.jsxs(ke,{onClick:()=>C(!0),children:[o.jsx(oa,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),o.jsx(wt,{className:"mb-6",children:o.jsxs(Et,{className:"py-4",children:[o.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[o.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[o.jsx(bl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.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:de=>i(de.target.value)})]}),o.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:[o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(dR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.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:de=>s(de.target.value?Number(de.target.value):null),children:[o.jsx("option",{value:"",children:"All Printers"}),Ie?.map(de=>o.jsx("option",{value:de.id,children:de.name},de.id))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Fc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:l||"",onChange:de=>c(de.target.value||null),children:[o.jsx("option",{value:"",children:"All Materials"}),$.map(de=>o.jsx("option",{value:de,children:de},de))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Kk,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:w,onChange:de=>T(de.target.value),children:[o.jsx("option",{value:"all",children:"All Files"}),o.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),o.jsx("option",{value:"source",children:"Source Only"})]})]}),o.jsxs("button",{onClick:()=>x(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[o.jsx(Tp,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),o.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),o.jsxs("button",{onClick:()=>y(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[o.jsx(mo,{className:"w-4 h-4 "}),o.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),se.length>0&&o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Ap,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.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:b||"",onChange:de=>E(de.target.value||null),children:[o.jsx("option",{value:"",children:"All Tags"}),se.map(de=>o.jsx("option",{value:de,children:de},de))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Noe,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.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:B,onChange:de=>G(de.target.value),children:[o.jsx("option",{value:"date-desc",children:"Newest first"}),o.jsx("option",{value:"date-asc",children:"Oldest first"}),o.jsx("option",{value:"name-asc",children:"Name A-Z"}),o.jsx("option",{value:"name-desc",children:"Name Z-A"}),o.jsx("option",{value:"size-desc",children:"Largest first"}),o.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),o.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[o.jsx("button",{className:`p-2 ${ee==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Z("grid"),title:"Grid view",children:o.jsx(QS,{className:"w-4 h-4"})}),o.jsx("button",{className:`p-2 ${ee==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Z("list"),title:"List view",children:o.jsx(fR,{className:"w-4 h-4"})}),o.jsx("button",{className:`p-2 ${ee==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Z("calendar"),title:"Calendar view",children:o.jsx(Boe,{className:"w-4 h-4"})})]})]}),_e&&o.jsxs(ke,{variant:"ghost",size:"sm",onClick:ye,className:"text-bambu-gray hover:text-white",children:[o.jsx(Gt,{className:"w-4 h-4"}),"Reset"]})]}),Y.length>0&&o.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&o.jsx("button",{onClick:()=>g(de=>de==="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()}),o.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:Y.map(de=>o.jsx("button",{onClick:()=>ne(de),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(de)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:de},title:de},de))}),u.size>0&&o.jsxs("button",{onClick:be,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[o.jsx(Gt,{className:"w-3 h-3"}),"Clear"]})]})]})}),o.jsx(j7e,{}),fe?o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ue?.length===0?o.jsx(wt,{children:o.jsxs(Et,{className:"text-center py-12",children:[o.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):ee==="calendar"?o.jsx(wt,{className:"p-6",children:o.jsx(aze,{archives:ue||[],onArchiveClick:de=>{i(de.print_name||de.filename),Z("grid")}})}):ee==="grid"?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:ue?.map(de=>o.jsx(R7e,{archive:de,printerName:de.printer_id?re.get(de.printer_id)||"Unknown":"No Printer",isSelected:I.has(de.id),onSelect:Me,selectionMode:Ee,projects:z},de.id))}):ee==="list"?o.jsx(wt,{children:o.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[o.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[o.jsx("div",{className:"col-span-1"}),o.jsx("div",{className:"col-span-4",children:"Name"}),o.jsx("div",{className:"col-span-2",children:"Printer"}),o.jsx("div",{className:"col-span-2",children:"Date"}),o.jsx("div",{className:"col-span-1",children:"Size"}),o.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),ue?.map(de=>o.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${I.has(de.id)?"bg-bambu-green/10":""}`,children:[o.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[Ee&&o.jsx("button",{onClick:()=>Me(de.id),children:I.has(de.id)?o.jsx(Jh,{className:"w-4 h-4 text-bambu-green"}):o.jsx(Ep,{className:"w-4 h-4 text-bambu-gray"})}),de.thumbnail_path?o.jsx("img",{src:Se.getArchiveThumbnail(de.id),alt:"",className:"w-10 h-10 object-cover rounded"}):o.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:o.jsx(Eb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),o.jsxs("div",{className:"col-span-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-white text-sm truncate",children:de.print_name||de.filename}),de.timelapse_path&&o.jsx("span",{title:"Has timelapse",children:o.jsx(Rh,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),de.filament_type&&o.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:de.filament_type}),de.filament_color&&o.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:de.filament_color.split(",").map((ae,ze)=>o.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:ae},title:ae},ze))})]})]}),o.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:de.printer_id?re.get(de.printer_id)||"Unknown":"No Printer"}),o.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(de.created_at).toLocaleDateString()}),o.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:Bj(de.file_size)}),o.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>{const ae=de.print_name||de.filename||"model",ze=`${window.location.origin}${Se.getArchiveForSlicer(de.id,ae)}`;gh(ze)},title:"Slice",children:o.jsx(ba,{className:"w-4 h-4"})}),de.makerworld_url&&o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>window.open(de.makerworld_url,"_blank"),title:"MakerWorld",children:o.jsx(k0,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>{const ae=document.createElement("a");ae.href=Se.getArchiveDownload(de.id),ae.download=`${de.print_name||de.filename}.3mf`,ae.click()},title:"Download",children:o.jsx(is,{className:"w-4 h-4"})})]})]},de.id))]})}):null,A&&o.jsx(XUe,{onClose:()=>{C(!1),F([])},initialFiles:N}),V&&o.jsx(kr,{title:"Delete Archives",message:`Are you sure you want to delete ${I.size} archive${I.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${I.size}`,variant:"danger",onConfirm:()=>{H.mutate(Array.from(I)),K(!1)},onCancel:()=>K(!1)}),W&&o.jsx(eze,{selectedIds:Array.from(I),existingTags:se,onClose:()=>J(!1)}),me&&I.size>=2&&I.size<=5&&o.jsx(A7e,{archiveIds:Array.from(I),onClose:()=>{ce(!1),L(new Set),j(!1)}})]})}function L7e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const _E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Sg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function OL(t){return"nodeType"in t}function cs(t){var e,n;return t?Sg(t)?t:OL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function LL(t){const{Document:e}=cs(t);return t instanceof e}function uy(t){return Sg(t)?!1:t instanceof cs(t).HTMLElement}function fte(t){return t instanceof cs(t).SVGElement}function Mg(t){return t?Sg(t)?t.document:OL(t)?LL(t)?t:uy(t)||fte(t)?t.ownerDocument:document:document:document}const Al=_E?M.useLayoutEffect:M.useEffect;function IL(t){const e=M.useRef(t);return Al(()=>{e.current=t}),M.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 I7e(){const t=M.useRef(null),e=M.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=M.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function gb(t,e){e===void 0&&(e=[t]);const n=M.useRef(t);return Al(()=>{n.current!==t&&(n.current=t)},e),n}function dy(t,e){const n=M.useRef();return M.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function BS(t){const e=IL(t),n=M.useRef(null),r=M.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function Hj(t){const e=M.useRef();return M.useEffect(()=>{e.current=t},[t]),e.current}let Sk={};function hy(t,e){return M.useMemo(()=>{if(e)return e;const n=Sk[t]==null?0:Sk[t]+1;return Sk[t]=n,t+"-"+n},[t,e])}function mte(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 l=Object.entries(s);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const yp=mte(1),xb=mte(-1);function F7e(t){return"clientX"in t&&"clientY"in t}function FL(t){if(!t)return!1;const{KeyboardEvent:e}=cs(t.target);return e&&t instanceof e}function U7e(t){if(!t)return!1;const{TouchEvent:e}=cs(t.target);return e&&t instanceof e}function $j(t){if(U7e(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 F7e(t)?{x:t.clientX,y:t.clientY}:null}const Qp=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[Qp.Translate.toString(t),Qp.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),j9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function z7e(t){return t.matches(j9)?t:t.querySelector(j9)}const B7e={display:"none"};function H7e(t){let{id:e,value:n}=t;return _r.createElement("div",{id:e,style:B7e},n)}function $7e(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 _r.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function V7e(){const[t,e]=M.useState("");return{announce:M.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const pte=M.createContext(null);function G7e(t){const e=M.useContext(pte);M.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function W7e(){const[t]=M.useState(()=>new Set),e=M.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[M.useCallback(r=>{let{type:i,event:a}=r;t.forEach(s=>{var l;return(l=s[i])==null?void 0:l.call(s,a)})},[t]),e]}const q7e={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},K7e={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 X7e(t){let{announcements:e=K7e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=q7e}=t;const{announce:a,announcement:s}=V7e(),l=hy("DndLiveRegion"),[c,u]=M.useState(!1);if(M.useEffect(()=>{u(!0)},[]),G7e(M.useMemo(()=>({onDragStart(f){let{active:g}=f;a(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:p}=f;e.onDragMove&&a(e.onDragMove({active:g,over:p}))},onDragOver(f){let{active:g,over:p}=f;a(e.onDragOver({active:g,over:p}))},onDragEnd(f){let{active:g,over:p}=f;a(e.onDragEnd({active:g,over:p}))},onDragCancel(f){let{active:g,over:p}=f;a(e.onDragCancel({active:g,over:p}))}}),[a,e])),!c)return null;const d=_r.createElement(_r.Fragment,null,_r.createElement(H7e,{id:r,value:i.draggable}),_r.createElement($7e,{id:l,announcement:s}));return n?wc.createPortal(d,n):d}var bi;(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"})(bi||(bi={}));function HS(){}function $S(t,e){return M.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function gte(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Vo=Object.freeze({x:0,y:0});function xte(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function bte(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function Y7e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function R9(t){let{left:e,top:n,height:r,width:i}=t;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function yte(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function D9(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const vte=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=D9(e,e.left,e.top),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=xte(D9(c),i);a.push({id:l,data:{droppableContainer:s,value:u}})}}return a.sort(bte)},Z7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=R9(e),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=R9(c),d=i.reduce((g,p,x)=>g+xte(u[x],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:s,value:f}})}}return a.sort(bte)};function Q7e(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,l=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=s*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const J7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,l=n.get(s);if(l){const c=Q7e(l,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(Y7e)};function e9e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function _te(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Vo}function t9e(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,l)=>({...s,top:s.top+t*l.y,bottom:s.bottom+t*l.y,left:s.left+t*l.x,right:s.right+t*l.x}),{...n})}}const n9e=t9e(1);function r9e(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 i9e(t,e,n){const r=r9e(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:l}=r,c=t.left-s-(1-i)*parseFloat(n),u=t.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const a9e={ignoreTransform:!1};function Eg(t,e){e===void 0&&(e=a9e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=cs(t).getComputedStyle(t);u&&(n=i9e(n,u,d))}const{top:r,left:i,width:a,height:s,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:s,bottom:l,right:c}}function O9(t){return Eg(t,{ignoreTransform:!0})}function s9e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function o9e(t,e){return e===void 0&&(e=cs(t).getComputedStyle(t)),e.position==="fixed"}function l9e(t,e){e===void 0&&(e=cs(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 wE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(LL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!uy(i)||fte(i)||n.includes(i))return n;const a=cs(t).getComputedStyle(i);return i!==t&&l9e(i,a)&&n.push(i),o9e(i,a)?n:r(i.parentNode)}return t?r(t):n}function wte(t){const[e]=wE(t,1);return e??null}function Mk(t){return!_E||!t?null:Sg(t)?t:OL(t)?LL(t)||t===Mg(t).scrollingElement?window:uy(t)?t:null:null}function Ste(t){return Sg(t)?t.scrollX:t.scrollLeft}function Mte(t){return Sg(t)?t.scrollY:t.scrollTop}function Vj(t){return{x:Ste(t),y:Mte(t)}}var Ui;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ui||(Ui={}));function Ete(t){return!_E||!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,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:l,maxScroll:r,minScroll:e}}const c9e={x:.2,y:.2};function u9e(t,e,n,r,i){let{top:a,left:s,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=c9e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=Tte(t),p={x:0,y:0},x={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(p.y=Ui.Backward,x.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(p.y=Ui.Forward,x.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!g&&l>=e.right-v.width?(p.x=Ui.Forward,x.x=r*Math.abs((e.right-v.width-l)/v.width)):!f&&s<=e.left+v.width&&(p.x=Ui.Backward,x.x=r*Math.abs((e.left+v.width-s)/v.width)),{direction:p,speed:x}}function d9e(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 Ate(t){return t.reduce((e,n)=>yp(e,Vj(n)),Vo)}function h9e(t){return t.reduce((e,n)=>e+Ste(n),0)}function f9e(t){return t.reduce((e,n)=>e+Mte(n),0)}function m9e(t,e){if(e===void 0&&(e=Eg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);wte(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const p9e=[["x",["left","right"],h9e],["y",["top","bottom"],f9e]];class UL{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=wE(n),i=Ate(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,l]of p9e)for(const c of s)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class _0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function g9e(t){const{EventTarget:e}=cs(t);return t instanceof e?t:Mg(t)}function Ek(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 Js;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Js||(Js={}));function L9(t){t.preventDefault()}function x9e(t){t.stopPropagation()}var An;(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"})(An||(An={}));const Nte={start:[An.Space,An.Enter],cancel:[An.Esc],end:[An.Space,An.Enter,An.Tab]},b9e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case An.Right:return{...n,x:n.x+25};case An.Left:return{...n,x:n.x-25};case An.Down:return{...n,y:n.y+25};case An.Up:return{...n,y:n.y-25}}};class SE{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 _0(Mg(n)),this.windowListeners=new _0(cs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Js.Resize,this.handleCancel),this.windowListeners.add(Js.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Js.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&m9e(r),n(Vo)}handleKeyDown(e){if(FL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Nte,coordinateGetter:s=b9e,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Vo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=s(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=xb(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const v of x){const y=e.code,{isTop:b,isRight:E,isLeft:w,isBottom:T,maxScroll:A,minScroll:C}=Tte(v),N=d9e(v),F={x:Math.min(y===An.Right?N.right-N.width/2:N.right,Math.max(y===An.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(y===An.Down?N.bottom-N.height/2:N.bottom,Math.max(y===An.Down?N.top:N.top+N.height/2,f.y))},k=y===An.Right&&!E||y===An.Left&&!w,R=y===An.Down&&!T||y===An.Up&&!b;if(k&&F.x!==f.x){const I=v.scrollLeft+g.x,L=y===An.Right&&I<=A.x||y===An.Left&&I>=C.x;if(L&&!g.y){v.scrollTo({left:I,behavior:l});return}L?p.x=v.scrollLeft-I:p.x=y===An.Right?v.scrollLeft-A.x:v.scrollLeft-C.x,p.x&&v.scrollBy({left:-p.x,behavior:l});break}else if(R&&F.y!==f.y){const I=v.scrollTop+g.y,L=y===An.Down&&I<=A.y||y===An.Up&&I>=C.y;if(L&&!g.x){v.scrollTo({top:I,behavior:l});return}L?p.y=v.scrollTop-I:p.y=y===An.Down?v.scrollTop-A.y:v.scrollTop-C.y,p.y&&v.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,yp(xb(f,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}SE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Nte,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function I9(t){return!!(t&&"distance"in t)}function F9(t){return!!(t&&"delay"in t)}class zL{constructor(e,n,r){var i;r===void 0&&(r=g9e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=Mg(s),this.documentListeners=new _0(this.document),this.listeners=new _0(r),this.windowListeners=new _0(cs(s)),this.initialCoordinates=(i=$j(a))!=null?i:Vo,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(Js.Resize,this.handleCancel),this.windowListeners.add(Js.DragStart,L9),this.windowListeners.add(Js.VisibilityChange,this.handleCancel),this.windowListeners.add(Js.ContextMenu,L9),this.documentListeners.add(Js.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(F9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(I9(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Js.Click,x9e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Js.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=$j(e))!=null?n:Vo,u=xb(i,c);if(!r&&l){if(I9(l)){if(l.tolerance!=null&&Ek(u,l.tolerance))return this.handleCancel();if(Ek(u,l.distance))return this.handleStart()}if(F9(l)&&Ek(u,l.tolerance))return this.handleCancel();this.handlePending(l,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===An.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const y9e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ME extends zL{constructor(e){const{event:n}=e,r=Mg(n.target);super(e,y9e,r)}}ME.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 v9e={move:{name:"mousemove"},end:{name:"mouseup"}};var Gj;(function(t){t[t.RightClick=2]="RightClick"})(Gj||(Gj={}));class _9e extends zL{constructor(e){super(e,v9e,Mg(e.event.target))}}_9e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===Gj.RightClick?!1:(r?.({event:n}),!0)}}];const Tk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class w9e extends zL{constructor(e){super(e,Tk)}static setup(){return window.addEventListener(Tk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Tk.move.name,e)};function e(){}}}w9e.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 w0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(w0||(w0={}));var VS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(VS||(VS={}));function S9e(t){let{acceleration:e,activator:n=w0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:l=VS.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const p=E9e({delta:f,disabled:!a}),[x,v]=I7e(),y=M.useRef({x:0,y:0}),b=M.useRef({x:0,y:0}),E=M.useMemo(()=>{switch(n){case w0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case w0.DraggableRect:return i}},[n,i,c]),w=M.useRef(null),T=M.useCallback(()=>{const C=w.current;if(!C)return;const N=y.current.x*b.current.x,F=y.current.y*b.current.y;C.scrollBy(N,F)},[]),A=M.useMemo(()=>l===VS.TreeOrder?[...u].reverse():u,[l,u]);M.useEffect(()=>{if(!a||!u.length||!E){v();return}for(const C of A){if(r?.(C)===!1)continue;const N=u.indexOf(C),F=d[N];if(!F)continue;const{direction:k,speed:R}=u9e(C,F,E,e,g);for(const I of["x","y"])p[I][k[I]]||(R[I]=0,k[I]=0);if(R.x>0||R.y>0){v(),w.current=C,x(T,s),y.current=R,b.current=k;return}}y.current={x:0,y:0},b.current={x:0,y:0},v()},[e,T,r,v,a,s,JSON.stringify(E),JSON.stringify(p),x,u,A,d,JSON.stringify(g)])}const M9e={x:{[Ui.Backward]:!1,[Ui.Forward]:!1},y:{[Ui.Backward]:!1,[Ui.Forward]:!1}};function E9e(t){let{delta:e,disabled:n}=t;const r=Hj(e);return dy(i=>{if(n||!r||!i)return M9e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ui.Backward]:i.x[Ui.Backward]||a.x===-1,[Ui.Forward]:i.x[Ui.Forward]||a.x===1},y:{[Ui.Backward]:i.y[Ui.Backward]||a.y===-1,[Ui.Forward]:i.y[Ui.Forward]||a.y===1}}},[n,e,r])}function T9e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return dy(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function A9e(t,e){return M.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 bb;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(bb||(bb={}));var Wj;(function(t){t.Optimized="optimized"})(Wj||(Wj={}));const U9=new Map;function N9e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=M.useState(null),{frequency:l,measure:c,strategy:u}=i,d=M.useRef(t),f=y(),g=gb(f),p=M.useCallback(function(b){b===void 0&&(b=[]),!g.current&&s(E=>E===null?b:E.concat(b.filter(w=>!E.includes(w))))},[g]),x=M.useRef(null),v=dy(b=>{if(f&&!n)return U9;if(!b||b===U9||d.current!==t||a!=null){const E=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){E.set(w.id,w.rect.current);continue}const T=w.node.current,A=T?new UL(c(T),T):null;w.rect.current=A,A&&E.set(w.id,A)}return E}return b},[t,a,n,f,c]);return M.useEffect(()=>{d.current=t},[t]),M.useEffect(()=>{f||p()},[n,f]),M.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),M.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,f,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:a!=null};function y(){switch(u){case bb.Always:return!1;case bb.BeforeDragging:return n;default:return!n}}}function Cte(t,e){return dy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function C9e(t,e){return Cte(t,e)}function k9e(t){let{callback:e,disabled:n}=t;const r=IL(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function EE(t){let{callback:e,disabled:n}=t;const r=IL(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function P9e(t){return new UL(Eg(t),t)}function z9(t,e,n){e===void 0&&(e=P9e);const[r,i]=M.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=k9e({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),l=EE({callback:a});return Al(()=>{a(),t?(l?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),s?.disconnect())},[t]),r}function j9e(t){const e=Cte(t);return _te(t,e)}const B9=[];function R9e(t){const e=M.useRef(t),n=dy(r=>t?r&&r!==B9&&t&&e.current&&t.parentNode===e.current.parentNode?r:wE(t):B9,[t]);return M.useEffect(()=>{e.current=t},[t]),n}function D9e(t){const[e,n]=M.useState(null),r=M.useRef(t),i=M.useCallback(a=>{const s=Mk(a.target);s&&n(l=>l?(l.set(s,Vj(s)),new Map(l)):null)},[]);return M.useEffect(()=>{const a=r.current;if(t!==a){s(a);const l=t.map(c=>{const u=Mk(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,Vj(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{s(t),s(a)};function s(l){l.forEach(c=>{const u=Mk(c);u?.removeEventListener("scroll",i)})}},[i,t]),M.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>yp(a,s),Vo):Ate(t):Vo,[t,e])}function H9(t,e){e===void 0&&(e=[]);const n=M.useRef(null);return M.useEffect(()=>{n.current=null},e),M.useEffect(()=>{const r=t!==Vo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?xb(t,n.current):Vo}function O9e(t){M.useEffect(()=>{if(!_E)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 L9e(t,e){return M.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function kte(t){return M.useMemo(()=>t?s9e(t):null,[t])}const $9=[];function I9e(t,e){e===void 0&&(e=Eg);const[n]=t,r=kte(n?cs(n):null),[i,a]=M.useState($9);function s(){a(()=>t.length?t.map(c=>Ete(c)?r:new UL(e(c),c)):$9)}const l=EE({callback:s});return Al(()=>{l?.disconnect(),s(),t.forEach(c=>l?.observe(c))},[t]),i}function F9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return uy(e)?e:t}function U9e(t){let{measure:e}=t;const[n,r]=M.useState(null),i=M.useCallback(u=>{for(const{target:d}of u)if(uy(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=EE({callback:i}),s=M.useCallback(u=>{const d=F9e(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=BS(s);return M.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const z9e=[{sensor:ME,options:{}},{sensor:SE,options:{}}],B9e={current:{}},P1={draggable:{measure:O9},droppable:{measure:O9,strategy:bb.WhileDragging,frequency:Wj.Optimized},dragOverlay:{measure:Eg}};class S0 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 H9e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new S0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:HS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:P1,measureDroppableContainers:HS,windowRect:null,measuringScheduled:!1},$9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:HS,draggableNodes:new Map,over:null,measureDroppableContainers:HS},TE=M.createContext($9e),Pte=M.createContext(H9e);function V9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new S0}}}function G9e(t,e){switch(e.type){case bi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case bi.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 bi.DragEnd:case bi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case bi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new S0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case bi.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 S0(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case bi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new S0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function W9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=M.useContext(TE),a=Hj(r),s=Hj(n?.id);return M.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!FL(a)||document.activeElement===a.target)return;const l=i.get(s);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=z7e(d);if(f){f.focus();break}}})}},[r,e,i,s,a]),null}function q9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function K9e(t){return M.useMemo(()=>({draggable:{...P1.draggable,...t?.draggable},droppable:{...P1.droppable,...t?.droppable},dragOverlay:{...P1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function X9e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=M.useRef(!1),{x:s,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Al(()=>{if(!s&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=_te(d,r);if(s||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=wte(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,s,l,r,n])}const jte=M.createContext({...Vo,scaleX:1,scaleY:1});var Wu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Wu||(Wu={}));const Rte=M.memo(function(e){var n,r,i,a;let{id:s,accessibility:l,autoScroll:c=!0,children:u,sensors:d=z9e,collisionDetection:f=J7e,measuring:g,modifiers:p,...x}=e;const v=M.useReducer(G9e,void 0,V9e),[y,b]=v,[E,w]=W7e(),[T,A]=M.useState(Wu.Uninitialized),C=T===Wu.Initialized,{draggable:{active:N,nodes:F,translate:k},droppable:{containers:R}}=y,I=N!=null?F.get(N):null,L=M.useRef({initial:null,translated:null}),q=M.useMemo(()=>{var He;return N!=null?{id:N,data:(He=I?.data)!=null?He:B9e,rect:L}:null},[N,I]),j=M.useRef(null),[V,K]=M.useState(null),[W,J]=M.useState(null),ee=gb(x,Object.values(x)),Z=hy("DndDescribedBy",s),B=M.useMemo(()=>R.getEnabled(),[R]),G=K9e(g),{droppableRects:Q,measureDroppableContainers:te,measuringScheduled:he}=N9e(B,{dragging:C,dependencies:[k.x,k.y],config:G.droppable}),oe=T9e(F,N),xe=M.useMemo(()=>W?$j(W):null,[W]),Te=ve(),me=C9e(oe,G.draggable.measure);X9e({activeNode:N!=null?F.get(N):null,config:Te.layoutShiftCompensation,initialRect:me,measure:G.draggable.measure});const ce=z9(oe,G.draggable.measure,me),Ce=z9(oe?oe.parentElement:null),fe=M.useRef({activatorEvent:null,active:null,activeNode:oe,collisionRect:null,collisions:null,droppableRects:Q,draggableNodes:F,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ie=R.getNodeFor((n=fe.current.over)==null?void 0:n.id),z=U9e({measure:G.dragOverlay.measure}),H=(r=z.nodeRef.current)!=null?r:oe,re=C?(i=z.rect)!=null?i:ce:null,$=!!(z.nodeRef.current&&z.rect),Y=j9e($?null:ce),se=kte(H?cs(H):null),ue=R9e(C?Ie??oe:null),Ee=I9e(ue),Me=q9e(p,{transform:{x:k.x-Y.x,y:k.y-Y.y,scaleX:1,scaleY:1},activatorEvent:W,active:q,activeNodeRect:ce,containerNodeRect:Ce,draggingNodeRect:re,over:fe.current.over,overlayNodeRect:z.rect,scrollableAncestors:ue,scrollableAncestorRects:Ee,windowRect:se}),U=xe?yp(xe,k):null,O=D9e(ue),ne=H9(O),be=H9(O,[ce]),ye=yp(Me,ne),_e=re?n9e(re,Me):null,We=q&&_e?f({active:q,collisionRect:_e,droppableRects:Q,droppableContainers:B,pointerCoordinates:U}):null,Ve=yte(We,"id"),[Ye,lt]=M.useState(null),de=$?Me:yp(Me,be),ae=e9e(de,(a=Ye?.rect)!=null?a:null,ce),ze=M.useRef(null),Ue=M.useCallback((He,je)=>{let{sensor:we,options:Xe}=je;if(j.current==null)return;const ot=F.get(j.current);if(!ot)return;const St=He.nativeEvent,Dt=new we({active:j.current,activeNode:ot,event:St,options:Xe,context:fe,onAbort(Ft){if(!F.get(Ft))return;const{onDragAbort:Nn}=ee.current,Lr={id:Ft};Nn?.(Lr),E({type:"onDragAbort",event:Lr})},onPending(Ft,kn,Nn,Lr){if(!F.get(Ft))return;const{onDragPending:br}=ee.current,Tr={id:Ft,constraint:kn,initialCoordinates:Nn,offset:Lr};br?.(Tr),E({type:"onDragPending",event:Tr})},onStart(Ft){const kn=j.current;if(kn==null)return;const Nn=F.get(kn);if(!Nn)return;const{onDragStart:Lr}=ee.current,Er={activatorEvent:St,active:{id:kn,data:Nn.data,rect:L}};wc.unstable_batchedUpdates(()=>{Lr?.(Er),A(Wu.Initializing),b({type:bi.DragStart,initialCoordinates:Ft,active:kn}),E({type:"onDragStart",event:Er}),K(ze.current),J(St)})},onMove(Ft){b({type:bi.DragMove,coordinates:Ft})},onEnd:qt(bi.DragEnd),onCancel:qt(bi.DragCancel)});ze.current=Dt;function qt(Ft){return async function(){const{active:Nn,collisions:Lr,over:Er,scrollAdjustedTranslate:br}=fe.current;let Tr=null;if(Nn&&br){const{cancelDrop:ei}=ee.current;Tr={activatorEvent:St,active:Nn,collisions:Lr,delta:br,over:Er},Ft===bi.DragEnd&&typeof ei=="function"&&await Promise.resolve(ei(Tr))&&(Ft=bi.DragCancel)}j.current=null,wc.unstable_batchedUpdates(()=>{b({type:Ft}),A(Wu.Uninitialized),lt(null),K(null),J(null),ze.current=null;const ei=Ft===bi.DragEnd?"onDragEnd":"onDragCancel";if(Tr){const Ar=ee.current[ei];Ar?.(Tr),E({type:ei,event:Tr})}})}}},[F]),et=M.useCallback((He,je)=>(we,Xe)=>{const ot=we.nativeEvent,St=F.get(Xe);if(j.current!==null||!St||ot.dndKit||ot.defaultPrevented)return;const Dt={active:St};He(we,je.options,Dt)===!0&&(ot.dndKit={capturedBy:je.sensor},j.current=Xe,Ue(we,je))},[F,Ue]),dt=A9e(d,et);O9e(d),Al(()=>{ce&&T===Wu.Initializing&&A(Wu.Initialized)},[ce,T]),M.useEffect(()=>{const{onDragMove:He}=ee.current,{active:je,activatorEvent:we,collisions:Xe,over:ot}=fe.current;if(!je||!we)return;const St={active:je,activatorEvent:we,collisions:Xe,delta:{x:ye.x,y:ye.y},over:ot};wc.unstable_batchedUpdates(()=>{He?.(St),E({type:"onDragMove",event:St})})},[ye.x,ye.y]),M.useEffect(()=>{const{active:He,activatorEvent:je,collisions:we,droppableContainers:Xe,scrollAdjustedTranslate:ot}=fe.current;if(!He||j.current==null||!je||!ot)return;const{onDragOver:St}=ee.current,Dt=Xe.get(Ve),qt=Dt&&Dt.rect.current?{id:Dt.id,rect:Dt.rect.current,data:Dt.data,disabled:Dt.disabled}:null,Ft={active:He,activatorEvent:je,collisions:we,delta:{x:ot.x,y:ot.y},over:qt};wc.unstable_batchedUpdates(()=>{lt(qt),St?.(Ft),E({type:"onDragOver",event:Ft})})},[Ve]),Al(()=>{fe.current={activatorEvent:W,active:q,activeNode:oe,collisionRect:_e,collisions:We,droppableRects:Q,draggableNodes:F,draggingNode:H,draggingNodeRect:re,droppableContainers:R,over:Ye,scrollableAncestors:ue,scrollAdjustedTranslate:ye},L.current={initial:re,translated:_e}},[q,oe,We,_e,F,H,re,Q,R,Ye,ue,ye]),S9e({...Te,delta:k,draggingRect:_e,pointerCoordinates:U,scrollableAncestors:ue,scrollableAncestorRects:Ee});const pe=M.useMemo(()=>({active:q,activeNode:oe,activeNodeRect:ce,activatorEvent:W,collisions:We,containerNodeRect:Ce,dragOverlay:z,draggableNodes:F,droppableContainers:R,droppableRects:Q,over:Ye,measureDroppableContainers:te,scrollableAncestors:ue,scrollableAncestorRects:Ee,measuringConfiguration:G,measuringScheduled:he,windowRect:se}),[q,oe,ce,W,We,Ce,z,F,R,Q,Ye,te,ue,Ee,G,he,se]),nt=M.useMemo(()=>({activatorEvent:W,activators:dt,active:q,activeNodeRect:ce,ariaDescribedById:{draggable:Z},dispatch:b,draggableNodes:F,over:Ye,measureDroppableContainers:te}),[W,dt,q,ce,b,Z,F,Ye,te]);return _r.createElement(pte.Provider,{value:w},_r.createElement(TE.Provider,{value:nt},_r.createElement(Pte.Provider,{value:pe},_r.createElement(jte.Provider,{value:ae},u)),_r.createElement(W9e,{disabled:l?.restoreFocus===!1})),_r.createElement(X7e,{...l,hiddenTextDescribedById:Z}));function ve(){const He=V?.autoScrollEnabled===!1,je=typeof c=="object"?c.enabled===!1:c===!1,we=C&&!He&&!je;return typeof c=="object"?{...c,enabled:we}:{enabled:we}}}),Y9e=M.createContext(null),V9="button",Z9e="Draggable";function Q9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=hy(Z9e),{activators:s,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=M.useContext(TE),{role:p=V9,roleDescription:x="draggable",tabIndex:v=0}=i??{},y=c?.id===e,b=M.useContext(y?jte:Y9e),[E,w]=BS(),[T,A]=BS(),C=L9e(s,e),N=gb(n);Al(()=>(f.set(e,{id:e,key:a,node:E,activatorNode:T,data:N}),()=>{const k=f.get(e);k&&k.key===a&&f.delete(e)}),[f,e]);const F=M.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":y&&p===V9?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,v,y,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:F,isDragging:y,listeners:r?void 0:C,node:E,over:g,setNodeRef:w,setActivatorNodeRef:A,transform:b}}function J9e(){return M.useContext(Pte)}const eGe="Droppable",tGe={timeout:25};function nGe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=hy(eGe),{active:s,dispatch:l,over:c,measureDroppableContainers:u}=M.useContext(TE),d=M.useRef({disabled:n}),f=M.useRef(!1),g=M.useRef(null),p=M.useRef(null),{disabled:x,updateMeasurementsFor:v,timeout:y}={...tGe,...i},b=gb(v??r),E=M.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(b.current)?b.current:[b.current]),p.current=null},y)},[y]),w=EE({callback:E,disabled:x||!s}),T=M.useCallback((F,k)=>{w&&(k&&(w.unobserve(k),f.current=!1),F&&w.observe(F))},[w]),[A,C]=BS(T),N=gb(e);return M.useEffect(()=>{!w||!A.current||(w.disconnect(),f.current=!1,w.observe(A.current))},[A,w]),M.useEffect(()=>(l({type:bi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:A,rect:g,data:N}}),()=>l({type:bi.UnregisterDroppable,key:a,id:r})),[r]),M.useEffect(()=>{n!==d.current.disabled&&(l({type:bi.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:s,rect:g,isOver:c?.id===r,node:A,over:c,setNodeRef:C}}function AE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function rGe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function n1(t){return t!==null&&t>=0}function iGe(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 aGe(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=AE(e,r,n),s=e[i],l=a[i];return!l||!s?null:{x:l.left-s.left,y:l.top-s.top,scaleX:l.width/s.width,scaleY:l.height/s.height}},r1={scaleX:1,scaleY:1},sGe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:s}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[s];return u?{x:0,y:n<s?u.top+u.height-(l.top+l.height):u.top-l.top,...r1}:null}const c=oGe(a,i,n);return i>n&&i<=s?{x:0,y:-l.height-c,...r1}:i<n&&i>=s?{x:0,y:l.height+c,...r1}:{x:0,y:0,...r1}};function oGe(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 Dte="Sortable",Ote=_r.createContext({activeIndex:-1,containerId:Dte,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:BL,disabled:{draggable:!1,droppable:!1}});function Lte(t){let{children:e,id:n,items:r,strategy:i=BL,disabled:a=!1}=t;const{active:s,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=J9e(),f=hy(Dte,n),g=l.rect!==null,p=M.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=s!=null,v=s?p.indexOf(s.id):-1,y=u?p.indexOf(u.id):-1,b=M.useRef(p),E=!iGe(p,b.current),w=y!==-1&&v===-1||E,T=aGe(a);Al(()=>{E&&x&&d(p)},[E,p,x,d]),M.useEffect(()=>{b.current=p},[p]);const A=M.useMemo(()=>({activeIndex:v,containerId:f,disabled:T,disableTransforms:w,items:p,overIndex:y,useDragOverlay:g,sortedRects:rGe(p,c),strategy:i}),[v,f,T.draggable,T.droppable,w,p,y,c,g,i]);return _r.createElement(Ote.Provider,{value:A},e)}const lGe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return AE(n,r,i).indexOf(e)},cGe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===s?!1:n?!0:s!==i&&e===c},uGe={duration:200,easing:"ease"},Ite="transform",dGe=Qp.Transition.toString({property:Ite,duration:0,easing:"linear"}),hGe={roleDescription:"sortable"};function fGe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=M.useState(null),l=M.useRef(n);return Al(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Eg(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!==l.current&&(l.current=n)},[e,n,r,i]),M.useEffect(()=>{a&&s(null)},[a]),a}function Fte(t){let{animateLayoutChanges:e=cGe,attributes:n,disabled:r,data:i,getNewIndex:a=lGe,id:s,strategy:l,resizeObserverConfig:c,transition:u=uGe}=t;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:x,sortedRects:v,overIndex:y,useDragOverlay:b,strategy:E}=M.useContext(Ote),w=mGe(r,p),T=d.indexOf(s),A=M.useMemo(()=>({sortable:{containerId:f,index:T,items:d},...i}),[f,i,T,d]),C=M.useMemo(()=>d.slice(d.indexOf(s)),[d,s]),{rect:N,node:F,isOver:k,setNodeRef:R}=nGe({id:s,data:A,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:I,activatorEvent:L,activeNodeRect:q,attributes:j,setNodeRef:V,listeners:K,isDragging:W,over:J,setActivatorNodeRef:ee,transform:Z}=Q9e({id:s,data:A,attributes:{...hGe,...n},disabled:w.draggable}),B=L7e(R,V),G=!!I,Q=G&&!x&&n1(g)&&n1(y),te=!b&&W,he=te&&Q?Z:null,xe=Q?he??(l??E)({rects:v,activeNodeRect:q,activeIndex:g,overIndex:y,index:T}):null,Te=n1(g)&&n1(y)?a({id:s,items:d,activeIndex:g,overIndex:y}):T,me=I?.id,ce=M.useRef({activeId:me,items:d,newIndex:Te,containerId:f}),Ce=d!==ce.current.items,fe=e({active:I,containerId:f,isDragging:W,isSorting:G,id:s,index:T,items:d,newIndex:ce.current.newIndex,previousItems:ce.current.items,previousContainerId:ce.current.containerId,transition:u,wasDragging:ce.current.activeId!=null}),Ie=fGe({disabled:!fe,index:T,node:F,rect:N});return M.useEffect(()=>{G&&ce.current.newIndex!==Te&&(ce.current.newIndex=Te),f!==ce.current.containerId&&(ce.current.containerId=f),d!==ce.current.items&&(ce.current.items=d)},[G,Te,f,d]),M.useEffect(()=>{if(me===ce.current.activeId)return;if(me!=null&&ce.current.activeId==null){ce.current.activeId=me;return}const H=setTimeout(()=>{ce.current.activeId=me},50);return()=>clearTimeout(H)},[me]),{active:I,activeIndex:g,attributes:j,data:A,rect:N,index:T,newIndex:Te,items:d,isOver:k,isSorting:G,isDragging:W,listeners:K,node:F,overIndex:y,over:J,setNodeRef:B,setActivatorNodeRef:ee,setDroppableNodeRef:R,setDraggableNodeRef:V,transform:Ie??xe,transition:z()};function z(){if(Ie||Ce&&ce.current.newIndex===T)return dGe;if(!(te&&!FL(L)||!u)&&(G||fe))return Qp.Transition.toString({...u,property:Ite})}}function mGe(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 GS(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 pGe=[An.Down,An.Right,An.Up,An.Left],Ute=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:l}}=e;if(pGe.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 An.Down:r.top<g.top&&c.push(f);break;case An.Up:r.top>g.top&&c.push(f);break;case An.Left:r.left>g.left&&c.push(f);break;case An.Right:r.left<g.left&&c.push(f);break}});const u=Z7e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=yte(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),p=g?i.get(g.id):null,x=g?.node.current;if(x&&p&&f&&g){const y=wE(x).some((C,N)=>l[N]!==C),b=zte(f,g),E=gGe(f,g),w=y||!b?{x:0,y:0}:{x:E?r.width-p.width:0,y:E?r.height-p.height:0},T={x:p.left,y:p.top};return w.x&&w.y?T:xb(T,w)}}}};function zte(t,e){return!GS(t)||!GS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function gGe(t,e){return!GS(t)||!GS(e)||!zte(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function xGe({item:t,onClose:e}){const n=mn(),{showToast:r}=Sr(),[i,a]=M.useState(t.printer_id),s=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[l,c]=M.useState(t.scheduled_time&&!s?"scheduled":"asap"),[u,d]=M.useState(()=>t.scheduled_time&&!s?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=M.useState(t.require_previous_success),[p,x]=M.useState(t.auto_off_after),{data:v}=gt({queryKey:["printers"],queryFn:()=>Se.getPrinters()});M.useEffect(()=>{const w=T=>{T.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const y=vt({mutationFn:w=>Se.updateQueueItem(t.id,w),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:w=>{r(w.message||"Failed to update queue item","error")}}),b=w=>{w.preventDefault();const T={printer_id:i,require_previous_success:f,auto_off_after:p};l==="scheduled"&&u?T.scheduled_time=new Date(u).toISOString():T.scheduled_time=null,y.mutate(T)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:o.jsx(wt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:o.jsxs(Et,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Uc,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),o.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[o.jsx(mo,{className:"w-4 h-4"}),"No printers configured"]}):o.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:w=>a(Number(w.target.value)),required:!0,children:v?.map(w=>o.jsx("option",{value:w.id,children:w.name},w.id))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),o.jsxs("div",{className:"flex gap-2",children:[o.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 ${l==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[o.jsx(rr,{className:"w-4 h-4"}),"ASAP (when idle)"]}),o.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 ${l==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[o.jsx(Qr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),l==="scheduled"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),o.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:w=>d(w.target.value),min:E(),required:!0})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[o.jsx(kl,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:l==="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."}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",disabled:y.isPending||v?.length===0,children:y.isPending?"Saving...":"Save Changes"})]})]})]})})})}function Bte(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 bGe(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 yGe({status:t}){const e={pending:{icon:rr,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:Mp,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Cr,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:Pa,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:B1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Gt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return o.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[o.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function Ak({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:s}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=Fte({id:t.id,disabled:t.status!=="pending"}),p={transform:Qp.Transform.toString(d),transition:f},x=t.status==="printing",v=t.status==="pending",y=["completed","failed","skipped","cancelled"].includes(t.status);return o.jsx("div",{ref:u,style:p,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:o.jsxs("div",{className:"flex items-center gap-4 p-4",children:[v?o.jsx("div",{...l,...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:o.jsx(P0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?o.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]}):o.jsx("div",{className:"w-8"}),o.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?o.jsx("img",{src:Se.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:o.jsx(pd,{className:"w-6 h-6"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),o.jsx(_c,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:o.jsx(ba,{className:"w-3.5 h-3.5"})})]}),o.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Vi,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Zu,{className:"w-3.5 h-3.5"}),Bte(t.print_time_seconds)]}),v&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(rr,{className:"w-3.5 h-3.5"}),bGe(t.scheduled_time)]})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&o.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&&o.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:[o.jsx(kl,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&o.jsxs("div",{className:"mt-3",children:[o.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&o.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[o.jsx(mo,{className:"w-3 h-3"}),t.error_message]})]}),o.jsx(yGe,{status:t.status}),o.jsxs("div",{className:"flex items-center gap-1",children:[x&&o.jsx(ke,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:o.jsx(ile,{className:"w-4 h-4"})}),v&&o.jsxs(o.Fragment,{children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:o.jsx(Uc,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:o.jsx(Gt,{className:"w-4 h-4"})})]}),y&&o.jsxs(o.Fragment,{children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:s,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:o.jsx(_a,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:o.jsx(En,{className:"w-4 h-4"})})]})]})]})})}function vGe(){const t=mn(),{showToast:e}=Sr(),[n,r]=M.useState(null),[i,a]=M.useState(""),[s,l]=M.useState(!1),[c,u]=M.useState(null),[d,f]=M.useState(null),[g,p]=M.useState(null),[x,v]=M.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[y,b]=M.useState(()=>{const Z=localStorage.getItem("queue.historySortAsc");return Z!==null?Z==="true":!1}),[E,w]=M.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[T,A]=M.useState(()=>{const Z=localStorage.getItem("queue.pendingSortAsc");return Z!==null?Z==="true":!0});M.useEffect(()=>{localStorage.setItem("queue.historySortBy",x)},[x]),M.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(y))},[y]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",E)},[E]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(T))},[T]);const C=gte($S(ME,{activationConstraint:{distance:8}}),$S(SE,{coordinateGetter:Ute})),{data:N,isLoading:F}=gt({queryKey:["queue",n,i],queryFn:()=>Se.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:k}=gt({queryKey:["printers"],queryFn:()=>Se.getPrinters()}),R=vt({mutationFn:Z=>Se.cancelQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),I=vt({mutationFn:Z=>Se.removeFromQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),L=vt({mutationFn:Z=>Se.stopQueueItem(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),q=vt({mutationFn:Z=>Se.reorderQueue(Z),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),j=vt({mutationFn:async()=>{const Z=N?.filter(B=>["completed","failed","skipped","cancelled"].includes(B.status))||[];for(const B of Z)await Se.removeFromQueue(B.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")}),V=M.useMemo(()=>{const Z=N?.filter(G=>G.status==="pending")||[],B=G=>{if(!G.scheduled_time)return 0;const Q=new Date(G.scheduled_time).getTime(),te=Date.now()+4320*60*60*1e3;return Q>te?0:Q};return[...Z].sort((G,Q)=>{let te;return E==="name"?te=(G.archive_name||"").localeCompare(Q.archive_name||""):E==="printer"?te=(G.printer_name||"").localeCompare(Q.printer_name||""):E==="time"?te=B(G)-B(Q):te=G.position-Q.position,T?te:-te})},[N,E,T]),K=N?.filter(Z=>Z.status==="printing")||[],W=M.useMemo(()=>[...N?.filter(B=>["completed","failed","skipped","cancelled"].includes(B.status))||[]].sort((B,G)=>{let Q;return x==="name"?Q=(B.archive_name||"").localeCompare(G.archive_name||""):x==="printer"?Q=(B.printer_name||"").localeCompare(G.printer_name||""):Q=new Date(G.completed_at||G.created_at).getTime()-new Date(B.completed_at||B.created_at).getTime(),y?-Q:Q}),[N,x,y]),J=M.useMemo(()=>V.reduce((Z,B)=>Z+(B.print_time_seconds||0),0),[V]),ee=Z=>{const{active:B,over:G}=Z;if(!G||B.id===G.id)return;const Q=V.findIndex(he=>he.id===B.id),te=V.findIndex(he=>he.id===G.id);if(Q!==-1&&te!==-1){const oe=AE(V,Q,te).map((xe,Te)=>({id:xe.id,position:Te+1}));q.mutate(oe)}};return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsx("div",{className:"flex items-center justify-between mb-8",children:o.jsxs("div",{children:[o.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[o.jsx(IG,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),o.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[o.jsx(wt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:o.jsx(Et,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:o.jsx(Mp,{className:"w-5 h-5 text-blue-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),o.jsx(wt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:o.jsx(Et,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:o.jsx(rr,{className:"w-5 h-5 text-yellow-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:V.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),o.jsx(wt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:o.jsx(Et,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:o.jsx(Zu,{className:"w-5 h-5 text-bambu-green"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:Bte(J)}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),o.jsx(wt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:o.jsx(Et,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:o.jsx(Cr,{className:"w-5 h-5 text-gray-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),o.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[o.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:[o.jsx("option",{value:"",children:"All Printers"}),k?.map(Z=>o.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),o.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:[o.jsx("option",{value:"",children:"All Status"}),o.jsx("option",{value:"pending",children:"Pending"}),o.jsx("option",{value:"printing",children:"Printing"}),o.jsx("option",{value:"completed",children:"Completed"}),o.jsx("option",{value:"failed",children:"Failed"}),o.jsx("option",{value:"skipped",children:"Skipped"}),o.jsx("option",{value:"cancelled",children:"Cancelled"})]}),o.jsx("div",{className:"flex-1"}),W.length>0&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[o.jsx(En,{className:"w-4 h-4"}),"Clear History"]})]}),F?o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):N?.length===0?o.jsxs(wt,{className:"p-12 text-center border-dashed",children:[o.jsx(Qr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),o.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),o.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.'})]}):o.jsxs("div",{className:"space-y-8",children:[K.length>0&&o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),o.jsx("div",{className:"space-y-3",children:K.map(Z=>o.jsx(Ak,{item:Z,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:Z}),onRequeue:()=>{}},Z.id))})]}),V.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(rr,{className:"w-5 h-5 text-yellow-400"}),"Queued",o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",V.length," item",V.length!==1?"s":"",")"]}),o.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)"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:E,onChange:Z=>w(Z.target.value),children:[o.jsx("option",{value:"position",children:"Sort by Position"}),o.jsx("option",{value:"name",children:"Sort by Name"}),o.jsx("option",{value:"printer",children:"Sort by Printer"}),o.jsx("option",{value:"time",children:"Sort by Schedule"})]}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>A(!T),title:T?"Ascending":"Descending",className:"px-2",children:T?o.jsx(vp,{className:"w-4 h-4"}):o.jsx(N0,{className:"w-4 h-4"})})]})]}),o.jsx(Rte,{sensors:C,collisionDetection:vte,onDragEnd:ee,children:o.jsx(Lte,{items:V.map(Z=>Z.id),strategy:sGe,children:o.jsx("div",{className:"space-y-3",children:V.map((Z,B)=>o.jsx(Ak,{item:Z,position:B+1,onEdit:()=>u(Z),onCancel:()=>p({type:"cancel",item:Z}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Z.id))})})})]}),W.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Cr,{className:"w-5 h-5 text-bambu-gray"}),"History",o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.length," item",W.length!==1?"s":"",")"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:x,onChange:Z=>v(Z.target.value),children:[o.jsx("option",{value:"date",children:"Sort by Date"}),o.jsx("option",{value:"name",children:"Sort by Name"}),o.jsx("option",{value:"printer",children:"Sort by Printer"})]}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>b(!y),title:y?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:y?o.jsx(vp,{className:"w-4 h-4"}):o.jsx(N0,{className:"w-4 h-4"})})]})]}),o.jsx("div",{className:"space-y-3",children:W.slice(0,20).map((Z,B)=>o.jsx(Ak,{item:Z,position:B+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:Z}),onStop:()=>{},onRequeue:()=>f(Z)},Z.id))})]})]}),c&&o.jsx(xGe,{item:c,onClose:()=>u(null)}),d&&o.jsx(hte,{archiveId:d.archive_id,archiveName:d.archive_name||`Archive #${d.archive_id}`,onClose:()=>f(null)}),g&&o.jsx(kr,{title:g.type==="cancel"?"Cancel Scheduled Print":g.type==="stop"?"Stop Print":"Remove from History",message:g.type==="cancel"?`Are you sure you want to cancel "${g.item.archive_name||"this print"}"?`:g.type==="stop"?`Are you sure you want to stop the current print "${g.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${g.item.archive_name||"this item"}" from the queue history?`,confirmText:g.type==="cancel"?"Cancel Print":g.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{g.type==="cancel"?R.mutate(g.item.id):g.type==="stop"?L.mutate(g.item.id):I.mutate(g.item.id),p(null)},onCancel:()=>p(null)}),s&&o.jsx(kr,{title:"Clear History",message:`Are you sure you want to remove all ${W.length} item${W.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{j.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function _Ge({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=M.useMemo(()=>{const c={};t.forEach(b=>{const E=b.split("T")[0];c[E]=(c[E]||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 p=[],x=-1;const v=new Date(d);let y=0;for(;v<=u;)v.getDay()===0&&p.length>0&&(f.push(p),p=[],y++),v.getMonth()!==x&&(g.push({month:v.toLocaleDateString("en-US",{month:"short"}),weekIndex:y}),x=v.getMonth()),p.push(new Date(v)),v.setDate(v.getDate()+1);return p.length>0&&f.push(p),{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"},l=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return o.jsxs("div",{className:"overflow-x-auto",children:[o.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:c,weekIndex:u},d)=>o.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))}),o.jsxs("div",{className:"flex gap-0.5",children:[o.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:l.map((c,u)=>o.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)=>o.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=c.find(v=>v.getDay()===d);if(!f)return o.jsx("div",{className:"w-3 h-3"},d);const g=f.toISOString().split("T")[0],p=i[g]||0,x=g===new Date().toISOString().split("T")[0];return o.jsx("div",{className:`w-3 h-3 rounded-sm ${s(p)} ${x?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${p} print${p!==1?"s":""}`},d)})},u))]}),o.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[o.jsx("span",{children:"Less"}),o.jsxs("div",{className:"flex gap-0.5",children:[o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),o.jsx("span",{children:"More"})]})]})}const i1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function wGe(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 SGe({archives:t,currency:e="$"}){const[n,r]=M.useState("30d"),i=M.useMemo(()=>{const g=wGe(n);return t.filter(p=>new Date(p.completed_at||p.created_at)>=g)},[t,n]),a=M.useMemo(()=>{const g=new Map;return i.forEach(p=>{const v=new Date(p.completed_at||p.created_at).toISOString().split("T")[0],y=g.get(v)||{date:v,filament:0,cost:0,prints:0};y.filament+=p.filament_used_grams||0,y.cost+=p.cost||0,y.prints+=1,g.set(v,y)}),Array.from(g.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),s=M.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(p=>{const x=new Date(p.completed_at||p.created_at),v=new Date(x);v.setDate(x.getDate()-x.getDay());const y=v.toISOString().split("T")[0],b=g.get(y)||{week:y,filament:0,cost:0,prints:0};b.filament+=p.filament_used_grams||0,b.cost+=p.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=M.useMemo(()=>{const g=new Map;return i.forEach(p=>{const v=(p.filament_type||"Unknown").split(", ");v.forEach(y=>{const b=(p.filament_used_grams||0)/v.length;g.set(y,(g.get(y)||0)+b)})}),Array.from(g.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=M.useMemo(()=>{const g=new Date,p=[];for(let x=5;x>=0;x--){const v=new Date(g.getFullYear(),g.getMonth()-x,1),y=new Date(g.getFullYear(),g.getMonth()-x+1,0),b=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(w=>{const T=new Date(w.completed_at||w.created_at);return T>=v&&T<=y});p.push({month:b,filament:Math.round(E.reduce((w,T)=>w+(T.filament_used_grams||0),0)),cost:E.reduce((w,T)=>w+(T.cost||0),0),prints:E.length})}return p},[t]),u=n==="7d"||n==="30d"?a:s,d=i.reduce((g,p)=>g+(p.filament_used_grams||0),0),f=i.reduce((g,p)=>g+(p.cost||0),0);return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),o.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>o.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))})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),o.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),o.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),o.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),o.jsx(f1,{width:"100%",height:250,children:o.jsxs(INe,{data:u,children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),o.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),o.jsx(Dw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),o.jsx(Lw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),o.jsx(Iw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),o.jsx(p1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),o.jsx(KY,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):o.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(f1,{width:160,height:160,children:o.jsxs(ONe,{children:[o.jsx(bY,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((g,p)=>o.jsx(Jb,{fill:i1[p%i1.length]},`cell-${p}`))}),o.jsx(p1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),o.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((g,p)=>{const x=l.reduce((y,b)=>y+b.value,0),v=x>0?(g.value/x*100).toFixed(0):0;return o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:i1[p%i1.length]}}),o.jsx("span",{className:"text-white truncate flex-1",children:g.name}),o.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},g.name)})})]}):o.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),o.jsx(f1,{width:"100%",height:200,children:o.jsxs(SNe,{data:c,children:[o.jsx(Dw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),o.jsx(Lw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),o.jsx(Iw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),o.jsx(p1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,p)=>[p==="filament"?`${g}g`:p==="cost"?`${e}${g.toFixed(2)}`:g,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),o.jsx(GR,{}),o.jsx(MY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function MGe({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:s}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=Fte({id:t}),p={transform:Qp.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:o.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:o.jsx(P0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),o.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.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?o.jsx(Hce,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):o.jsx(Dce,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),o.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:o.jsx(YS,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),o.jsx("div",{className:"p-4",children:n})]})}function EGe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const s=()=>{const T={};return t.forEach(A=>{T[A.id]=A.defaultSize||4}),T},[l,c]=M.useState(()=>{const T=localStorage.getItem(e);if(T)try{const A=JSON.parse(T);return A.sizes||(A.sizes=s()),A}catch{}return{order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:s()}}),[u,d]=M.useState(!1);M.useEffect(()=>{const T=()=>d(A=>!A);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),M.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),M.useEffect(()=>{const A=t.map(C=>C.id).filter(C=>!l.order.includes(C));A.length>0&&c(C=>({...C,order:[...C.order,...A]}))},[t,l.order]);const f=gte($S(ME,{activationConstraint:{distance:8}}),$S(SE,{coordinateGetter:Ute})),g=T=>{const{active:A,over:C}=T;C&&A.id!==C.id&&c(N=>{const F=N.order.indexOf(A.id),k=N.order.indexOf(C.id);return{...N,order:AE(N.order,F,k)}})},p=T=>{c(A=>({...A,hidden:A.hidden.includes(T)?A.hidden.filter(C=>C!==T):[...A.hidden,T]}))},x=T=>{c(A=>{const C=A.sizes[T]||4,N=C===1?2:C===2?4:1;return{...A,sizes:{...A.sizes,[T]:N}}})},v=()=>{const T={order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:s()};c(T),i?.()},y=l.order.map(T=>t.find(A=>A.id===T)).filter(Boolean),b=y.filter(T=>!l.hidden.includes(T.id)),E=y.filter(T=>l.hidden.includes(T.id)),w=a?.({hiddenCount:E.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:v});return o.jsxs("div",{className:"space-y-4",children:[w,!r&&!a&&o.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:v,children:[o.jsx(ig,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[o.jsx(Zh,{className:"w-4 h-4"}),E.length," Hidden"]})]}),u&&E.length>0&&o.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(T=>o.jsxs("button",{onClick:()=>p(T.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:[o.jsx(Zh,{className:"w-3 h-3"}),T.title]},T.id))})]}),o.jsx(Rte,{sensors:f,collisionDetection:vte,onDragEnd:g,children:o.jsx(Lte,{items:b.map(T=>T.id),strategy:BL,children:o.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(T=>o.jsx(MGe,{id:T.id,title:T.title,isHidden:l.hidden.includes(T.id),size:l.sizes[T.id]||2,onToggleVisibility:()=>p(T.id),onToggleSize:()=>x(T.id),children:T.component},T.id))})})}),b.length===0&&o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx("p",{children:"All widgets are hidden."}),o.jsx(ke,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function TGe({stats:t,currency:e}){return o.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:o.jsx(Fc,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),o.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:o.jsx(rr,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:o.jsx(Fc,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:o.jsx(qk,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:o.jsx(ef,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:o.jsx(qk,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function AGe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return o.jsxs("div",{className:"flex items-center gap-6",children:[o.jsxs("div",{className:"relative w-28 h-28",children:[o.jsxs("svg",{className:"w-full h-full -rotate-90",children:[o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Cr,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),o.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400"}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),o.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function NGe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return o.jsx("div",{className:"flex items-center justify-center h-full",children:o.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),l=n-100;return o.jsxs("div",{className:"flex items-center gap-6",children:[o.jsxs("div",{className:"relative w-28 h-28",children:[o.jsxs("svg",{className:"w-full h-full -rotate-90",children:[o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),o.jsxs("span",{className:`text-xs ${l>=0?"text-blue-400":"text-orange-400"}`,children:[l>=0?"+":"",l.toFixed(0),"%"]})]})]}),o.jsxs("div",{className:"space-y-2 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[o.jsx(BG,{className:"w-3 h-3"}),o.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&o.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([c,u])=>o.jsxs("div",{className:"flex items-center justify-between text-xs",children:[o.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(c)||`Printer ${c}`}),o.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 CGe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return o.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 o.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[o.jsx("span",{className:"text-white",children:n}),o.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),o.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:o.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function kGe({printDates:t}){return o.jsx(_Ge,{printDates:t,months:4})}function PGe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?o.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[o.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:o.jsx(Vi,{className:"w-4 h-4 text-bambu-green"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function jGe({archives:t,currency:e}){return!t||t.length===0?o.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):o.jsx(SGe,{archives:t,currency:e})}function RGe(){const{data:t,isLoading:e}=gt({queryKey:["failureAnalysis"],queryFn:()=>Se.getFailureAnalysis({days:30})});if(e)return o.jsx("div",{className:"flex justify-center py-4",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!t||t.total_prints===0)return o.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 o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Gn,{className:`w-5 h-5 ${t.failure_rate>20?"text-red-400":t.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),o.jsxs("span",{className:"text-2xl font-bold text-white",children:[t.failure_rate.toFixed(1),"%"]}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"failure rate"})]}),o.jsxs("div",{className:"text-sm text-bambu-gray",children:[t.failed_prints," / ",t.total_prints," prints failed"]})]}),n.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray font-medium",children:"Top Failure Reasons"}),n.map(([r,i])=>o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-white truncate max-w-[200px]",children:r||"Unknown"}),o.jsx("span",{className:"text-bambu-gray",children:i})]},r))]}),t.trend&&t.trend.length>=2&&o.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx($G,{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"}`}),o.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",t.trend[t.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]})}function DGe(){const{showToast:t}=Sr(),[e,n]=M.useState(!1),[r,i]=M.useState(!1),[a,s]=M.useState(0),[l,c]=M.useState(0);M.useEffect(()=>{const w=()=>{try{const A=localStorage.getItem("bambusy-dashboard-layout");if(A){const C=JSON.parse(A);c(C.hidden?.length||0)}}catch{c(0)}};w(),window.addEventListener("storage",w);const T=setInterval(w,500);return()=>{window.removeEventListener("storage",w),clearInterval(T)}},[a]);const{data:u,isLoading:d}=gt({queryKey:["archiveStats"],queryFn:Se.getArchiveStats}),{data:f}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:g}=gt({queryKey:["archives"],queryFn:()=>Se.getArchives(void 0,void 0,1e3,0)}),{data:p}=gt({queryKey:["settings"],queryFn:Se.getSettings}),x=async w=>{i(!1),n(!0);try{const{blob:T,filename:A}=await Se.exportStats({format:w,days:90}),C=URL.createObjectURL(T),N=document.createElement("a");N.href=C,N.download=A,N.click(),URL.revokeObjectURL(C),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},v=p?.currency||"$",y=new Map(f?.map(w=>[String(w.id),w.name])||[]),b=g?.map(w=>w.created_at)||[];if(d)return o.jsx("div",{className:"p-4 md:p-8",children:o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:o.jsx(TGe,{stats:u,currency:v}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:o.jsx(AGe,{stats:u}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:o.jsx(NGe,{stats:u,printerMap:y}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:o.jsx(CGe,{stats:u}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:o.jsx(RGe,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:o.jsx(kGe,{printDates:b}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:o.jsx(PGe,{stats:u,printerMap:y}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:o.jsx(jGe,{archives:g||[],currency:v}),defaultSize:4}];return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"flex items-center justify-between mb-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),o.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&o.jsxs(ke,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[o.jsx(Zh,{className:"w-4 h-4"}),l," Hidden"]}),o.jsxs(ke,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),s(w=>w+1),t("Layout reset")},children:[o.jsx(ig,{className:"w-4 h-4"}),"Reset Layout"]}),o.jsxs("div",{className:"relative",children:[o.jsxs(ke,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(F1,{className:"w-4 h-4"}),"Export Stats"]}),r&&o.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:[o.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[o.jsx(Es,{className:"w-4 h-4"}),"Export as CSV"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[o.jsx(F1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),o.jsx(EGe,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function OGe({plug:t,onEdit:e}){const n=mn(),[r,i]=M.useState(!1),[a,s]=M.useState(!1),[l,c]=M.useState(!1),[u,d]=M.useState(!1),{data:f,isLoading:g,refetch:p}=gt({queryKey:["smart-plug-status",t.id],queryFn:()=>Se.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),v=x?.find(C=>C.id===t.printer_id),y=vt({mutationFn:C=>Se.controlSmartPlug(t.id,C),onSuccess:()=>{p()}}),b=vt({mutationFn:C=>Se.updateSmartPlug(t.id,C),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=vt({mutationFn:()=>Se.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",T=f?.reachable??!1,A=y.isPending;return o.jsxs(o.Fragment,{children:[o.jsx(wt,{className:"relative",children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("div",{className:"flex items-start justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg ${T?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:o.jsx(lo,{className:`w-5 h-5 ${T?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),o.jsxs("div",{children:[o.jsx("h3",{className:"font-medium text-white",children:t.name}),o.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),o.jsx("div",{className:"flex items-center gap-2",children:g?o.jsx(xt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):T?o.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[o.jsx(bR,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):o.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[o.jsx(Ab,{className:"w-4 h-4"}),o.jsx("span",{children:"Offline"})]})})]}),v&&o.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),o.jsx("span",{className:"text-sm text-white",children:v.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&o.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&o.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:[o.jsx(jh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&o.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:[o.jsx(Qr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),o.jsxs("div",{className:"flex gap-2 mb-3",children:[o.jsxs(ke,{size:"sm",variant:w?"primary":"secondary",disabled:!T||A,onClick:()=>s(!0),className:"flex-1",children:[A?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(kl,{className:"w-4 h-4"}),"On"]}),o.jsxs(ke,{size:"sm",variant:w?"secondary":"primary",disabled:!T||A,onClick:()=>c(!0),className:"flex-1",children:[A?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(JS,{className:"w-4 h-4"}),"Off"]})]}),o.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:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(eM,{className:"w-4 h-4"}),"Automation Settings"]}),o.jsx("span",{children:u?"-":"+"})]}),u&&o.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(QS,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:C=>b.mutate({show_in_switchbar:C.target.checked}),className:"sr-only peer"}),o.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"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Enabled"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.enabled,onChange:C=>b.mutate({enabled:C.target.checked}),className:"sr-only peer"}),o.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"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Auto On"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:C=>b.mutate({auto_on:C.target.checked}),className:"sr-only peer"}),o.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"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:C=>b.mutate({auto_off:C.target.checked}),className:"sr-only peer"}),o.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&&o.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{onClick:()=>b.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:[o.jsx(rr,{className:"w-4 h-4"}),"Time"]}),o.jsxs("button",{onClick:()=>b.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:[o.jsx(tM,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),o.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:C=>b.mutate({off_delay_minutes:parseInt(C.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"})]}):o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),o.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:C=>b.mutate({off_temp_threshold:parseInt(C.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"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),o.jsxs("div",{className:"flex gap-2 pt-2",children:[o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[o.jsx(pR,{className:"w-4 h-4"}),"Edit"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:o.jsx(En,{className:"w-4 h-4"})})]})]})]})}),r&&o.jsx(kr,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(),i(!1)},onCancel:()=>i(!1)}),a&&o.jsx(kr,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{y.mutate("on"),s(!1)},onCancel:()=>s(!1)}),l&&o.jsx(kr,{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:()=>{y.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function LGe({plug:t,onClose:e}){const n=mn(),r=!!t,[i,a]=M.useState(t?.name||""),[s,l]=M.useState(t?.ip_address||""),[c,u]=M.useState(t?.username||""),[d,f]=M.useState(t?.password||""),[g,p]=M.useState(t?.printer_id||null),[x,v]=M.useState(null),[y,b]=M.useState(null),[E,w]=M.useState(t?.power_alert_enabled||!1),[T,A]=M.useState(t?.power_alert_high?.toString()||""),[C,N]=M.useState(t?.power_alert_low?.toString()||""),[F,k]=M.useState(t?.schedule_enabled||!1),[R,I]=M.useState(t?.schedule_on_time||""),[L,q]=M.useState(t?.schedule_off_time||""),[j,V]=M.useState(t?.show_in_switchbar||!1),[K,W]=M.useState(!1),[J,ee]=M.useState({scanned:0,total:0}),[Z,B]=M.useState([]),G=M.useRef(null),{data:Q}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:te}=gt({queryKey:["smart-plugs"],queryFn:Se.getSmartPlugs});M.useEffect(()=>{const z=H=>{H.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>{window.removeEventListener("keydown",z),G.current&&clearInterval(G.current)}},[e]);const he=async()=>{W(!0),B([]),ee({scanned:0,total:0}),b(null);try{await Se.startTasmotaScan();const z=async()=>{try{const H=await Se.getTasmotaScanStatus();ee({scanned:H.scanned,total:H.total});const re=await Se.getDiscoveredTasmotaDevices();B(re),H.running||(W(!1),G.current&&(clearInterval(G.current),G.current=null))}catch(H){console.error("Polling error:",H)}};await z(),G.current=setInterval(z,500)}catch(z){W(!1);const H=z instanceof Error?z.message:typeof z=="string"?z:JSON.stringify(z);b(H||"Failed to start scan")}},oe=async()=>{try{await Se.stopTasmotaScan()}catch{}W(!1),G.current&&(clearInterval(G.current),G.current=null)},xe=z=>{l(z.ip_address),a(z.name),v(null)},Te=vt({mutationFn:()=>Se.testSmartPlugConnection(s,c||null,d||null),onSuccess:z=>{v(z),b(null),!i&&z.device_name&&a(z.device_name)},onError:z=>{v(null),b(z.message)}}),me=vt({mutationFn:z=>Se.createSmartPlug(z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{b(z.message)}}),ce=vt({mutationFn:z=>Se.updateSmartPlug(t.id,z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{b(z.message)}}),Ce=Q?.filter(z=>!te?.some(re=>re.printer_id===z.id&&re.id!==t?.id)),fe=z=>{if(z.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!s.trim()){b("IP address is required");return}const H={name:i.trim(),ip_address:s.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:T?parseFloat(T):null,power_alert_low:C?parseFloat(C):null,schedule_enabled:F,schedule_on_time:R||null,schedule_off_time:L||null,show_in_switchbar:j};r?ce.mutate(H):me.mutate(H)},Ie=me.isPending||ce.isPending;return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:o.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:z=>z.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:fe,className:"p-6 space-y-4 overflow-y-auto",children:[y&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:y}),!r&&o.jsxs("div",{className:"space-y-3",children:[K?o.jsxs(ke,{type:"button",variant:"secondary",onClick:oe,className:"w-full",children:[o.jsx(Gt,{className:"w-4 h-4"}),"Stop Scanning"]}):o.jsxs(ke,{type:"button",variant:"primary",onClick:he,className:"w-full",children:[o.jsx(bl,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),K&&J.total>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[o.jsx("span",{children:"Scanning network..."}),o.jsxs("span",{children:[J.scanned," / ",J.total]})]}),o.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:o.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${J.scanned/J.total*100}%`}})})]}),Z.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Z.length," device(s) - click to select:"]}),o.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Z.map(z=>o.jsxs("button",{type:"button",onClick:()=>xe(z),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(lo,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:z.name}),o.jsx("p",{className:"text-xs text-bambu-gray",children:z.ip_address})]})]}),z.state&&o.jsxs("span",{className:`flex items-center gap-1 text-xs ${z.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[o.jsx(kl,{className:"w-3 h-3"}),z.state]})]},z.ip_address))})]}),!K&&Z.length===0&&J.total>0&&o.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:s,onChange:z=>{l(z.target.value),v(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"}),o.jsxs(ke,{type:"button",variant:"secondary",onClick:()=>Te.mutate(),disabled:!s.trim()||Te.isPending,children:[Te.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(bR,{className:"w-4 h-4"}),"Test"]})]})]}),x&&o.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?o.jsxs(o.Fragment,{children:[o.jsx(Cr,{className:"w-5 h-5"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:"Connected!"}),o.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ab,{className:"w-5 h-5"}),o.jsx("span",{children:"Connection failed"})]})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),o.jsx("input",{type:"text",value:i,onChange:z=>a(z.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"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),o.jsx("input",{type:"text",value:c,onChange:z=>u(z.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),o.jsx("input",{type:"password",value:d,onChange:z=>f(z.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"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),o.jsxs("select",{value:g??"",onChange:z=>p(z.target.value?Number(z.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"No printer (manual control only)"}),Ce?.map(z=>o.jsx("option",{value:z.id,children:z.name},z.id))]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),o.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(jh,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:E,onChange:z=>w(z.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),o.jsx("input",{type:"number",value:T,onChange:z=>A(z.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),o.jsx("input",{type:"number",value:C,onChange:z=>N(z.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"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),o.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(rr,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:F,onChange:z=>k(z.target.checked),className:"sr-only peer"}),o.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"})]})]}),F&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),o.jsx("input",{type:"time",value:R,onChange:z=>I(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),o.jsx("input",{type:"time",value:L,onChange:z=>q(z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),o.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."})]})]}),o.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(QS,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:j,onChange:z=>V(z.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:Ie,className:"flex-1",children:[Ie?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function In({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return o.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:o.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 IGe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function FGe({provider:t,onEdit:e}){const n=mn(),[r,i]=M.useState(!1),[a,s]=M.useState(!1),[l,c]=M.useState(null),{data:u}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=vt({mutationFn:v=>Se.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=vt({mutationFn:()=>Se.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=vt({mutationFn:()=>Se.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),x=v=>v||"";return o.jsxs(o.Fragment,{children:[o.jsx(wt,{className:"relative",children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("div",{className:"flex items-start justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:o.jsx(jh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),o.jsxs("div",{children:[o.jsx("h3",{className:"font-medium text-white",children:t.name}),o.jsx("p",{className:"text-sm text-bambu-gray",children:IGe[t.provider_type]||t.provider_type})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&o.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))&&o.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),o.jsx(In,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]})]}),d&&o.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),o.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&o.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:o.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),o.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&o.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&o.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&o.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&o.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&o.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&o.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&o.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&o.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&&o.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&&o.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&&o.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&&o.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&&o.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&&o.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[o.jsx(z1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&o.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[o.jsx(Qr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),o.jsx("div",{className:"mb-3",children:o.jsxs(ke,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(gR,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&o.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?o.jsx(Cr,{className:"w-4 h-4"}):o.jsx(Pa,{className:"w-4 h-4"}),o.jsx("span",{children:l.message})]}),o.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:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(eM,{className:"w-4 h-4"}),"Event Settings"]}),a?o.jsx(Mb,{className:"w-4 h-4"}):o.jsx(Cl,{className:"w-4 h-4"})]}),a&&o.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Enabled"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),o.jsx(In,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Started"}),o.jsx(In,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),o.jsx(In,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),o.jsx(In,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),o.jsx(In,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),o.jsx(In,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),o.jsx(In,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),o.jsx(In,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),o.jsx(In,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),o.jsx(In,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),o.jsx(In,{checked:t.on_ams_humidity_high??!1,onChange:v=>f.mutate({on_ams_humidity_high:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),o.jsx(In,{checked:t.on_ams_temperature_high??!1,onChange:v=>f.mutate({on_ams_temperature_high:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),o.jsx(In,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>f.mutate({on_ams_ht_humidity_high:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),o.jsx(In,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>f.mutate({on_ams_ht_temperature_high:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(z1,{className:"w-4 h-4 text-purple-400"}),o.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),o.jsx(In,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),t.quiet_hours_enabled&&o.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(rr,{className:"w-4 h-4 text-bambu-gray"}),o.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Qr,{className:"w-4 h-4 text-emerald-400"}),o.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),o.jsx(In,{checked:t.daily_digest_enabled,onChange:v=>f.mutate({daily_digest_enabled:v})})]}),t.daily_digest_enabled&&o.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(rr,{className:"w-4 h-4 text-bambu-gray"}),o.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),o.jsxs("div",{className:"flex gap-2 pt-2",children:[o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[o.jsx(pR,{className:"w-4 h-4"}),"Edit"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:o.jsx(En,{className:"w-4 h-4"})})]})]})]})}),r&&o.jsx(kr,{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 G9=[{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 UGe({provider:t,onClose:e}){const n=mn(),r=!!t,[i,a]=M.useState(t?.name||""),[s,l]=M.useState(t?.provider_type||"email"),[c,u]=M.useState(t?.printer_id||null),[d,f]=M.useState(t?.quiet_hours_enabled||!1),[g,p]=M.useState(t?.quiet_hours_start||"22:00"),[x,v]=M.useState(t?.quiet_hours_end||"07:00"),[y,b]=M.useState(t?.daily_digest_enabled||!1),[E,w]=M.useState(t?.daily_digest_time||"08:00"),[T,A]=M.useState(t?.on_print_start??!1),[C,N]=M.useState(t?.on_print_complete??!0),[F,k]=M.useState(t?.on_print_failed??!0),[R,I]=M.useState(t?.on_print_stopped??!0),[L,q]=M.useState(t?.on_print_progress??!1),[j,V]=M.useState(t?.on_printer_offline??!1),[K,W]=M.useState(t?.on_printer_error??!1),[J,ee]=M.useState(t?.on_filament_low??!1),[Z,B]=M.useState(t?.on_maintenance_due??!1),[G,Q]=M.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([$,Y])=>[$,String(Y)])):{}),[te,he]=M.useState(null),[oe,xe]=M.useState(null),{data:Te}=gt({queryKey:["printers"],queryFn:Se.getPrinters});M.useEffect(()=>{const $=Y=>{Y.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const me=vt({mutationFn:()=>Se.testNotificationConfig({provider_type:s,config:G}),onSuccess:$=>{he($),xe(null)},onError:$=>{he({success:!1,message:$.message})}}),ce=vt({mutationFn:$=>Se.createNotificationProvider($),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:$=>{xe($.message)}}),Ce=vt({mutationFn:$=>Se.updateNotificationProvider(t.id,$),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:$=>{xe($.message)}}),fe=$=>{if($.preventDefault(),xe(null),!i.trim()){xe("Name is required");return}const Y=H(s);for(const ue of Y)if(!G[ue.key]?.trim()){xe(`${ue.label} is required`);return}const se={name:i.trim(),provider_type:s,config:G,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:y,daily_digest_time:y?E:null,on_print_start:T,on_print_complete:C,on_print_failed:F,on_print_stopped:R,on_print_progress:L,on_printer_offline:j,on_printer_error:K,on_filament_low:J,on_maintenance_due:Z};r?Ce.mutate(se):ce.mutate(se)},Ie=ce.isPending||Ce.isPending,z=$=>{switch($){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},H=$=>z($).filter(Y=>Y.required),re=z(s);return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:fe,className:"p-6 space-y-4",children:[oe&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:oe}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),o.jsx("input",{type:"text",value:i,onChange:$=>a($.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),o.jsx("select",{value:s,onChange:$=>{l($.target.value),Q({}),he(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:G9.map($=>o.jsx("option",{value:$.value,children:$.label},$.value))}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:G9.find($=>$.value===s)?.description})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),re.map($=>o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[$.label," ",$.required&&"*"]}),$.type==="select"&&$.options?o.jsx("select",{value:G[$.key]||$.options[0]?.value||"",onChange:Y=>{Q({...G,[$.key]:Y.target.value}),he(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:$.options.map(Y=>o.jsx("option",{value:Y.value,children:Y.label},Y.value))}):o.jsx("input",{type:$.type,value:G[$.key]||"",onChange:Y=>{Q({...G,[$.key]:Y.target.value}),he(null)},placeholder:$.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},$.key))]}),o.jsx("div",{className:"flex gap-2",children:o.jsxs(ke,{type:"button",variant:"secondary",onClick:()=>{he(null),me.mutate()},disabled:me.isPending||!G[H(s)[0]?.key],className:"flex-1",children:[me.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(gR,{className:"w-4 h-4"}),"Test Configuration"]})}),te&&o.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?o.jsxs(o.Fragment,{children:[o.jsx(Cr,{className:"w-5 h-5"}),o.jsx("span",{children:te.message})]}):o.jsxs(o.Fragment,{children:[o.jsx(Pa,{className:"w-5 h-5"}),o.jsx("span",{children:te.message})]})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),o.jsxs("select",{value:c??"",onChange:$=>u($.target.value?Number($.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"All printers"}),Te?.map($=>o.jsx("option",{value:$.id,children:$.name},$.id))]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),o.jsx(In,{checked:d,onChange:f})]}),d&&o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),o.jsx("input",{type:"time",value:g,onChange:$=>p($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),o.jsx("input",{type:"time",value:x,onChange:$=>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"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),o.jsx(In,{checked:y,onChange:b})]}),y&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),o.jsx("input",{type:"time",value:E,onChange:$=>w($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),o.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Start"}),o.jsx(In,{checked:T,onChange:A})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Complete"}),o.jsx(In,{checked:C,onChange:N})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Failed"}),o.jsx(In,{checked:F,onChange:k})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Stopped"}),o.jsx(In,{checked:R,onChange:I})]}),o.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-white",children:"Progress"}),o.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),o.jsx(In,{checked:L,onChange:q})]})]})]}),o.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Offline"}),o.jsx(In,{checked:j,onChange:V})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Error"}),o.jsx(In,{checked:K,onChange:W})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),o.jsx(In,{checked:J,onChange:ee})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),o.jsx(In,{checked:Z,onChange:B})]})]})]})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:Ie,className:"flex-1",children:[Ie?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function zGe({template:t,onClose:e}){const n=mn(),r=M.useRef(null),[i,a]=M.useState(t.title_template),[s,l]=M.useState(t.body_template),[c,u]=M.useState(null),[d,f]=M.useState(!0),{data:g}=gt({queryKey:["template-variables"],queryFn:Se.getTemplateVariables}),p=g?.find(A=>A.event_type===t.event_type),{data:x,isLoading:v}=gt({queryKey:["template-preview",t.event_type,i,s],queryFn:()=>Se.previewTemplate({event_type:t.event_type,title_template:i,body_template:s}),enabled:d&&i.length>0&&s.length>0});M.useEffect(()=>{const A=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e]);const y=vt({mutationFn:A=>Se.updateNotificationTemplate(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:A=>{u(A.message)}}),b=vt({mutationFn:()=>Se.resetNotificationTemplate(t.id),onSuccess:A=>{a(A.title_template),l(A.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:A=>{u(A.message)}}),E=A=>{if(A.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!s.trim()){u("Body is required");return}y.mutate({title_template:i,body_template:s})},w=A=>{const C=r.current;if(!C)return;const N=C.selectionStart,F=C.selectionEnd,k=s,R=k.substring(0,N),I=k.substring(F),L=R+`{${A}}`+I;l(L),setTimeout(()=>{C.focus();const q=N+A.length+2;C.setSelectionRange(q,q)},0)},T=i!==t.title_template||s!==t.body_template;return o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),o.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:o.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),o.jsx("input",{type:"text",value:i,onChange:A=>a(A.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..."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),o.jsx("textarea",{ref:r,value:s,onChange:A=>l(A.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(A=>o.jsxs("button",{type:"button",onClick:()=>w(A),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:[o.jsx(sr,{className:"w-3 h-3"}),A]},A))}),o.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[o.jsx(Zh,{className:"w-4 h-4"}),"Live Preview"]}),o.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&o.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:v?o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),o.jsx("div",{className:"text-white font-medium",children:x.title})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),o.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):o.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[o.jsxs(ke,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(ig,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsxs(ke,{onClick:E,disabled:y.isPending||!T,children:[y.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Ts,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const BGe={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"},HGe={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 $Ge({onClose:t}){const e=mn(),{showToast:n}=Sr(),[r,i]=M.useState(7),[a,s]=M.useState(null),[l,c]=M.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=gt({queryKey:["notification-logs",r,l],queryFn:()=>Se.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:p}=gt({queryKey:["notification-log-stats",r],queryFn:()=>Se.getNotificationLogStats(r)}),x=vt({mutationFn:()=>Se.clearNotificationLogs(30),onSuccess:y=>{n(y.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:y=>{n(`Failed to clear logs: ${y.message}`,"error")}}),v=y=>{const b=new Date(y),w=new Date().getTime()-b.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:b.toLocaleDateString()+" "+b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.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:[o.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(U1,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),p&&o.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:o.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[o.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",o.jsx("span",{className:"text-white font-medium",children:p.total})," notifications"]}),o.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[o.jsx(Cr,{className:"w-4 h-4"}),p.success_count," sent"]}),p.failure_count>0&&o.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[o.jsx(Pa,{className:"w-4 h-4"}),p.failure_count," failed"]})]})}),o.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[o.jsxs("select",{value:r,onChange:y=>i(Number(y.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:[o.jsx("option",{value:1,children:"Last 24 hours"}),o.jsx("option",{value:7,children:"Last 7 days"}),o.jsx("option",{value:30,children:"Last 30 days"}),o.jsx("option",{value:90,children:"Last 90 days"})]}),o.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:l,onChange:y=>c(y.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(_a,{className:"w-4 h-4"}),"Refresh"]}),o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(En,{className:"w-4 h-4"}),"Clear Old"]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?o.jsx("div",{className:"space-y-2",children:u.map(y=>o.jsx(VGe,{log:y,isExpanded:a===y.id,onToggle:()=>s(a===y.id?null:y.id),formatDate:v},y.id))}):o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx(U1,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function VGe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return o.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:[o.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?o.jsx(Cr,{className:"w-4 h-4 text-bambu-green shrink-0"}):o.jsx(Pa,{className:"w-4 h-4 text-red-400 shrink-0"}),o.jsx("span",{className:`text-xs font-medium ${HGe[t.event_type]||"text-bambu-gray"}`,children:BGe[t.event_type]||t.event_type}),o.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&o.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),o.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?o.jsx(Mb,{className:"w-4 h-4 text-bambu-gray shrink-0"}):o.jsx(Cl,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&o.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),o.jsx("p",{className:"text-sm text-white",children:t.title})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),o.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),o.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),o.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[o.jsxs("span",{children:["Provider: ",t.provider_type]}),o.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const a1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:o.jsx(xR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:o.jsx(jh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:o.jsx(Es,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:o.jsx(lo,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:o.jsx(Tb,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:o.jsx(Vi,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:o.jsx(mR,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:o.jsx(gd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:o.jsx(oo,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:o.jsx(Uo,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:o.jsx(oa,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"}];function GGe({onClose:t,onExport:e}){const{t:n}=eg(),[r,i]=M.useState(()=>{const x={};return a1.forEach(v=>{x[v.id]=v.default}),x}),[a,s]=M.useState(!1),[l,c]=M.useState(!1);M.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(v=>({...v,[x]:!v[x]}))},d=()=>{const x={};a1.forEach(v=>{x[v.id]=!0}),i(x)},f=()=>{const x={};a1.forEach(v=>{x[v.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,p=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:o.jsx(wt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:o.jsxs(Et,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:o.jsx(is,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),o.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),o.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[o.jsx("button",{onClick:d,disabled:l,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),o.jsx("span",{className:"text-bambu-gray",children:"|"}),o.jsx("button",{onClick:f,disabled:l,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),o.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:a1.map(x=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[o.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:l,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),o.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),o.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&o.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx(oo,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[o.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),o.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&&o.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ep,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),o.jsx(In,{checked:a,onChange:s})]}),a&&o.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[o.jsx(Gn,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),o.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),o.jsx(ke,{onClick:p,disabled:g===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):o.jsxs(o.Fragment,{children:[o.jsx(is,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const W9={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives",projects:"Projects",pending_uploads:"Pending Uploads",external_links:"External Links"};function WGe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=M.useState("options"),[a,s]=M.useState(!1),[l,c]=M.useState(null),[u,d]=M.useState(null),[f,g]=M.useState(new Set),p=M.useRef(null);M.useEffect(()=>{const w=T=>{T.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const x=w=>{const T=w.target.files?.[0];T&&c(T)},v=async()=>{if(l){i("restoring");try{const w=await e(l,a);d(w),i("result"),w.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},y=w=>{g(T=>{const A=new Set(T);return A.has(w)?A.delete(w):A.add(w),A})},b=u?.restored?Object.values(u.restored).reduce((w,T)=>w+T,0)+(u.files_restored||0):0,E=u?.total_skipped||0;return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:w=>{w.target===w.currentTarget&&r!=="restoring"&&t()},children:o.jsx(wt,{className:"w-full max-w-lg",children:o.jsxs(Et,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.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?o.jsx(Cr,{className:"w-5 h-5"}):r==="result"&&!u?.success?o.jsx(Gn,{className:"w-5 h-5"}):o.jsx(oa,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.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")]}),o.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"&&o.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),r==="options"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),o.jsx("button",{type:"button",onClick:()=>p.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?o.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[o.jsx(Cr,{className:"w-5 h-5"}),o.jsx("span",{className:"font-medium",children:l.name})]}):o.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[o.jsx(oa,{className:"w-8 h-8"}),o.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),o.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx(Gn,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[o.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),o.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[o.jsxs("li",{children:[o.jsx("strong",{children:"Printers"})," - matched by serial number"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Pending Uploads"})," - matched by filename"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),o.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?o.jsx(_a,{className:"w-4 h-4 text-orange-400"}):o.jsx(B1,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),o.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"})]}),o.jsx(In,{checked:a,onChange:s})]})}),a&&o.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx(Gn,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[o.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."]})]})})]}),o.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),o.jsxs(ke,{type:"button",onClick:v,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&o.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[o.jsx(xt,{className:"w-12 h-12 text-bambu-green animate-spin"}),o.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[o.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:b}),o.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),o.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[o.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:E}),o.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,w])=>w>0)&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[o.jsx(Cr,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),o.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,w])=>w>0).map(([w,T])=>o.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[o.jsx("span",{className:"text-white",children:W9[w]||w}),o.jsx("span",{className:"text-bambu-green font-medium",children:T})]},w)),(u.files_restored||0)>0&&o.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[o.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),o.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,w])=>w>0)&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[o.jsx(B1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),o.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,w])=>w>0).map(([w,T])=>{const A=u.skipped_details?.[w]||[],C=f.has(w);return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>A.length>0&&y(w),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${A.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[o.jsxs("span",{className:"text-white flex items-center gap-2",children:[W9[w]||w,A.length>0&&(C?o.jsx(Mb,{className:"w-3 h-3"}):o.jsx(Cl,{className:"w-3 h-3"}))]}),o.jsx("span",{className:"text-yellow-500 font-medium",children:T})]}),C&&A.length>0&&o.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[A.slice(0,10).map((N,F)=>o.jsx("div",{children:N},F)),A.length>10&&o.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",A.length-10," more"]})]})]},w)})})]}),b===0&&E===0&&o.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),o.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:o.jsx(ke,{onClick:t,children:"Close"})})]})]})})})}async function qGe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function KGe(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 XGe(){const t=mn(),[e,n]=M.useState(!1),[r,i]=M.useState(""),[a,s]=M.useState("auto"),[l,c]=M.useState(!1),[u,d]=M.useState("all"),[f,g]=M.useState(!1),{data:p,isLoading:x}=gt({queryKey:["spoolman-settings"],queryFn:qGe}),{data:v,isLoading:y,refetch:b}=gt({queryKey:["spoolman-status"],queryFn:Se.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=gt({queryKey:["printers"],queryFn:Se.getPrinters});M.useEffect(()=>{p&&(n(p.spoolman_enabled==="true"),i(p.spoolman_url||""),s(p.spoolman_sync_mode||"auto"),g(!0))},[p]),M.useEffect(()=>{if(!f||!p)return;if(p.spoolman_enabled==="true"!==e||(p.spoolman_url||"")!==r||(p.spoolman_sync_mode||"auto")!==a){const q=setTimeout(()=>{w.mutate()},500);return()=>clearTimeout(q)}},[e,r,a,f]);const w=vt({mutationFn:()=>KGe({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)}}),T=vt({mutationFn:Se.connectSpoolman,onSuccess:()=>{b()}}),A=vt({mutationFn:Se.disconnectSpoolman,onSuccess:()=>{b()}}),C=vt({mutationFn:Se.syncAllPrintersAms,onSuccess:L=>{L.success}}),N=vt({mutationFn:L=>Se.syncPrinterAms(L),onSuccess:L=>{L.success}}),F=()=>{u==="all"?C.mutate():N.mutate(u)},k=C.isPending||N.isPending,R=u==="all"?C.data:N.data,I=u==="all"?C.isSuccess:N.isSuccess;return x?o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(wp,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),o.jsx(Et,{children:o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(wp,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),w.isPending&&o.jsx(xt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&o.jsx(xl,{className:"w-4 h-4 text-bambu-green"})]})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Enable Spoolman"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:e,onChange:L=>n(L.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),o.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:L=>i(L.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"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),o.jsxs("select",{value:a,onChange:L=>s(L.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:[o.jsx("option",{value:"auto",children:"Automatic"}),o.jsx("option",{value:"manual",children:"Manual Only"})]}),o.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&&o.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),y?o.jsx(xt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?o.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[o.jsx(xl,{className:"w-4 h-4"}),"Connected"]}):o.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[o.jsx(Gt,{className:"w-4 h-4"}),"Disconnected"]})]}),o.jsx("div",{className:"flex gap-2",children:v?.connected?o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>A.mutate(),disabled:A.isPending,children:[A.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(yce,{className:"w-4 h-4"}),"Disconnect"]}):o.jsxs(ke,{size:"sm",onClick:()=>T.mutate(),disabled:T.isPending||!r,children:[T.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Yk,{className:"w-4 h-4"}),"Connect"]})})]}),T.isError&&o.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:T.error.message}),v?.connected&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsxs("select",{value:u,onChange:L=>d(L.target.value==="all"?"all":Number(L.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:[o.jsx("option",{value:"all",children:"All Printers"}),E?.map(L=>o.jsx("option",{value:L.id,children:L.name},L.id))]}),o.jsx(Cl,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:F,disabled:k,children:[k?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(_a,{className:"w-4 h-4"}),"Sync"]})]})]}),I&&R&&o.jsx("div",{className:`mt-2 p-2 rounded text-sm ${R.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:R.success?`Synced ${R.synced_count} trays successfully`:`Synced ${R.synced_count} trays with ${R.errors.length} errors`})]})]})]})}function YGe({link:t,onClose:e}){const n=mn(),{mode:r}=ag(),i=!!t,a=M.useRef(null),[s,l]=M.useState(t?.name||""),[c,u]=M.useState(t?.url||""),[d,f]=M.useState(t?.icon||"link"),[g,p]=M.useState(!!t?.custom_icon),[x,v]=M.useState(t?.custom_icon?Se.getExternalLinkIconUrl(t.id):null),[y,b]=M.useState(null),[E,w]=M.useState(null);M.useEffect(()=>{const I=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[e]);const T=vt({mutationFn:async I=>{const L=await Se.createExternalLink(I);return y?await Se.uploadExternalLinkIcon(L.id,y):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{w(I.message)}}),A=vt({mutationFn:async I=>{let L=await Se.updateExternalLink(t.id,I);return y?L=await Se.uploadExternalLinkIcon(t.id,y):!g&&t?.custom_icon&&(L=await Se.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{w(I.message)}}),C=I=>{const L=I.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){w("Image file must be less than 1MB");return}b(L),p(!0);const j=new FileReader;j.onload=V=>{v(V.target?.result)},j.readAsDataURL(L)}},N=()=>{b(null),v(null),p(!1),a.current&&(a.current.value="")},F=I=>{if(I.preventDefault(),w(null),!s.trim()){w("Name is required");return}if(!c.trim()){w("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){w("URL must start with http:// or https://");return}const L={name:s.trim(),url:c.trim(),icon:d};i?A.mutate(L):T.mutate(L)},k=T.isPending||A.isPending,R=nM(d);return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:I=>I.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?o.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):o.jsx(R,{className:"w-5 h-5"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:F,className:"p-6 space-y-4",children:[E&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),o.jsx("input",{type:"text",value:s,onChange:I=>l(I.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),o.jsx("input",{type:"text",value:c,onChange:I=>u(I.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"})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),o.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),o.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),g&&x?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),o.jsx("button",{type:"button",onClick:N,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:o.jsx(En,{className:"w-4 h-4"})})]}):o.jsxs(ke,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[o.jsx(oa,{className:"w-4 h-4"}),"Upload"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),o.jsx(Cde,{value:d,onChange:f})]})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:k,className:"flex-1",children:[k?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function ZGe(){const t=mn(),[e,n]=M.useState(!1),[r,i]=M.useState(null),[a,s]=M.useState(null),[l,c]=M.useState(null),{data:u,isLoading:d}=gt({queryKey:["external-links"],queryFn:Se.getExternalLinks}),f=vt({mutationFn:E=>Se.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=vt({mutationFn:E=>Se.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},v=(E,w)=>{if(E.preventDefault(),l===null||l===w||!u)return;const T=u.map(F=>F.id),A=T.indexOf(l),C=T.indexOf(w);if(A===-1||C===-1)return;const N=[...T];N.splice(A,1),N.splice(C,0,l),g.mutate(N),c(null)},y=E=>{s(E)},b=()=>{a&&(f.mutate(a.id),s(null))};return o.jsxs(o.Fragment,{children:[o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Yk,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),o.jsxs(ke,{size:"sm",onClick:()=>n(!0),children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Link"]})]})}),o.jsxs(Et,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?o.jsx("div",{className:"space-y-2",children:u.map(E=>{const w=nM(E.icon);return o.jsxs("div",{draggable:!0,onDragStart:T=>p(T,E.id),onDragOver:x,onDrop:T=>v(T,E.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===E.id?"opacity-50":""}`,children:[o.jsx(P0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:o.jsx(w,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-white font-medium truncate",children:E.name}),o.jsx(ba,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),o.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:o.jsx(Uc,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>y(E),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:o.jsx(En,{className:"w-4 h-4"})})]})]},E.id)})}):o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(Yk,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),o.jsx("p",{children:"No external links configured"}),o.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&o.jsx(YGe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&o.jsx(kr,{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:b,onCancel:()=>s(null)})]})}function QGe(){const t=mn(),{showToast:e}=Sr(),[n,r]=M.useState(!1),[i,a]=M.useState(""),[s,l]=M.useState("immediate"),[c,u]=M.useState(!1),{data:d,isLoading:f}=gt({queryKey:["virtual-printer-settings"],queryFn:t3.getSettings,refetchInterval:1e4});M.useEffect(()=>{d&&(r(d.enabled),l(d.mode))},[d]);const g=vt({mutationFn:E=>t3.updateSettings(E),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated")},onError:E=>{e(E.message||"Failed to update settings","error"),d&&(r(d.enabled),l(d.mode))}}),p=()=>{const E=!n;if(E&&!i&&!d?.access_code_set){e("Please set an access code first","error");return}r(E),g.mutate({enabled:E,access_code:i||void 0,mode:s})},x=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}g.mutate({access_code:i}),a("")},v=E=>{l(E),g.mutate({mode:E})};if(f)return o.jsx(wt,{children:o.jsx(Et,{className:"py-8 flex justify-center",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const y=d?.status,b=y?.running||!1;return o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[o.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Vi,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),y&&o.jsxs("div",{className:`flex items-center gap-2 text-sm ${b?"text-green-400":"text-bambu-gray"}`,children:[o.jsx("span",{className:`w-2 h-2 rounded-full ${b?"bg-green-400 animate-pulse":"bg-gray-500"}`}),b?"Running":"Stopped"]})]})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing."}),o.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),o.jsx("div",{className:"text-sm text-bambu-gray",children:b?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),o.jsx("button",{onClick:p,disabled:g.isPending,className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${g.isPending?"opacity-50":""}`,children:o.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),o.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[o.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),o.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:d?.access_code_set?o.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[o.jsx(xl,{className:"w-4 h-4"}),"Access code is set"]}):o.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[o.jsx(Gn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx("input",{type:c?"text":"password",value:i,onChange:E=>a(E.target.value),placeholder:d?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),o.jsx("button",{onClick:()=>u(!c),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:c?o.jsx(YS,{className:"w-4 h-4"}):o.jsx(Zh,{className:"w-4 h-4"})})]}),o.jsx(ke,{onClick:x,disabled:!i||g.isPending,variant:"primary",children:g.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):"Save"})]}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&o.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),o.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[o.jsx("div",{className:"text-white font-medium mb-2",children:"Archive Mode"}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("button",{onClick:()=>v("immediate"),disabled:g.isPending,className:`p-3 rounded-lg border text-left transition-colors ${s==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[o.jsx("div",{className:"text-white font-medium",children:"Immediate"}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files as soon as they are uploaded"})]}),o.jsxs("button",{onClick:()=>v("queue"),disabled:g.isPending,className:`p-3 rounded-lg border text-left transition-colors ${s==="queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[o.jsx("div",{className:"text-white font-medium",children:"Queue for Review"}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag files before archiving"})]})]})]})]})]})}),o.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[o.jsx(wt,{children:o.jsx(Et,{className:"py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Sp,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm text-bambu-gray",children:[o.jsx("p",{className:"mb-2",children:o.jsx("strong",{className:"text-white",children:"How it works:"})}),o.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[o.jsx("li",{children:"Enable the virtual printer and set an access code"}),o.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),o.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),o.jsx("li",{children:"Connect using the access code you set"}),o.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]}),o.jsxs("p",{className:"mt-3 text-yellow-400/80",children:[o.jsx(Gn,{className:"w-4 h-4 inline mr-1"}),"Required ports: 2021 (SSDP), 8883 (MQTT), 990 (FTP)"]}),o.jsxs("div",{className:"mt-2 text-xs text-bambu-gray space-y-1",children:[o.jsx("p",{children:"Port 990 requires root or iptables redirect:"}),o.jsx("code",{className:"block bg-bambu-dark-tertiary px-2 py-1 rounded text-[10px]",children:"sudo iptables -t nat -A PREROUTING -p tcp --dport 990 -j REDIRECT --to-port 9990"}),o.jsx("code",{className:"block bg-bambu-dark-tertiary px-2 py-1 rounded text-[10px]",children:"sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 990 -j REDIRECT --to-port 9990"})]})]})]})})}),y&&b&&o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),o.jsx(Et,{children:o.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),o.jsx("div",{className:"text-white",children:y.name})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Model"}),o.jsx("div",{className:"text-white",children:y.model?.replace("3DPrinter-","").replace("-"," ")||"X1 Carbon"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),o.jsx("div",{className:"text-white font-mono",children:y.serial})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Mode"}),o.jsx("div",{className:"text-white capitalize",children:y.mode})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),o.jsx("div",{className:"text-white",children:y.pending_files})]})]})})]})]})]})}function JGe(){const t=mn(),{t:e,i18n:n}=eg(),{showToast:r,showPersistentToast:i,dismissToast:a}=Sr(),{mode:s,darkStyle:l,darkBackground:c,darkAccent:u,lightStyle:d,lightBackground:f,lightAccent:g,setDarkStyle:p,setDarkBackground:x,setDarkAccent:v,setLightStyle:y,setLightBackground:b,setLightAccent:E}=ag(),[w,T]=M.useState(null),[A,C]=M.useState(!1),[N,F]=M.useState(null),[k,R]=M.useState(!1),[I,L]=M.useState(null),[q,j]=M.useState(null),[V,K]=M.useState(!1),[W,J]=M.useState(YG()),[ee,Z]=M.useState("general"),[B,G]=M.useState(!1),[Q,te]=M.useState(""),[he,oe]=M.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[xe,Te]=M.useState(null),[me,ce]=M.useState(null),[Ce,fe]=M.useState(!1),[Ie,z]=M.useState(!1),[H,re]=M.useState(null),[$,Y]=M.useState(!1),[se,ue]=M.useState(!1),[Ee,Me]=M.useState(!1),[U,O]=M.useState(!1),ne=Oe=>{J(Oe),jde(Oe)},be=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:ye,isLoading:_e}=gt({queryKey:["settings"],queryFn:Se.getSettings}),{data:We,isLoading:Ve}=gt({queryKey:["smart-plugs"],queryFn:Se.getSmartPlugs}),{data:Ye,isLoading:lt}=gt({queryKey:["smart-plugs-energy",We?.map(Oe=>Oe.id)],queryFn:async()=>{if(!We||We.length===0)return null;const Oe=await Promise.all(We.filter(Ke=>Ke.enabled).map(async Ke=>{try{const at=await Se.getSmartPlugStatus(Ke.id);return{plug:Ke,status:at}}catch{return{plug:Ke,status:null}}}));let Jt=0,Gr=0,ge=0,Ge=0,rt=0;for(const{status:Ke}of Oe)Ke?.reachable&&Ke.energy&&(rt++,Ke.energy.power!=null&&(Jt+=Ke.energy.power),Ke.energy.today!=null&&(Gr+=Ke.energy.today),Ke.energy.yesterday!=null&&(ge+=Ke.energy.yesterday),Ke.energy.total!=null&&(Ge+=Ke.energy.total));return{totalPower:Jt,totalToday:Gr,totalYesterday:ge,totalLifetime:Ge,reachableCount:rt,totalPlugs:We.filter(Ke=>Ke.enabled).length}},enabled:ee==="plugs"&&!!We&&We.length>0,refetchInterval:ee==="plugs"?1e4:!1}),{data:de,isLoading:ae}=gt({queryKey:["notification-providers"],queryFn:Se.getNotificationProviders}),{data:ze,isLoading:Ue}=gt({queryKey:["api-keys"],queryFn:Se.getAPIKeys}),et=vt({mutationFn:Oe=>Se.createAPIKey(Oe),onSuccess:Oe=>{Te(Oe.key||null),G(!1),te(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:Oe=>{r(`Failed to create API key: ${Oe.message}`,"error")}}),dt=vt({mutationFn:Oe=>Se.deleteAPIKey(Oe),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:Oe=>{r(`Failed to delete API key: ${Oe.message}`,"error")}}),{data:pe}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:nt,isLoading:ve}=gt({queryKey:["notification-templates"],queryFn:Se.getNotificationTemplates}),{data:He}=gt({queryKey:["virtual-printer-settings"],queryFn:t3.getSettings,refetchInterval:1e4}),je=He?.status?.running??!1,{data:we}=gt({queryKey:["ffmpeg-status"],queryFn:Se.checkFfmpeg}),{data:Xe}=gt({queryKey:["version"],queryFn:Se.getVersion}),{data:ot,refetch:St,isRefetching:Dt}=gt({queryKey:["updateCheck"],queryFn:Se.checkForUpdates,staleTime:300*1e3}),{data:qt,refetch:Ft}=gt({queryKey:["updateStatus"],queryFn:Se.getUpdateStatus,refetchInterval:Oe=>{const Jt=Oe.state.data;return Jt?.status==="downloading"||Jt?.status==="installing"?1e3:!1}}),kn=vt({mutationFn:Se.applyUpdate,onSuccess:()=>{Ft()}}),[Nn,Lr]=M.useState(null),Er=vt({mutationFn:Se.testAllNotificationProviders,onSuccess:Oe=>{Lr(Oe),t.invalidateQueries({queryKey:["notification-providers"]}),Oe.failed===0?r(`All ${Oe.tested} providers tested successfully!`,"success"):r(`${Oe.success}/${Oe.tested} providers succeeded`,Oe.failed>0?"error":"success")},onError:Oe=>{r(`Failed to test providers: ${Oe.message}`,"error")}}),br=vt({mutationFn:async Oe=>{if(!We)return{success:0,failed:0};const Jt=We.filter(ge=>ge.enabled),Gr=await Promise.all(Jt.map(async ge=>{try{return await Se.controlSmartPlug(ge.id,Oe),{success:!0}}catch{return{success:!1}}}));return{success:Gr.filter(ge=>ge.success).length,failed:Gr.filter(ge=>!ge.success).length}},onSuccess:(Oe,Jt)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Oe.failed===0?r(`All ${Oe.success} plugs turned ${Jt}`,"success"):r(`${Oe.success} plugs turned ${Jt}, ${Oe.failed} failed`,"error")},onError:Oe=>{r(`Failed: ${Oe.message}`,"error")}}),Tr=M.useRef(null),ei=M.useRef(!0);M.useEffect(()=>{ye&&!w&&(T(ye),setTimeout(()=>{ei.current=!1},100))},[ye,w]);const Ar=vt({mutationFn:Se.updateSettings,onSuccess:Oe=>{t.setQueryData(["settings"],Oe),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Oe=>{r(`Failed to save: ${Oe.message}`,"error")}});M.useEffect(()=>{if(!(ei.current||!w||!ye||!(ye.auto_archive!==w.auto_archive||ye.save_thumbnails!==w.save_thumbnails||ye.capture_finish_photo!==w.capture_finish_photo||ye.default_filament_cost!==w.default_filament_cost||ye.currency!==w.currency||ye.energy_cost_per_kwh!==w.energy_cost_per_kwh||ye.energy_tracking_mode!==w.energy_tracking_mode||ye.check_updates!==w.check_updates||ye.notification_language!==w.notification_language||ye.telemetry_enabled!==w.telemetry_enabled||ye.ams_humidity_good!==w.ams_humidity_good||ye.ams_humidity_fair!==w.ams_humidity_fair||ye.ams_temp_good!==w.ams_temp_good||ye.ams_temp_fair!==w.ams_temp_fair||ye.ams_history_retention_days!==w.ams_history_retention_days||ye.date_format!==w.date_format||ye.time_format!==w.time_format||ye.default_printer_id!==w.default_printer_id)))return Tr.current&&clearTimeout(Tr.current),Tr.current=setTimeout(()=>{const Jt={auto_archive:w.auto_archive,save_thumbnails:w.save_thumbnails,capture_finish_photo:w.capture_finish_photo,default_filament_cost:w.default_filament_cost,currency:w.currency,energy_cost_per_kwh:w.energy_cost_per_kwh,energy_tracking_mode:w.energy_tracking_mode,check_updates:w.check_updates,notification_language:w.notification_language,telemetry_enabled:w.telemetry_enabled,ams_humidity_good:w.ams_humidity_good,ams_humidity_fair:w.ams_humidity_fair,ams_temp_good:w.ams_temp_good,ams_temp_fair:w.ams_temp_fair,ams_history_retention_days:w.ams_history_retention_days,date_format:w.date_format,time_format:w.time_format,default_printer_id:w.default_printer_id};Ar.mutate(Jt)},500),()=>{Tr.current&&clearTimeout(Tr.current)}},[w,ye,Ar]);const rn=M.useCallback((Oe,Jt)=>{T(Gr=>Gr?{...Gr,[Oe]:Jt}:null)},[]);return _e||!w?o.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),o.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),o.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[o.jsx("button",{onClick:()=>Z("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${ee==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),o.jsxs("button",{onClick:()=>Z("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(lo,{className:"w-4 h-4"}),"Smart Plugs",We&&We.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:We.length})]}),o.jsxs("button",{onClick:()=>Z("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(jh,{className:"w-4 h-4"}),"Notifications",de&&de.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:de.length})]}),o.jsxs("button",{onClick:()=>Z("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(ep,{className:"w-4 h-4"}),"API Keys",ze&&ze.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ze.length})]}),o.jsxs("button",{onClick:()=>Z("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(Vi,{className:"w-4 h-4"}),"Virtual Printer",o.jsx("span",{className:`w-2 h-2 rounded-full ${je?"bg-green-400":"bg-gray-500"}`})]})]}),ee==="general"&&o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[o.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(k0,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),o.jsx("select",{value:n.language,onChange:Oe=>n.changeLanguage(Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:eU.map(Oe=>o.jsxs("option",{value:Oe.code,children:[Oe.nativeName," (",Oe.name,")"]},Oe.code))}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),o.jsx("select",{value:W,onChange:Oe=>ne(Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:R0.map(Oe=>o.jsx("option",{value:Oe.to,children:e(Oe.labelKey)},Oe.id))}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),o.jsxs("select",{value:w.date_format||"system",onChange:Oe=>rn("date_format",Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"system",children:"System Default"}),o.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),o.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),o.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),o.jsxs("select",{value:w.time_format||"system",onChange:Oe=>rn("time_format",Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"system",children:"System Default"}),o.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),o.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),o.jsxs("select",{value:w.default_printer_id??"",onChange:Oe=>rn("default_printer_id",Oe.target.value?Number(Oe.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:[o.jsx("option",{value:"",children:"No default (ask each time)"}),pe?.map(Oe=>o.jsx("option",{value:Oe.id,children:Oe.name},Oe.id))]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Sidebar order"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:be,children:[o.jsx(ig,{className:"w-4 h-4"}),"Reset"]})]})]})]}),o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(mR,{className:"w-5 h-5"}),"Appearance"]})}),o.jsxs(Et,{className:"space-y-6",children:[o.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${s==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[o.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",s==="dark"&&o.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),o.jsxs("select",{value:c,onChange:Oe=>{x(Oe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"neutral",children:"Neutral"}),o.jsx("option",{value:"warm",children:"Warm"}),o.jsx("option",{value:"cool",children:"Cool"}),o.jsx("option",{value:"oled",children:"OLED Black"}),o.jsx("option",{value:"slate",children:"Slate Blue"}),o.jsx("option",{value:"forest",children:"Forest Green"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),o.jsxs("select",{value:u,onChange:Oe=>{v(Oe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"green",children:"Green"}),o.jsx("option",{value:"teal",children:"Teal"}),o.jsx("option",{value:"blue",children:"Blue"}),o.jsx("option",{value:"orange",children:"Orange"}),o.jsx("option",{value:"purple",children:"Purple"}),o.jsx("option",{value:"red",children:"Red"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),o.jsxs("select",{value:l,onChange:Oe=>{p(Oe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"classic",children:"Classic"}),o.jsx("option",{value:"glow",children:"Glow"}),o.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),o.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${s==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[o.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",s==="light"&&o.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),o.jsxs("select",{value:f,onChange:Oe=>{b(Oe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"neutral",children:"Neutral"}),o.jsx("option",{value:"warm",children:"Warm"}),o.jsx("option",{value:"cool",children:"Cool"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),o.jsxs("select",{value:g,onChange:Oe=>{E(Oe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"green",children:"Green"}),o.jsx("option",{value:"teal",children:"Teal"}),o.jsx("option",{value:"blue",children:"Blue"}),o.jsx("option",{value:"orange",children:"Orange"}),o.jsx("option",{value:"purple",children:"Purple"}),o.jsx("option",{value:"red",children:"Red"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),o.jsxs("select",{value:d,onChange:Oe=>{y(Oe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"classic",children:"Classic"}),o.jsx("option",{value:"glow",children:"Glow"}),o.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Auto-archive prints"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.auto_archive,onChange:Oe=>rn("auto_archive",Oe.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Save thumbnails"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.save_thumbnails,onChange:Oe=>rn("save_thumbnails",Oe.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Capture finish photo"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.capture_finish_photo,onChange:Oe=>rn("capture_finish_photo",Oe.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),w.capture_finish_photo&&we&&!we.installed&&o.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[o.jsx(Gn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm",children:[o.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),o.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",o.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",o.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),o.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),o.jsx("input",{type:"number",step:"0.01",min:"0",value:w.default_filament_cost,onChange:Oe=>rn("default_filament_cost",parseFloat(Oe.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),o.jsxs("select",{value:w.currency,onChange:Oe=>rn("currency",Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"USD",children:"USD ($)"}),o.jsx("option",{value:"EUR",children:"EUR (€)"}),o.jsx("option",{value:"GBP",children:"GBP (£)"}),o.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),o.jsx("option",{value:"JPY",children:"JPY (¥)"}),o.jsx("option",{value:"CNY",children:"CNY (¥)"}),o.jsx("option",{value:"CAD",children:"CAD ($)"}),o.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),o.jsx("input",{type:"number",step:"0.01",min:"0",value:w.energy_cost_per_kwh,onChange:Oe=>rn("energy_cost_per_kwh",parseFloat(Oe.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),o.jsxs("select",{value:w.energy_tracking_mode||"total",onChange:Oe=>rn("energy_tracking_mode",Oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"print",children:"Prints Only"}),o.jsx("option",{value:"total",children:"Total Consumption"})]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:w.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-white",children:[o.jsx(lR,{className:"w-4 h-4 text-blue-400"}),o.jsx("span",{className:"font-medium",children:"Humidity"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_good??40,onChange:Oe=>rn("ams_humidity_good",parseInt(Oe.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_fair??60,onChange:Oe=>rn("ams_humidity_fair",parseInt(Oe.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),o.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2 text-white",children:[o.jsx(tM,{className:"w-4 h-4 text-orange-400"}),o.jsx("span",{className:"font-medium",children:"Temperature"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_good??28,onChange:Oe=>rn("ams_temp_good",parseFloat(Oe.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_fair??35,onChange:Oe=>rn("ams_temp_fair",parseFloat(Oe.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),o.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2 text-white",children:[o.jsx(wp,{className:"w-4 h-4 text-purple-400"}),o.jsx("span",{className:"font-medium",children:"History Retention"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",min:"1",max:"365",value:w.ams_history_retention_days??30,onChange:Oe=>rn("ams_history_retention_days",parseInt(Oe.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]}),o.jsx(XGe,{})]}),o.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[o.jsx(ZGe,{}),o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Check for updates"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.check_updates,onChange:Oe=>rn("check_updates",Oe.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-white",children:e("settings.telemetry")}),o.jsxs("button",{onClick:()=>Me(!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:[o.jsx(Sp,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),o.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.telemetry_enabled,onChange:Oe=>rn("telemetry_enabled",Oe.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Current version"}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Xe?.version||"..."]})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>St(),disabled:Dt,children:[Dt?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(_a,{className:"w-4 h-4"}),"Check now"]})]}),ot?.update_available?o.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[o.jsxs("div",{className:"flex items-start justify-between",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",ot.latest_version]}),ot.release_name&&ot.release_name!==ot.latest_version&&o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ot.release_name})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[ot.release_notes&&o.jsx("button",{onClick:()=>O(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),ot.release_url&&o.jsx("a",{href:ot.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:o.jsx(ba,{className:"w-4 h-4"})})]})]}),qt?.status==="downloading"||qt?.status==="installing"?o.jsxs("div",{className:"mt-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),o.jsx("span",{children:qt.message})]}),o.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:o.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${qt.progress}%`}})})]}):qt?.status==="complete"?o.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:qt.message}):qt?.status==="error"?o.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:qt.error||qt.message}):o.jsxs(ke,{className:"mt-3",onClick:()=>kn.mutate(),disabled:kn.isPending,children:[kn.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(is,{className:"w-4 h-4"}),"Install Update"]})]}):ot?.error?o.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: ",ot.error]}):ot&&!ot.update_available?o.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),o.jsxs(wt,{children:[o.jsx(Ii,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Backup Data"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[o.jsx(is,{className:"w-4 h-4"}),"Export"]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Restore Backup"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>ue(!0),children:[o.jsx(oa,{className:"w-4 h-4"}),"Restore"]})]}),o.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>fe(!0),children:[o.jsx(En,{className:"w-4 h-4"}),"Clear"]})]})}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),o.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."})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>z(!0),children:[o.jsx(En,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),ee==="plugs"&&o.jsxs("div",{className:"max-w-4xl",children:[o.jsxs("div",{className:"flex items-start justify-between mb-6",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(lo,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),o.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."})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[We&&We.filter(Oe=>Oe.enabled).length>1&&o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>re("on"),disabled:br.isPending,title:"Turn all plugs on",children:[br.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(kl,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),o.jsxs(ke,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>re("off"),disabled:br.isPending,title:"Turn all plugs off",children:[br.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(JS,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),o.jsxs(ke,{className:"whitespace-nowrap",onClick:()=>{F(null),C(!0)},children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),We&&We.length>0&&o.jsxs(wt,{className:"mb-6",children:[o.jsx(Ii,{children:o.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[o.jsx(ef,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",lt&&o.jsx(xt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),o.jsx(Et,{children:Ye?o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(ef,{className:"w-3 h-3"}),"Current Power"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[Ye.totalPower.toFixed(1),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Ye.reachableCount,"/",Ye.totalPlugs," plugs online"]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(Qr,{className:"w-3 h-3"}),"Today"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[Ye.totalToday.toFixed(2),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ye.totalToday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(VG,{className:"w-3 h-3"}),"Yesterday"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[Ye.totalYesterday.toFixed(2),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ye.totalYesterday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(qk,{className:"w-3 h-3"}),"Total"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[Ye.totalLifetime.toFixed(1),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ye.totalLifetime*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]})]}):lt?null:o.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Ve?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):We&&We.length>0?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:We.map(Oe=>o.jsx(OGe,{plug:Oe,onEdit:Jt=>{F(Jt),C(!0)}},Oe.id))}):o.jsx(wt,{children:o.jsx(Et,{className:"py-12",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(lo,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),o.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),o.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),o.jsxs(ke,{onClick:()=>{F(null),C(!0)},children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),ee==="notifications"&&o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(jh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>K(!0),children:[o.jsx(U1,{className:"w-4 h-4"}),"Log"]}),de&&de.length>0&&o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>{Lr(null),Er.mutate()},disabled:Er.isPending,children:[Er.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(gR,{className:"w-4 h-4"}),"Test All"]}),o.jsxs(ke,{size:"sm",onClick:()=>{L(null),R(!0)},children:[o.jsx(sr,{className:"w-4 h-4"}),"Add"]})]})]}),o.jsx(wt,{className:"mb-4",children:o.jsx(Et,{className:"py-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),o.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),o.jsx("select",{value:w.notification_language||"en",onChange:Oe=>rn("notification_language",Oe.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:eU.map(Oe=>o.jsx("option",{value:Oe.code,children:Oe.nativeName},Oe.code))})]})})}),Nn&&o.jsx(wt,{className:"mb-4",children:o.jsxs(Et,{className:"py-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),o.jsx("button",{onClick:()=>Lr(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[o.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[o.jsx(Cr,{className:"w-4 h-4"}),Nn.success," passed"]}),Nn.failed>0&&o.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[o.jsx(Pa,{className:"w-4 h-4"}),Nn.failed," failed"]})]}),Nn.results.filter(Oe=>!Oe.success).length>0&&o.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Nn.results.filter(Oe=>!Oe.success).map(Oe=>o.jsxs("div",{className:"text-xs text-red-400",children:[o.jsxs("span",{className:"font-medium",children:[Oe.provider_name,":"]})," ",Oe.message]},Oe.provider_id))})]})}),ae?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):de&&de.length>0?o.jsx("div",{className:"space-y-3",children:de.map(Oe=>o.jsx(FGe,{provider:Oe,onEdit:Jt=>{L(Jt),R(!0)}},Oe.id))}):o.jsx(wt,{children:o.jsx(Et,{className:"py-8",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(jh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),o.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),o.jsxs(ke,{size:"sm",onClick:()=>{L(null),R(!0)},children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[o.jsx(Es,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),o.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),ve?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):nt&&nt.length>0?o.jsx("div",{className:"space-y-2",children:nt.map(Oe=>o.jsx(wt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>j(Oe),children:o.jsx(Et,{className:"py-2.5 px-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-white font-medium text-sm truncate",children:Oe.name}),o.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Oe.title_template})]}),o.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Jt=>{Jt.stopPropagation(),j(Oe)},children:o.jsx(pR,{className:"w-4 h-4 text-bambu-gray"})})]})})},Oe.id))}):o.jsx(wt,{children:o.jsx(Et,{className:"py-8",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(Es,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),ee==="apikeys"&&o.jsxs("div",{className:"max-w-3xl",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(ep,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),o.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."})]}),o.jsxs(ke,{size:"sm",onClick:()=>G(!0),className:"flex-shrink-0",children:[o.jsx(sr,{className:"w-4 h-4"}),"Create Key"]})]}),xe&&o.jsx(wt,{className:"mb-6 border-bambu-green",children:o.jsx(Et,{className:"py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Cr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),o.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),o.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[o.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:xe}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(xe);else{const Oe=document.createElement("textarea");Oe.value=xe,Oe.style.position="fixed",Oe.style.left="-999999px",document.body.appendChild(Oe),Oe.select(),document.execCommand("copy"),document.body.removeChild(Oe)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:o.jsx(md,{className:"w-4 h-4"})})]}),o.jsx(ke,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>Te(null),children:"Dismiss"})]})]})})}),B&&o.jsxs(wt,{className:"mb-6",children:[o.jsx(Ii,{children:o.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),o.jsxs(Et,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),o.jsx("input",{type:"text",value:Q,onChange:Oe=>te(Oe.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:he.can_read_status,onChange:Oe=>oe(Jt=>({...Jt,can_read_status:Oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white",children:"Read Status"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:he.can_queue,onChange:Oe=>oe(Jt=>({...Jt,can_queue:Oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white",children:"Manage Queue"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:he.can_control_printer,onChange:Oe=>oe(Jt=>({...Jt,can_control_printer:Oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white",children:"Control Printer"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsxs(ke,{onClick:()=>et.mutate({name:Q||"Unnamed Key",...he}),disabled:et.isPending,children:[et.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(sr,{className:"w-4 h-4"}),"Create Key"]}),o.jsx(ke,{variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]})]})]}),Ue?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ze&&ze.length>0?o.jsx("div",{className:"space-y-3",children:ze.map(Oe=>o.jsx(wt,{children:o.jsx(Et,{className:"py-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ep,{className:`w-5 h-5 ${Oe.enabled?"text-bambu-green":"text-bambu-gray"}`}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white font-medium",children:Oe.name}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[Oe.key_prefix,"••••••••",Oe.last_used&&` · Last used: ${new Date(Oe.last_used).toLocaleDateString()}`]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex gap-1 text-xs",children:[Oe.can_read_status&&o.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),Oe.can_queue&&o.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),Oe.can_control_printer&&o.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>ce(Oe.id),children:o.jsx(En,{className:"w-4 h-4 text-red-400"})})]})]})})},Oe.id))}):o.jsx(wt,{children:o.jsx(Et,{className:"py-12",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(ep,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),o.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),o.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),o.jsxs(ke,{onClick:()=>G(!0),children:[o.jsx(sr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),o.jsxs(wt,{className:"mt-6",children:[o.jsx(Ii,{children:o.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),o.jsxs(Et,{className:"space-y-3 text-sm",children:[o.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",o.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),o.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-blue-400",children:"GET"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),o.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-blue-400",children:"GET"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),o.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-green-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),o.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-orange-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),o.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-orange-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),o.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-red-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),o.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),ee==="virtual-printer"&&o.jsx(QGe,{}),me!==null&&o.jsx(kr,{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:()=>{dt.mutate(me),ce(null)},onCancel:()=>ce(null)}),A&&o.jsx(LGe,{plug:N,onClose:()=>{C(!1),F(null)}}),k&&o.jsx(UGe,{provider:I,onClose:()=>{R(!1),L(null)}}),q&&o.jsx(zGe,{template:q,onClose:()=>j(null)}),V&&o.jsx($Ge,{onClose:()=>K(!1)}),Ce&&o.jsx(kr,{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()=>{fe(!1);try{const Oe=await Se.clearNotificationLogs(30);r(Oe.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>fe(!1)}),Ie&&o.jsx(kr,{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:()=>{z(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>z(!1)}),H&&o.jsx(kr,{title:`Turn All Plugs ${H==="on"?"On":"Off"}`,message:`This will turn ${H==="on"?"ON":"OFF"} all ${We?.filter(Oe=>Oe.enabled).length||0} enabled smart plugs. ${H==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${H==="on"?"On":"Off"}`,variant:H==="off"?"danger":"warning",onConfirm:()=>{const Oe=H;re(null),br.mutate(Oe)},onCancel:()=>re(null)}),$&&o.jsx(GGe,{onClose:()=>Y(!1),onExport:async Oe=>{Y(!1);const Jt="backup-progress",Gr=Oe.archives;Gr&&i(Jt,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:ge,filename:Ge}=await Se.exportBackup(Oe);Gr&&a(Jt);const rt=URL.createObjectURL(ge),Ke=document.createElement("a");Ke.href=rt,Ke.download=Ge,Ke.click(),URL.revokeObjectURL(rt),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{Gr&&a(Jt),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),se&&o.jsx(WGe,{onClose:()=>ue(!1),onRestore:async(Oe,Jt)=>await Se.importBackup(Oe,Jt),onSuccess:()=>{T(null),ei.current=!0,t.invalidateQueries()}}),Ee&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Me(!1),children:o.jsxs(wt,{className:"w-full max-w-lg",onClick:Oe=>Oe.stopPropagation(),children:[o.jsxs(Ii,{className:"flex flex-row items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Aue,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),o.jsx("button",{onClick:()=>Me(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs(Et,{className:"space-y-4",children:[o.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),o.jsxs("ul",{className:"space-y-2 text-sm",children:[o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Cr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Cr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Cr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem3")})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),o.jsxs("ul",{className:"space-y-2 text-sm",children:[o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),o.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),o.jsx(ke,{onClick:()=>Me(!1),className:"w-full",children:e("common.close")})]})]})}),U&&ot?.release_notes&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>O(!1),children:o.jsxs(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:Oe=>Oe.stopPropagation(),children:[o.jsxs(Ii,{className:"flex flex-row items-center justify-between shrink-0",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",ot.latest_version]}),ot.release_name&&ot.release_name!==ot.latest_version&&o.jsx("p",{className:"text-sm text-bambu-gray",children:ot.release_name})]}),o.jsx("button",{onClick:()=>O(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsx(Et,{className:"overflow-y-auto flex-1",children:o.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:ot.release_notes})}),o.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[ot.release_url&&o.jsx("a",{href:ot.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:o.jsxs(ke,{variant:"secondary",className:"w-full",children:[o.jsx(ba,{className:"w-4 h-4"}),"View on GitHub"]})}),o.jsx(ke,{onClick:()=>O(!1),className:"flex-1",children:"Close"})]})]})})]})}const Hte=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},eWe=t=>t.startsWith("HH")?"HF":"S",tWe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},qj=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 Nk({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:s}){const l=eWe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return o.jsxs("div",{className:"flex items-center gap-2",children:[r&&o.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?o.jsx(Jh,{className:"w-4 h-4 text-bambu-green"}):o.jsx(Ep,{className:"w-4 h-4"})}),o.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:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Hte(t.k_value)}),o.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),s&&o.jsx("span",{title:"Has note",children:o.jsx(zG,{className:"w-3 h-3 text-yellow-500"})}),o.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),s&&o.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&&o.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:o.jsx(md,{className:"w-4 h-4"})})]})}function Ck({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:s=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=Sr(),[f,g]=M.useState(t?.name||""),[p,x]=M.useState(t?.k_value?Hte(t.k_value):"0.020"),[v,y]=M.useState(t?.filament_id||""),[b,E]=M.useState(t?.nozzle_id?tWe(t.nozzle_id):"HH00"),[w,T]=M.useState(t?.nozzle_diameter||n),[A,C]=M.useState(t?[t.extruder_id]:i?[0,1]:[0]),[N,F]=M.useState(!1),[k,R]=M.useState({current:0,total:0}),[I,L]=M.useState(a),q=_r.useMemo(()=>{const Z=new Map;for(const B of r)if(B.filament_id&&!Z.has(B.filament_id)){const G=qj(B.name||"");Z.set(B.filament_id,{id:B.filament_id,name:G||B.filament_id})}return Array.from(Z.values()).sort((B,G)=>B.name.localeCompare(G.name))},[r]),j=vt({mutationFn:Z=>(console.log("[KProfile] Calling API..."),Se.setKProfile(e,Z)),onSuccess:Z=>{if(console.log("[KProfile] Save success:",Z),d("K-profile saved"),u&&I!==a){let B;I===""&&s?B=s:t&&t.slot_id>0?B=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:B=`name_${f}_${v}`,u(B,I)}F(!0),setTimeout(()=>{F(!1),c()},2500)},onError:Z=>{console.error("[KProfile] Save error:",Z),d(Z.message,"error"),F(!1)}}),V=vt({mutationFn:Z=>(console.log("[KProfile] Deleting profile..."),Se.deleteKProfile(e,Z)),onSuccess:Z=>{console.log("[KProfile] Delete success:",Z),d("K-profile deleted"),F(!0),setTimeout(()=>{F(!1),l()},4e3)},onError:Z=>{console.error("[KProfile] Delete error:",Z),d(Z.message,"error"),F(!1)}}),[K,W]=M.useState(!1),J=()=>{t&&V.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})},ee=async Z=>{if(Z.preventDefault(),i&&!t&&A.length===0){d("Please select at least one extruder","error");return}const B=parseFloat(p).toFixed(6),G=`${b}-${w}`;if(t||A.length===1){const te={name:f,k_value:B,filament_id:v,nozzle_id:G,nozzle_diameter:w,extruder_id:t?t.extruder_id:A[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",te),j.mutate(te);return}F(!0),R({current:1,total:A.length});const Q=A.map(te=>({name:f,k_value:B,filament_id:v,nozzle_id:G,nozzle_diameter:w,extruder_id:te,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${Q.length} profiles in batch:`,Q);try{if(await Se.setKProfilesBatch(e,Q),d(`K-profile saved to ${A.length} extruders`),u&&I){const te=`name_${f}_${v}`;u(te,I)}}catch(te){console.error("[KProfile] Failed to save batch:",te),d("Failed to save K-profiles","error"),F(!1),R({current:0,total:0});return}R({current:A.length,total:A.length}),setTimeout(()=>{F(!1),R({current:0,total:0}),c()},3e3)};return o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[o.jsxs(wt,{className:"w-full max-w-md relative",children:[N&&o.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),o.jsx("p",{className:"text-white font-medium",children:k.total>1?`Saving to extruder ${k.current}/${k.total}...`:"Syncing with printer..."}),o.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),o.jsxs(Et,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),o.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:N,children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:ee,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),o.jsx("input",{type:"text",value:f,onChange:Z=>g(Z.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})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),o.jsx("input",{type:"text",inputMode:"decimal",value:p,onChange:Z=>{const B=Z.target.value;(B===""||/^\d*\.?\d*$/.test(B))&&x(B)},onBlur:Z=>{const B=parseFloat(Z.target.value);isNaN(B)||x((Math.trunc(B*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}),o.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),o.jsxs("select",{value:v,onChange:Z=>{const B=Z.target.value;if(y(B),!t&&B&&!f){const G=q.find(Q=>Q.id===B);G&&g(`${b==="HH00"?"HF":"S"} ${G.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[o.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&o.jsx("option",{value:t.filament_id,children:q.find(Z=>Z.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Z=>o.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),!t&&q.length===0&&o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),o.jsxs("select",{value:b,onChange:Z=>{const B=Z.target.value;if(E(B),!t&&v&&!f){const G=q.find(Q=>Q.id===v);G&&g(`${B==="HS00"?"HF":"S"} ${G.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[o.jsx("option",{value:"HH00",children:"High Flow"}),o.jsx("option",{value:"HS00",children:"Standard"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),o.jsxs("select",{value:w,onChange:Z=>T(Z.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:[o.jsx("option",{value:"0.2",children:"0.2mm"}),o.jsx("option",{value:"0.4",children:"0.4mm"}),o.jsx("option",{value:"0.6",children:"0.6mm"}),o.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?o.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"}):o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:A.includes(1),onChange:Z=>{Z.target.checked?C([...A,1]):C(A.filter(B=>B!==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"}),o.jsx("span",{className:"text-white",children:"Left"})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:A.includes(0),onChange:Z=>{Z.target.checked?C([...A,0]):C(A.filter(B=>B!==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"}),o.jsx("span",{className:"text-white",children:"Right"})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),o.jsx("textarea",{value:I,onChange:Z=>L(Z.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"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),o.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&o.jsx(ke,{type:"button",variant:"secondary",onClick:()=>W(!0),disabled:V.isPending||N,className:"text-red-500 hover:bg-red-500/10",children:V.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(En,{className:"w-4 h-4"})}),o.jsx(ke,{type:"button",variant:"secondary",onClick:l,disabled:N,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:j.isPending||N,className:"flex-1",children:[j.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(ZS,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:o.jsx(wt,{className:"w-full max-w-sm",children:o.jsxs(Et,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:o.jsx(En,{className:"w-5 h-5 text-red-500"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),o.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",o.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:()=>W(!1),className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:()=>{W(!1),J()},disabled:V.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[V.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const s1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function nWe(){const{showToast:t}=Sr(),[e,n]=M.useState(null),[r,i]=M.useState(()=>localStorage.getItem(s1.NOZZLE_DIAMETER)||"0.4"),[a,s]=M.useState(null),[l,c]=M.useState(!1),[u,d]=M.useState(null),[f,g]=M.useState(""),[p,x]=M.useState("all"),[v,y]=M.useState("all"),[b,E]=M.useState(()=>localStorage.getItem(s1.SORT_OPTION)||"name"),[w,T]=M.useState(!1),[A,C]=M.useState(new Set),[N,F]=M.useState(!1),[k,R]=M.useState(!1),I=$=>`${$.slot_id}_${$.extruder_id}`;M.useEffect(()=>{localStorage.setItem(s1.NOZZLE_DIAMETER,r)},[r]),M.useEffect(()=>{localStorage.setItem(s1.SORT_OPTION,b)},[b]);const{data:L,isLoading:q}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:j,isLoading:V,isFetching:K,error:W,refetch:J}=gt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const $=await Se.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",$?.profiles?.length||0,"profiles"),$},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:ee}=gt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Se.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Z,refetch:B}=gt({queryKey:["kprofile-notes",e],queryFn:()=>Se.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),G=W?.message?.includes("not connected");M.useEffect(()=>{if(!e&&L&&L.length>0){const $=L.find(Y=>Y.is_active);$&&n($.id)}},[e,L]),M.useEffect(()=>{if(e){const $=setTimeout(()=>{J()},150);return()=>clearTimeout($)}},[e,r]);const Q=L?.filter($=>$.is_active)||[],te=_r.useMemo(()=>j?.profiles?j.profiles.filter(Y=>{const se=f.toLowerCase(),ue=!se||Y.name.toLowerCase().includes(se)||Y.filament_id.toLowerCase().includes(se),Ee=p==="all"||p==="left"&&Y.extruder_id===1||p==="right"&&Y.extruder_id===0,Me=v==="all"||v==="hf"&&Y.nozzle_id.startsWith("HH")||v==="s"&&Y.nozzle_id.startsWith("HS");return ue&&Ee&&Me}).sort((Y,se)=>{switch(b){case"k_value":return parseFloat(Y.k_value)-parseFloat(se.k_value);case"filament":return qj(Y.name).localeCompare(qj(se.name));case"name":default:return Y.name.localeCompare(se.name)}}):[],[j?.profiles,f,p,v,b]),he=L?.find($=>$.id===e),oe=he?.nozzle_count===2;M.useEffect(()=>{const $=Y=>{Y.target instanceof HTMLInputElement||Y.target instanceof HTMLTextAreaElement||Y.target instanceof HTMLSelectElement||a||l||u||(Y.key==="r"||Y.key==="R"?(Y.preventDefault(),J()):Y.key==="n"||Y.key==="N"?(Y.preventDefault(),c(!0)):Y.key==="Escape"&&w&&(Y.preventDefault(),T(!1),C(new Set)))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,l,u,w,J]);const xe=M.useCallback(()=>{if(!j?.profiles||j.profiles.length===0){t("No profiles to export","error");return}const $={version:1,exported_at:new Date().toISOString(),printer:he?.name||"Unknown",nozzle_diameter:r,profiles:j.profiles.map(Ee=>({name:Ee.name,k_value:Ee.k_value,filament_id:Ee.filament_id,nozzle_id:Ee.nozzle_id,nozzle_diameter:Ee.nozzle_diameter,extruder_id:Ee.extruder_id}))},Y=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),se=URL.createObjectURL(Y),ue=document.createElement("a");ue.href=se,ue.download=`kprofiles_${he?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ue),ue.click(),document.body.removeChild(ue),URL.revokeObjectURL(se),t(`Exported ${j.profiles.length} profiles`)},[j?.profiles,he,r,t]),Te=M.useCallback(()=>{const $=document.createElement("input");$.type="file",$.accept=".json",$.onchange=async Y=>{const se=Y.target.files?.[0];if(se)try{const ue=await se.text(),Ee=JSON.parse(ue);if(!Ee.profiles||!Array.isArray(Ee.profiles)){t("Invalid file format","error");return}let Me=0;for(const U of Ee.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await Se.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${r}`,nozzle_diameter:U.nozzle_diameter||r,extruder_id:U.extruder_id??0,slot_id:0}),Me++,await new Promise(O=>setTimeout(O,500))}catch(O){console.error("Failed to import profile:",U.name,O)}t(`Imported ${Me} of ${Ee.profiles.length} profiles`),J()}catch(ue){console.error("Import error:",ue),t("Failed to parse import file","error")}},$.click()},[e,r,t,J]),me=M.useCallback($=>{C(Y=>{const se=new Set(Y);return se.has($)?se.delete($):se.add($),se})},[]),ce=M.useCallback(()=>{C(new Set(te.map($=>I($))))},[te,I]),Ce=M.useCallback(()=>{A.size!==0&&F(!0)},[A.size]),fe=M.useCallback(async()=>{const $=te.filter(se=>A.has(I(se)));R(!0);let Y=0;for(const se of $)try{await Se.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}),Y++,await new Promise(ue=>setTimeout(ue,300))}catch(ue){console.error("Failed to delete profile:",se.name,ue)}t(`Deleted ${Y} profiles`),R(!1),F(!1),T(!1),C(new Set),J()},[e,A,te,t,J,I]),Ie=M.useCallback($=>{const Y=[];return $.setting_id&&Y.push($.setting_id),Y.push(`slot_${$.slot_id}_${$.filament_id}_${$.extruder_id}`),Y.push(`name_${$.name}_${$.filament_id}`),Y},[]),z=M.useCallback(async($,Y)=>{if(e)try{await Se.setKProfileNote(e,$,Y),B()}catch(se){console.error("Failed to save note:",se),t("Failed to save note","error")}},[e,B,t]),H=M.useCallback($=>{if(!Z?.notes)return{note:"",key:null};const Y=Ie($);for(const se of Y)if(Z.notes[se])return{note:Z.notes[se],key:se};return{note:"",key:null}},[Z,Ie]),re=M.useCallback($=>H($).note,[H]);return q?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?o.jsx(wt,{children:o.jsxs(Et,{className:"py-12 text-center",children:[o.jsx(mo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),o.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):Q.length===0?o.jsx(wt,{children:o.jsxs(Et,{className:"py-12 text-center",children:[o.jsx(Vi,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),o.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):o.jsxs(o.Fragment,{children:[K&&!V&&o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[o.jsx(xt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),o.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),o.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[o.jsxs("div",{className:"flex-1 min-w-48",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),o.jsx("select",{value:e||"",onChange:$=>n(parseInt($.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:Q.map($=>o.jsx("option",{value:$.id,children:$.name},$.id))})]}),o.jsxs("div",{className:"w-32",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),o.jsxs("select",{value:r,onChange:$=>i($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"0.2",children:"0.2mm"}),o.jsx("option",{value:"0.4",children:"0.4mm"}),o.jsx("option",{value:"0.6",children:"0.6mm"}),o.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsxs(ke,{variant:"secondary",onClick:()=>J(),disabled:K,children:[o.jsx(_a,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),o.jsxs(ke,{onClick:()=>c(!0),children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),o.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[o.jsxs("div",{className:"flex-1 min-w-48 relative",children:[o.jsx(bl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:f,onChange:$=>g($.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),oe&&o.jsx("div",{className:"w-36",children:o.jsxs("select",{value:p,onChange:$=>x($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"all",children:"All Extruders"}),o.jsx("option",{value:"left",children:"Left Only"}),o.jsx("option",{value:"right",children:"Right Only"})]})}),o.jsx("div",{className:"w-32",children:o.jsxs("select",{value:v,onChange:$=>y($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"all",children:"All Flow"}),o.jsx("option",{value:"hf",children:"HF Only"}),o.jsx("option",{value:"s",children:"S Only"})]})}),o.jsx("div",{className:"w-32",children:o.jsxs("select",{value:b,onChange:$=>E($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"name",children:"Sort: Name"}),o.jsx("option",{value:"k_value",children:"Sort: K-Value"}),o.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),o.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[o.jsxs(ke,{variant:"secondary",onClick:xe,disabled:!j?.profiles?.length,title:"Export profiles to JSON",children:[o.jsx(is,{className:"w-4 h-4"}),"Export"]}),o.jsxs(ke,{variant:"secondary",onClick:Te,title:"Import profiles from JSON",children:[o.jsx(oa,{className:"w-4 h-4"}),"Import"]}),o.jsx("div",{className:"flex-1"}),w?o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"secondary",onClick:ce,title:"Select all visible profiles",children:[o.jsx(Jh,{className:"w-4 h-4"}),"Select All"]}),o.jsxs(ke,{variant:"secondary",onClick:Ce,disabled:A.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${A.size} selected profiles`,children:[o.jsx(En,{className:"w-4 h-4"}),"Delete (",A.size,")"]}),o.jsxs(ke,{variant:"secondary",onClick:()=>{T(!1),C(new Set)},children:[o.jsx(Gt,{className:"w-4 h-4"}),"Cancel"]})]}):o.jsxs(ke,{variant:"secondary",onClick:()=>T(!0),disabled:!te.length,title:"Enter selection mode for bulk delete",children:[o.jsx(Jh,{className:"w-4 h-4"}),"Select"]})]}),V?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):G?o.jsx(wt,{children:o.jsxs(Et,{className:"py-12 text-center",children:[o.jsx(Ab,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),o.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),o.jsxs(ke,{variant:"secondary",onClick:()=>J(),children:[o.jsx(_a,{className:"w-4 h-4"}),"Retry"]})]})}):te.length>0?oe?o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),o.jsx("div",{className:"space-y-1",children:te.filter($=>$.extruder_id===1).map($=>o.jsx(Nk,{profile:$,onEdit:()=>s($),onCopy:()=>d($),selectionMode:w,isSelected:A.has(I($)),onToggleSelect:()=>me(I($)),note:re($)},I($)))})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),o.jsx("div",{className:"space-y-1",children:te.filter($=>$.extruder_id===0).map($=>o.jsx(Nk,{profile:$,onEdit:()=>s($),onCopy:()=>d($),selectionMode:w,isSelected:A.has(I($)),onToggleSelect:()=>me(I($)),note:re($)},I($)))})]})]}):o.jsx("div",{className:"space-y-1",children:te.map($=>o.jsx(Nk,{profile:$,onEdit:()=>s($),onCopy:()=>d($),selectionMode:w,isSelected:A.has(I($)),onToggleSelect:()=>me(I($)),note:re($)},I($)))}):f||p!=="all"||v!=="all"?o.jsx(wt,{children:o.jsxs(Et,{className:"py-12 text-center",children:[o.jsx(bl,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),o.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):o.jsx(wt,{children:o.jsxs(Et,{className:"py-12 text-center",children:[o.jsx(ZS,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),o.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),o.jsxs(ke,{onClick:()=>c(!0),children:[o.jsx(sr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:$,key:Y}=H(a);return o.jsx(Ck,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||j?.profiles,isDualNozzle:oe,initialNote:$,initialNoteKey:Y,onSaveNote:z,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),J()},onSave:()=>{s(null),J()}})})(),l&&e&&o.jsx(Ck,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||j?.profiles,isDualNozzle:oe,onSaveNote:z,onClose:()=>{c(!1),J()},onSave:()=>{c(!1),J()}}),u&&e&&o.jsx(Ck,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||j?.profiles,isDualNozzle:oe,onSaveNote:z,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),J()},onSave:()=>{d(null),J()}}),N&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(wt,{className:"w-full max-w-sm",children:o.jsxs(Et,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:o.jsx(En,{className:"w-5 h-5 text-red-500"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),o.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",o.jsx("span",{className:"text-white font-medium",children:A.size})," selected profiles from the printer?"]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:()=>F(!1),disabled:k,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:fe,disabled:k,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[k?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function HL(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,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:s,layerHeight:c,filamentType:d}}function yb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function rWe(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 iWe({onSuccess:t}){const{showToast:e}=Sr(),[n,r]=M.useState("email"),[i,a]=M.useState(""),[s,l]=M.useState(""),[c,u]=M.useState(""),[d,f]=M.useState(""),[g,p]=M.useState("global"),x=vt({mutationFn:()=>Se.cloudLogin(i,s,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=vt({mutationFn:()=>Se.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=vt({mutationFn:()=>Se.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),b=w=>{w.preventDefault(),n==="email"?x.mutate():n==="code"?v.mutate():n==="token"&&y.mutate()},E=x.isPending||v.isPending||y.isPending;return o.jsx(wt,{className:"max-w-md mx-auto",children:o.jsxs(Et,{children:[o.jsxs("div",{className:"text-center mb-6",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:o.jsx(XS,{className:"w-6 h-6 text-bambu-green"})}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),o.jsxs("form",{onSubmit:b,className:"space-y-4",children:[n==="email"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),o.jsx("input",{type:"email",value:i,onChange:w=>a(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),o.jsx("input",{type:"password",value:s,onChange:w=>l(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),o.jsxs("select",{value:g,onChange:w=>p(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"global",children:"Global"}),o.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),o.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),o.jsx("input",{type:"text",value:c,onChange:w=>u(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),o.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),o.jsx("textarea",{value:d,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),o.jsxs("div",{className:"flex gap-2",children:[n==="code"&&o.jsx(ke,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),o.jsxs(ke,{type:"submit",disabled:E,className:"flex-1",children:[E?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(_U,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&o.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[o.jsx(ep,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&o.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[o.jsx(_U,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Wm({label:t,value:e,options:n,onChange:r}){const[i,a]=M.useState(!1),s=n.find(l=>l.value===e);return o.jsxs("div",{className:"relative",children:[o.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:[o.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),o.jsx("span",{children:s?.label||"All"}),o.jsx(Cl,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),o.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>o.jsxs("button",{onClick:()=>{r(l.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[o.jsx("span",{children:l.label}),l.count!==void 0&&o.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function aWe(){const[t,e]=M.useState(!1);M.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?o.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:o.jsx(vp,{className:"w-5 h-5"})}):null}function kk({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:s}){const l=HL(t.name),c=yb(t.setting_id);return o.jsxs("div",{className:"flex items-center gap-2 group",children:[o.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:o.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&o.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&&o.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),o.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),o.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:o.jsx(md,{className:"w-4 h-4"})})]})}function Kj(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(a=>n+" "+a).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+Kj(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,s])=>n+" "+JSON.stringify(a)+": "+Kj(s,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function sWe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Sr(),s=mn(),[l,c]=M.useState(!1),{data:u,isLoading:d}=gt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Se.getCloudSettingDetail(t.setting_id)}),f=vt({mutationFn:()=>Se.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),s.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),g=yb(t.setting_id),p=HL(t.name,u?.setting?.inherits);return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(wt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:o.jsxs(Et,{className:"p-0 flex flex-col min-h-0 flex-1",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&o.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[o.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"•"}),o.jsx("span",{children:p.printer})]})]})]}),o.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?o.jsx("div",{className:"flex items-center justify-center py-16",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?o.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:Kj(u)}):o.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),l?o.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[o.jsx(Gn,{className:"w-5 h-5"}),o.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),o.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]})]}):o.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),o.jsxs(ke,{variant:"secondary",onClick:r,children:[o.jsx(md,{className:"w-4 h-4"}),"Duplicate"]}),g&&o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"secondary",onClick:i,disabled:d||!u,children:[o.jsx(Uc,{className:"w-4 h-4"}),"Edit"]}),o.jsx(ke,{variant:"danger",onClick:()=>c(!0),children:o.jsx(En,{className:"w-4 h-4"})})]})]})})]})})})}function $te(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Vte(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function oWe({onClose:t,onApply:e}){const{showToast:n}=Sr(),[r,i]=M.useState($te),[a,s]=M.useState("all"),[l,c]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(""),[p,x]=M.useState("{}"),[v,y]=M.useState(null),[b,E]=M.useState(null),w=a==="all"?r:r.filter(L=>L.type===a),T=L=>{i(L),Vte(L)},A=L=>{const q=r.filter(j=>j.id!==L);T(q),E(null),n("Template deleted")},C=L=>{c(L.id),d(L.name),g(L.description),x(JSON.stringify(L.settings,null,2)),y(null)},N=()=>{if(!(!l||!u.trim()))try{const L=JSON.parse(p),q=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:L}:j);T(q),c(null),n("Template updated")}catch(L){y(L.message)}},F=()=>{c(null),d(""),g(""),x("{}"),y(null)},k=L=>{const q=r.map(j=>j.id===L?{...j,showInModal:!j.showInModal}:j);T(q)},R={filament:{label:"Filament",icon:oR,color:"text-amber-400"},print:{label:"Process",icon:eM,color:"text-blue-400"},printer:{label:"Printer",icon:Vi,color:"text-purple-400"}},I=b?r.find(L=>L.id===b):null;return M.useEffect(()=>{const L=q=>{q.key==="Escape"&&(b?E(null):l?F():t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[b,l,t]),o.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[I&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:o.jsx(wt,{className:"w-full max-w-md",children:o.jsxs(Et,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:o.jsx(Gn,{className:"w-6 h-6 text-red-400"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),o.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',o.jsx("span",{className:"font-medium",children:I.name}),'"?']}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:()=>A(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]})]})})}),o.jsx(wt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:o.jsxs(Et,{className:"p-0 flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(j0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(L=>o.jsx("button",{onClick:()=>s(L),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:L==="all"?"All":R[L].label},L))]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx(j0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),o.jsx("p",{children:"No templates yet"}),o.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):o.jsx("div",{className:"space-y-2",children:w.map(L=>{const q=R[L.type],j=q.icon;return l===L.id?o.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[o.jsx("input",{type:"text",value:u,onChange:V=>d(V.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}),o.jsx("input",{type:"text",value:f,onChange:V=>g(V.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"})]}),o.jsxs("div",{className:"mb-3",children:[o.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),o.jsx("textarea",{value:p,onChange:V=>{x(V.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&o.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{size:"sm",onClick:N,disabled:!u.trim(),children:[o.jsx(Ts,{className:"w-4 h-4"}),"Save"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:F,children:"Cancel"})]})]},L.id):o.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:[o.jsx(j,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium text-white",children:L.name}),o.jsx("p",{className:"text-xs text-bambu-gray truncate",children:L.description})]}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(L.settings).length," fields"]}),o.jsx("button",{onClick:()=>k(L.id),className:`p-1 transition-colors ${L.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:L.showInModal?"Shown in modals":"Hidden in modals",children:L.showInModal?o.jsx(Zh,{className:"w-4 h-4"}):o.jsx(YS,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>e(L),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),o.jsx("button",{onClick:()=>C(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:o.jsx(Uc,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>E(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:o.jsx(En,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function Gte({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,s]=M.useState("changes"),[l,c]=M.useState(""),u=M.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const v of p){if(v==="inherits"||v==="version")continue;const y=e[v],b=n[v],E=v in e,w=v in n;let T;!E&&w?T="added":E&&!w?T="removed":JSON.stringify(y)!==JSON.stringify(b)?T="changed":T="same",x.push({key:v,left:y,right:b,status:T})}return x.sort((v,y)=>{const b={changed:0,added:1,removed:2,same:3};return b[v.status]!==b[y.status]?b[v.status]-b[y.status]:v.key.localeCompare(y.key)})},[e,n]),d=M.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();p=p.filter(v=>v.key.toLowerCase().includes(x)||String(v.left).toLowerCase().includes(x)||String(v.right).toLowerCase().includes(x))}return p},[u,a,l]),f=M.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),g=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const v=x.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return M.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:o.jsx(wt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:o.jsxs(Et,{className:"p-0 flex flex-col min-h-0 flex-1",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(op,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:o.jsx(Gt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),o.jsx("p",{className:"text-white font-medium truncate",children:r})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),o.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[o.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[o.jsx(sr,{className:"w-3.5 h-3.5"}),f.added," added"]}),o.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[o.jsx(Qk,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),o.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[o.jsx(Wk,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),o.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[o.jsx(GT,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"relative",children:[o.jsx(bl,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:l,onChange:p=>c(p.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&o.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[o.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"}),o.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"})]})]})]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx(GT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),o.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):o.jsxs("table",{className:"w-full",children:[o.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:o.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[o.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),o.jsx("th",{className:"text-left p-3 w-1/3",children:r}),o.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),o.jsx("tbody",{children:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],v={added:o.jsx(sr,{className:"w-3.5 h-3.5 text-green-400"}),removed:o.jsx(Qk,{className:"w-3.5 h-3.5 text-red-400"}),changed:o.jsx(Wk,{className:"w-3.5 h-3.5 text-amber-400"}),same:o.jsx(GT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return o.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[o.jsx("td",{className:"p-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[v,o.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),o.jsx("td",{className:"p-3",children:o.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.left)})}),o.jsx("td",{className:"p-3",children:o.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.right)})})]},p.key)})})]})})]})})})}function lWe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Sr(),i=mn(),a=!!e?.setting_id,[s,l]=M.useState("common"),[c,u]=M.useState(e?.type||"filament"),[d,f]=M.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,p]=M.useState(e?.base_id||""),[x,v]=M.useState(""),[y,b]=M.useState(e?.setting||{inherits:""}),[E,w]=M.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[T,A]=M.useState(null),[C,N]=M.useState(""),[F,k]=M.useState(!1),[R,I]=M.useState(""),[L,q]=M.useState(!1),[j,V]=M.useState($te),[K,W]=M.useState(!1),[J,ee]=M.useState(""),[Z,B]=M.useState(""),[G,Q]=M.useState(!0),[te,he]=M.useState(null),[oe,xe]=M.useState(!1),Te=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),me=M.useMemo(()=>Te.filter(ae=>yb(ae.setting_id)),[Te]),{data:ce}=gt({queryKey:["cloudFields",c],queryFn:()=>Se.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Ce}=gt({queryKey:["allPresetDetails",c,me.map(ae=>ae.setting_id).join(",")],queryFn:async()=>{const ae={};for(let Ue=0;Ue<me.length;Ue+=5){const et=me.slice(Ue,Ue+5);(await Promise.all(et.map(async pe=>{try{const nt=await Se.getCloudSettingDetail(pe.setting_id);return{id:pe.setting_id,detail:nt}}catch{return null}}))).forEach(pe=>{pe&&(ae[pe.id]=pe.detail)})}return ae},enabled:me.length>0,staleTime:1e3*60*10}),{data:fe,isLoading:Ie}=gt({queryKey:["cloudSettingDetail",g],queryFn:()=>Se.getCloudSettingDetail(g),enabled:!!g});M.useEffect(()=>{s!=="json"&&w(JSON.stringify(y,null,2))},[y,s]);const z=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(ze=>!yb(ze.setting_id)).sort((ze,Ue)=>ze.name.localeCompare(Ue.name)),[n,c]);M.useEffect(()=>{if(!g)return;const ae=z.find(ze=>ze.setting_id===g);ae&&(v(ae.name),a||(b({inherits:ae.name}),w(JSON.stringify({inherits:ae.name},null,2))))},[g,z,a]);const H=M.useMemo(()=>{const ae=ce?.fields||[],ze=new Set(ae.map(pe=>pe.key)),Ue=new Set,et=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Ce&&Object.values(Ce).forEach(pe=>{pe?.setting&&Object.keys(pe.setting).forEach(nt=>{!ze.has(nt)&&!et.has(nt)&&Ue.add(nt)})}),Object.keys(y).forEach(pe=>{!ze.has(pe)&&!et.has(pe)&&Ue.add(pe)});const dt=Array.from(Ue).sort().map(pe=>({key:pe,label:pe.replace(/_/g," ").replace(/\b\w/g,nt=>nt.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ae,...dt]},[ce,Ce,y]),re=H.filter(ae=>ae.label.toLowerCase().includes(C.toLowerCase())||ae.key.toLowerCase().includes(C.toLowerCase())),$=()=>{if(R.trim()){const ae=R.trim().toLowerCase().replace(/\s+/g,"_");Y(ae,""),I(""),q(!1),r(`Field "${ae}" added`)}},Y=(ae,ze)=>{b(Ue=>{const et={...Ue};return ze===""||ze===void 0?delete et[ae]:et[ae]=ze,et})},se=ae=>{b(ze=>({...ze,...ae.settings})),he(ae.name),r("Template applied")},ue=()=>{if(!J.trim())return;const ae={...y};if(delete ae.inherits,Object.keys(ae).length===0){r("No overrides to save","error");return}const ze={id:Date.now().toString(),name:J.trim(),description:Z.trim()||"Custom template",type:c,settings:ae,showInModal:G},Ue=[...j,ze];V(Ue),Vte(Ue),W(!1),ee(""),B(""),Q(!0),r("Template saved")},Ee=M.useMemo(()=>j.filter(ae=>ae.type===c&&ae.showInModal),[c,j]),Me=ae=>{w(ae);try{const ze=JSON.parse(ae);b(ze),A(null)}catch(ze){A(ze.message)}},U=ae=>{ae.preventDefault(),k(!1);const ze=ae.dataTransfer.files[0];if(ze&&ze.name.endsWith(".json")){const Ue=new FileReader;Ue.onload=et=>{try{const dt=et.target?.result,pe=JSON.parse(dt),nt=pe.setting||pe;b(ve=>({...ve,...nt})),w(JSON.stringify({...y,...nt},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Ue.readAsText(ze)}},O=vt({mutationFn:()=>{const ae={...y},ze=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";ae[ze]=`"${d}"`;const Ue={type:c,name:d,base_id:g,setting:ae};return Se.createCloudSetting(Ue)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ae=>r(ae.message,"error")}),ne=vt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return Se.updateCloudSetting(e.setting_id,{name:d,setting:y})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ae=>r(ae.message,"error")}),be=a?ne:O,ye=fe?.setting?.inherits,_e=ye?z.find(ae=>ae.name===ye):void 0,{data:We}=gt({queryKey:["cloudSettingDetail",_e?.setting_id],queryFn:()=>Se.getCloudSettingDetail(_e.setting_id),enabled:!!_e?.setting_id}),Ve=M.useMemo(()=>{const ae=We?.setting||{},ze=fe?.setting||{},Ue=g&&Ce?.[g]?.setting?Ce[g].setting:{};return{...ae,...ze,...Ue}},[g,fe,We,Ce]),Ye=ae=>{if(ae==null)return"";if(Array.isArray(ae)){const ze=[...new Set(ae.map(Ue=>String(Ue)))];return ze.length===1?ze[0]:ae.join(", ")}return String(ae)},lt=ae=>{const ze=y[ae.key],Ue=Ve[ae.key],et=Ye(Ue),dt=Ie?"Loading...":et||"",pe="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(ae.type==="boolean"){const nt=ze==="1"||ze===void 0&&Ue==="1";return o.jsx("button",{type:"button",onClick:()=>Y(ae.key,ze==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${nt?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:o.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${nt?"translate-x-3.5":"translate-x-0.5"}`})})}return ae.type==="select"?o.jsxs("select",{value:ze||"",onChange:nt=>Y(ae.key,nt.target.value),className:pe,children:[o.jsx("option",{value:"",children:dt}),ae.options?.map(nt=>o.jsx("option",{value:nt.value,children:nt.label},nt.value))]}):o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:ae.type==="number"?"number":"text",value:ze!==void 0?String(ze):"",onChange:nt=>Y(ae.key,nt.target.value),step:ae.step,min:ae.min,max:ae.max,placeholder:dt,className:pe}),ae.unit&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ae.unit})]})},de=M.useMemo(()=>fe?.setting?fe.setting:{},[fe]);return o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ae=>{ae.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:U,children:[oe&&g&&o.jsx(Gte,{onClose:()=>xe(!1),leftPreset:de,rightPreset:y,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),o.jsx(wt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:o.jsxs(Et,{className:"p-0 flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[g&&o.jsxs("button",{onClick:()=>xe(!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:[o.jsx(op,{className:"w-4 h-4"}),"Compare"]}),o.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Gt,{className:"w-5 h-5"})})]})]}),F&&o.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:o.jsxs("div",{className:"text-center",children:[o.jsx(oa,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),o.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),o.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),o.jsxs("select",{value:c,onChange:ae=>{u(ae.target.value),p("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"filament",children:"Filament"}),o.jsx("option",{value:"print",children:"Process"}),o.jsx("option",{value:"printer",children:"Printer"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),o.jsxs("select",{value:g,onChange:ae=>p(ae.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:[o.jsx("option",{value:"",children:"Select base preset..."}),z.map(ae=>o.jsx("option",{value:ae.setting_id,children:ae.name},ae.setting_id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),o.jsx("input",{type:"text",value:d,onChange:ae=>f(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&o.jsx("div",{className:"text-xs text-bambu-gray",children:o.jsxs("p",{className:"flex items-center gap-1",children:[o.jsx(xl,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",o.jsx("span",{className:"text-white",children:x}),Ie&&o.jsx(xt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),o.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[o.jsxs("button",{onClick:()=>l("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(wU,{className:"w-4 h-4"}),"Common"]}),o.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(fR,{className:"w-4 h-4"}),"All Fields"]}),o.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(DG,{className:"w-4 h-4"}),"JSON",T&&o.jsx(mo,{className:"w-3 h-3 text-red-400"})]}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{onClick:()=>{const ae={name:d,type:c,base_id:g,setting:y},ze=new Blob([JSON.stringify(ae,null,2)],{type:"application/json"}),Ue=URL.createObjectURL(ze),et=document.createElement("a");et.href=Ue,et.download=`${d||"preset"}.json`,document.body.appendChild(et),et.click(),document.body.removeChild(et),URL.revokeObjectURL(Ue),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:[o.jsx(is,{className:"w-4 h-4"}),"Export"]}),o.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:[o.jsx(oa,{className:"w-4 h-4"}),"Import"]}),o.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ae=>{const ze=ae.target.files?.[0];if(ze){const Ue=new FileReader;Ue.onload=et=>{try{const dt=JSON.parse(et.target?.result),pe=dt.setting||dt;b(nt=>({...nt,...pe})),r("File imported")}catch{r("Invalid JSON","error")}},Ue.readAsText(ze)}}})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[s==="common"&&o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[o.jsx(j0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(y).filter(ae=>ae!=="inherits").length>0&&o.jsxs("button",{onClick:()=>W(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[o.jsx(Ts,{className:"w-3 h-3"}),"Save as template"]})]}),K&&o.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[o.jsx("input",{type:"text",value:J,onChange:ae=>ee(ae.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}),o.jsx("input",{type:"text",value:Z,onChange:ae=>B(ae.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"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{size:"sm",onClick:ue,disabled:!J.trim(),children:[o.jsx(Ts,{className:"w-3 h-3"}),"Save"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>W(!1),children:"Cancel"})]}),o.jsxs("button",{onClick:()=>Q(!G),className:`flex items-center gap-1.5 text-xs transition-colors ${G?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[G?o.jsx(Zh,{className:"w-3.5 h-3.5"}):o.jsx(YS,{className:"w-3.5 h-3.5"}),G?"Show in modals":"Hidden in modals"]})]})]}),te&&o.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:[o.jsx(xl,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",o.jsx("span",{className:"font-medium",children:te})]}),o.jsx("button",{onClick:()=>he(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:o.jsx(Gt,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ee.map(ae=>o.jsxs("button",{onClick:()=>se(ae),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[o.jsx("p",{className:"text-sm font-medium text-white",children:ae.name}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ae.description})]},ae.id)),Ee.length===0&&o.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."})]}),o.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),o.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:H.slice(0,10).map(ae=>o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ae.label}),o.jsx("div",{className:"w-48",children:lt(ae)})]},ae.key))})]}),Object.keys(y).length>1&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([ae])=>ae!=="inherits").map(([ae,ze])=>o.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ae,": ",String(ze).slice(0,20),o.jsx("button",{onClick:()=>Y(ae,void 0),className:"hover:text-white",children:o.jsx(Gt,{className:"w-3 h-3"})})]},ae))})]})]}),s==="fields"&&o.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[o.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[o.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),o.jsx("span",{className:"text-xs text-bambu-gray",children:Ce?`${H.length} fields`:"Loading..."})]}),o.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[o.jsx(bl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:C,onChange:ae=>N(ae.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"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[re.filter(ae=>!(ae.key in y)).map(ae=>{const ze=Ve[ae.key],Ue=Ye(ze);return o.jsxs("div",{onClick:()=>{b(et=>({...et,[ae.key]:Ue||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-sm text-white truncate",children:ae.label}),o.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ae.key})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Ue&&o.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Ue,children:[Ue.slice(0,20),Ue.length>20?"...":""]}),o.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:o.jsx(sr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ae.key)}),re.filter(ae=>!(ae.key in y)).length===0&&o.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:C?"No matching fields":"All fields added"})]}),o.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:L?o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:R,onChange:ae=>I(ae.target.value),onKeyDown:ae=>ae.key==="Enter"&&$(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),o.jsx(ke,{size:"sm",onClick:$,disabled:!R.trim(),children:o.jsx(sr,{className:"w-4 h-4"})}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>{q(!1),I("")},children:o.jsx(Gt,{className:"w-4 h-4"})})]}):o.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:[o.jsx(sr,{className:"w-4 h-4"}),"Add custom field"]})})]}),o.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[o.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),o.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(y).filter(ae=>ae!=="inherits").length," fields"]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([ae])=>ae!=="inherits").map(([ae,ze])=>{const Ue=H.find(et=>et.key===ae);return o.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-white",children:Ue?.label||ae}),o.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ae})]}),o.jsx("button",{onClick:()=>Y(ae,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:o.jsx(Gt,{className:"w-4 h-4"})})]}),Ue?lt(Ue):o.jsx("input",{type:"text",value:String(ze),onChange:et=>Y(ae,et.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"})]},ae)}),Object.keys(y).filter(ae=>ae!=="inherits").length===0&&o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(wU,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),o.jsx("p",{className:"text-sm",children:"No overrides yet"}),o.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(y).filter(ae=>ae!=="inherits").length>0&&o.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:o.jsxs("button",{onClick:()=>{W(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[o.jsx(Ts,{className:"w-4 h-4"}),"Save as template"]})})]})]}),s==="json"&&o.jsxs("div",{className:"space-y-2",children:[T&&o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[o.jsx(mo,{className:"w-4 h-4"}),T]}),o.jsx("textarea",{value:E,onChange:ae=>Me(ae.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 ${T?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),o.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!a&&!g||!!T,className:"flex-1",children:[be.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):a?o.jsx(Ts,{className:"w-4 h-4"}):o.jsx(sr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function cWe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,s]=M.useState(""),[l,c]=M.useState("all"),[u,d]=M.useState("all"),[f,g]=M.useState("all"),[p,x]=M.useState("all"),[v,y]=M.useState("all"),[b,E]=M.useState("all"),[w,T]=M.useState(null),[A,C]=M.useState(!1),[N,F]=M.useState(!1),[k,R]=M.useState(null),[I,L]=M.useState(null),[q,j]=M.useState(null),[V,K]=M.useState(!1),[W,J]=M.useState([null,null]),[ee,Z]=M.useState(!1),[B,G]=M.useState(null),Q=mn(),te=M.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:HL(re.name)})),[t]),he=M.useMemo(()=>{const H=new Set,re=new Set,$=new Set;return te.forEach(Y=>{Y.meta.nozzle&&H.add(Y.meta.nozzle),Y.meta.filamentType&&re.add(Y.meta.filamentType),Y.meta.layerHeight&&$.add(Y.meta.layerHeight)}),{printers:i.map(Y=>({id:Y.id.toString(),name:Y.name})),nozzles:Array.from(H).sort((Y,se)=>parseFloat(Y)-parseFloat(se)),filaments:Array.from(re).sort(),layerHeights:Array.from($).sort((Y,se)=>parseFloat(Y)-parseFloat(se))}},[te,i]),oe=M.useMemo(()=>f==="all"?null:i.find(re=>re.id.toString()===f)?.model||null,[f,i]),xe=M.useMemo(()=>te.filter(H=>l==="all"||H.type===l).filter(H=>{if(u==="all")return!0;const re=yb(H.setting_id);return u==="custom"?re:!re}).filter(H=>{if(f==="all"||!oe)return!0;const re=H.meta.printer?.toLowerCase()||"",$=oe.toLowerCase();return re.includes($)||$.includes(re)}).filter(H=>p==="all"||H.meta.nozzle===p).filter(H=>v==="all"||H.meta.filamentType===v).filter(H=>b==="all"||H.meta.layerHeight===b).filter(H=>a===""||H.name.toLowerCase().includes(a.toLowerCase())).sort((H,re)=>H.name.localeCompare(re.name)),[te,l,u,f,oe,p,v,b,a]),Te=H=>{if(V){const re=W[0]?.setting_id===H.setting_id,$=W[1]?.setting_id===H.setting_id;if(re)J([W[1],null]);else if($)J([W[0],null]);else if(!W[0])J([H,null]);else if(W[1]){if(W[0].type!==H.type)return;J([W[0],H])}else{if(W[0].type!==H.type)return;J([W[0],H])}}else T(H)},me=H=>{if(W[0]?.setting_id===H.setting_id)return 0;if(W[1]?.setting_id===H.setting_id)return 1},ce=async H=>{try{const re=await Se.getCloudSettingDetail(H.setting_id),$=H.type==="process"?"print":H.type;R({type:$,name:H.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),T(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},Ce=async H=>{try{Q.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const re=await Se.getCloudSettingDetail(H.setting_id),$=H.type==="process"?"print":H.type;L({type:$,name:H.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:H.setting_id}),T(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},fe=()=>{c("all"),d("all"),g("all"),x("all"),y("all"),E("all"),s("")},Ie=l!=="all"||u!=="all"||f!=="all"||p!=="all"||v!=="all"||b!=="all"||a!=="",z=t.filament.length+t.printer.length+t.process.length;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 mb-6",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(bl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:a,onChange:H=>s(H.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{variant:V?"primary":"secondary",onClick:()=>{V?(K(!1),J([null,null])):K(!0)},children:[o.jsx(op,{className:"w-4 h-4"}),V?"Cancel":"Compare"]}),o.jsxs(ke,{variant:"secondary",onClick:()=>F(!0),children:[o.jsx(j0,{className:"w-4 h-4"}),"Templates"]}),o.jsxs(ke,{variant:"secondary",onClick:n,disabled:r,children:[o.jsx(_a,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),o.jsxs(ke,{onClick:()=>C(!0),children:[o.jsx(sr,{className:"w-4 h-4"}),"New Preset"]})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(dR,{className:"w-4 h-4 text-bambu-gray"}),o.jsx(Wm,{label:"Type",value:l,options:[{value:"all",label:"All",count:z},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:H=>c(H)}),o.jsx(Wm,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:H=>d(H)}),he.printers.length>0&&o.jsx(Wm,{label:"Printer",value:f,options:[{value:"all",label:"All"},...he.printers.map(H=>({value:H.id,label:H.name}))],onChange:g}),he.nozzles.length>0&&o.jsx(Wm,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...he.nozzles.map(H=>({value:H,label:H}))],onChange:x}),he.filaments.length>0&&(l==="all"||l==="filament")&&o.jsx(Wm,{label:"Filament",value:v,options:[{value:"all",label:"All"},...he.filaments.map(H=>({value:H,label:H}))],onChange:y}),he.layerHeights.length>0&&(l==="all"||l==="process")&&o.jsx(Wm,{label:"Layer",value:b,options:[{value:"all",label:"All"},...he.layerHeights.map(H=>({value:H,label:H}))],onChange:E}),Ie&&o.jsx("button",{onClick:fe,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),V&&o.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(op,{className:"w-5 h-5 text-blue-400"}),o.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),o.jsx("span",{className:"text-bambu-gray",children:W[0]?`Select another ${W[0].type} preset`:"Click two presets of the same type to compare"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${W[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:W[0]?W[0].name:"1. Select first"}),o.jsx(Wk,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${W[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:W[1]?W[1].name:"2. Select second"})]}),W[0]&&W[1]&&o.jsxs(ke,{size:"sm",onClick:async()=>{try{const[H,re]=await Promise.all([Se.getCloudSettingDetail(W[0].setting_id),Se.getCloudSettingDetail(W[1].setting_id)]);G([H.setting||{},re.setting||{}]),Z(!0)}catch{}},children:[o.jsx(op,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),o.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(rr,{className:"w-3 h-3"}),"Last synced: ",rWe(e.toISOString())]}),o.jsxs("span",{children:["Showing ",xe.length," of ",z," presets"]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),o.jsx("span",{children:"= My preset (editable)"})]})]}),xe.length===0?o.jsxs("div",{className:"text-center py-16",children:[o.jsx(pd,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),o.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Ie&&o.jsx("button",{onClick:fe,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(oR,{className:"w-4 h-4 text-amber-400"}),o.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="filament").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(H=>H.type==="filament").map(H=>o.jsx(kk,{setting:H,onClick:()=>Te(H),onDuplicate:()=>ce(H),compareMode:V,isCompareSelected:me(H)!==void 0,compareIndex:me(H),compareDisabled:V&&!!W[0]&&W[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="filament").length===0&&o.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(eM,{className:"w-4 h-4 text-blue-400"}),o.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="process").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(H=>H.type==="process").map(H=>o.jsx(kk,{setting:H,onClick:()=>Te(H),onDuplicate:()=>ce(H),compareMode:V,isCompareSelected:me(H)!==void 0,compareIndex:me(H),compareDisabled:V&&!!W[0]&&W[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="process").length===0&&o.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(Vi,{className:"w-4 h-4 text-purple-400"}),o.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="printer").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(H=>H.type==="printer").map(H=>o.jsx(kk,{setting:H,onClick:()=>Te(H),onDuplicate:()=>ce(H),compareMode:V,isCompareSelected:me(H)!==void 0,compareIndex:me(H),compareDisabled:V&&!!W[0]&&W[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="printer").length===0&&o.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&o.jsx(sWe,{setting:w,onClose:()=>T(null),onDeleted:()=>T(null),onDuplicate:()=>ce(w),onEdit:()=>Ce(w)}),(A||k||I||q)&&o.jsx(lWe,{onClose:()=>{C(!1),R(null),L(null),j(null)},initialData:I||k||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),N&&o.jsx(oWe,{onClose:()=>F(!1),onApply:H=>{j({type:H.type,setting:H.settings}),F(!1)}}),ee&&B&&W[0]&&W[1]&&o.jsx(Gte,{onClose:()=>{Z(!1),G(null)},leftPreset:B[0],rightPreset:B[1],leftLabel:W[0].name,rightLabel:W[1].name})]})}function uWe(){const t=mn(),{showToast:e}=Sr(),[n,r]=M.useState("cloud"),[i,a]=M.useState(),{data:s,isLoading:l}=gt({queryKey:["cloudStatus"],queryFn:Se.getCloudStatus}),{data:c=[]}=gt({queryKey:["printers"],queryFn:Se.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=gt({queryKey:["cloudSettings"],queryFn:()=>Se.getCloudSettings(),enabled:!!s?.is_authenticated,retry:!1,staleTime:1e3*60*5});M.useEffect(()=>{g&&a(new Date(g))},[g]);const p=vt({mutationFn:Se.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?o.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):o.jsxs("div",{className:"p-6 lg:p-8",children:[o.jsxs("div",{className:"mb-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),o.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),o.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[o.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:[o.jsx(XS,{className:"w-4 h-4"}),"Cloud Profiles"]}),o.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:[o.jsx(ZS,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&o.jsxs(o.Fragment,{children:[s?.is_authenticated&&o.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),o.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",o.jsx("span",{className:"text-white",children:s.email})]})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[o.jsx(Nce,{className:"w-4 h-4"}),"Logout"]})]}),s?.is_authenticated?d?o.jsx("div",{className:"flex items-center justify-center py-16",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?o.jsx(cWe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):o.jsxs("div",{className:"text-center py-16",children:[o.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),o.jsx(ke,{onClick:()=>f(),children:"Retry"})]}):o.jsx(iWe,{onSuccess:x})]}),n==="kprofiles"&&o.jsx(nWe,{}),o.jsx(aWe,{})]})}const t0={Droplet:oR,Flame:Ble,Ruler:pue,Sparkles:j0,Square:Ep,Cable:Uoe,Wrench:gd,Calendar:Qr,Timer:Zu,Cog:ple,Fan:Ple,Zap:ef,Wind:xde,Thermometer:tM,Layers:pd,Box:_p,Target:BG,RefreshCw:_a,Settings:xR,Filter:dR,CircleDot:nle};function M0(t){return t&&t0[t]||gd}function qm(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function Pk(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 dWe({item:t,onPerform:e,onToggle:n}){const r=M0(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))})(),l=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${qm(Math.abs(f),"days")}`:t.is_warning?`Due in ${qm(f,"days")}`:`${qm(f,"days")} left`}else return t.is_due?`Overdue by ${qm(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${qm(t.hours_until_due,"hours")}`:`${qm(t.hours_until_due,"hours")} left`};return o.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.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:[o.jsx(r,{className:`w-5 h-5 ${l()}`}),t.enabled&&(t.is_due||t.is_warning)&&o.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`})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&o.jsx("span",{title:"Time-based interval",children:o.jsx(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),o.jsx("div",{className:"mt-2 mb-1.5",children:o.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${s}%`}})})}),o.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&o.jsx(Gn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&o.jsx(rr,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&o.jsx(xl,{className:"w-3 h-3"}),d()]})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx(In,{checked:t.enabled,onChange:f=>n(t.id,f)}),o.jsxs(ke,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[o.jsx(ig,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function hWe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=M.useState(!0),[s,l]=M.useState(!1),[c,u]=M.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,x)=>p.is_due&&!x.is_due?-1:!p.is_due&&x.is_due?1:p.is_warning&&!x.is_warning?-1:!p.is_warning&&x.is_warning?1:p.maintenance_type_id-x.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),g=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return o.jsxs(wt,{className:"overflow-hidden",children:[o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),o.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&o.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:[o.jsx(Gn,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&o.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:[o.jsx(rr,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&o.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:[o.jsx(xl,{className:"w-3 h-3"}),"All good"]})]})]}),o.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?o.jsx(Mb,{className:"w-4 h-4"}):o.jsx(Cl,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),o.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:o.jsx(Zu,{className:"w-4 h-4 text-bambu-gray"})}),s?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",value:c,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&g(),p.key==="Escape"&&l(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),o.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),o.jsx(ke,{size:"sm",onClick:g,children:"Save"}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):o.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[o.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",o.jsx(Qh,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),o.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=M0(f.maintenance_type_icon);return o.jsx(p,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),o.jsxs("div",{children:[o.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),o.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&o.jsx(Et,{className:"pt-0 border-t border-bambu-dark-tertiary",children:o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(p=>o.jsx(dWe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function fWe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:s,onRemoveItem:l}){const[c,u]=M.useState(null),[d,f]=M.useState(""),[g,p]=M.useState("hours"),[x,v]=M.useState(!1),[y,b]=M.useState(""),[E,w]=M.useState("100"),[T,A]=M.useState("hours"),[C,N]=M.useState("Wrench"),[F,k]=M.useState(new Set),[R,I]=M.useState(null),L=M.useMemo(()=>t?t.map(Ie=>({id:Ie.printer_id,name:Ie.printer_name})):[],[t]),q=Ie=>t?t.filter(z=>z.maintenance_items.some(H=>H.maintenance_type_id===Ie)).map(z=>({printerId:z.printer_id,printerName:z.printer_name,itemId:z.maintenance_items.find(H=>H.maintenance_type_id===Ie)?.id})):[],j=Ie=>{if(!t)return[];const z=new Set(q(Ie).map(H=>H.printerId));return L.filter(H=>!z.has(H.id))},[V,K]=M.useState(null),[W,J]=M.useState(""),[ee,Z]=M.useState(""),[B,G]=M.useState("hours"),[Q,te]=M.useState("Wrench"),he=Ie=>{K(Ie),J(Ie.name),Z(Ie.default_interval_hours.toString()),G(Ie.interval_type||"hours"),te(Ie.icon||"Wrench")},oe=()=>{V&&W.trim()&&parseFloat(ee)>0&&(i(V.id,{name:W.trim(),default_interval_hours:parseFloat(ee),interval_type:B,icon:Q}),K(null))},xe=(Ie,z,H)=>{const re=parseFloat(d);if(!isNaN(re)&&re>0){const $=Math.abs(re-z)<.01?null:re;n(Ie,{custom_interval_hours:$,custom_interval_type:g!==H?g:null})}u(null)},Te=Ie=>{Ie.preventDefault(),y.trim()&&parseFloat(E)>0&&F.size>0&&(r({name:y.trim(),default_interval_hours:parseFloat(E),interval_type:T,icon:C},Array.from(F)),b(""),w("100"),A("hours"),k(new Set),v(!1))},me=Ie=>{k(z=>{const H=new Set(z);return H.has(Ie)?H.delete(Ie):H.add(Ie),H})},ce=t?.map(Ie=>({printerId:Ie.printer_id,printerName:Ie.printer_name,items:Ie.maintenance_items.sort((z,H)=>z.maintenance_type_id-H.maintenance_type_id)})).sort((Ie,z)=>Ie.printerName.localeCompare(z.printerName))||[],Ce=e.filter(Ie=>Ie.is_system),fe=e.filter(Ie=>!Ie.is_system);return o.jsxs("div",{className:"space-y-8",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),o.jsxs(ke,{onClick:()=>v(!x),children:[o.jsx(sr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&o.jsx(wt,{className:"mb-6",children:o.jsx(Et,{className:"py-4",children:o.jsxs("form",{onSubmit:Te,children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsxs("div",{className:"lg:col-span-2",children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),o.jsx("input",{type:"text",value:y,onChange:Ie=>b(Ie.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})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),o.jsxs("select",{value:T,onChange:Ie=>{A(Ie.target.value),Ie.target.value==="days"?w("30"):w("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"hours",children:"Print Hours"}),o.jsx("option",{value:"days",children:"Calendar Days"})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",T==="days"?"days":"hours",")"]}),o.jsx("input",{type:"number",value:E,onChange:Ie=>w(Ie.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"})]})]}),o.jsx("div",{className:"mt-4 flex items-end justify-between",children:o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),o.jsx("div",{className:"flex gap-1",children:Object.keys(t0).map(Ie=>{const z=t0[Ie];return o.jsx("button",{type:"button",onClick:()=>N(Ie),className:`p-2 rounded-lg transition-colors ${C===Ie?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:o.jsx(z,{className:"w-4 h-4"})},Ie)})})]})}),o.jsxs("div",{className:"mt-4",children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:L.map(Ie=>o.jsx("button",{type:"button",onClick:()=>me(Ie.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(Ie.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:Ie.name},Ie.id))}),F.size===0&&o.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),o.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:()=>{v(!1),k(new Set)},children:"Cancel"}),o.jsx(ke,{type:"submit",disabled:!y.trim()||F.size===0,children:"Add Type"})]})]})})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[Ce.map(Ie=>{const z=M0(Ie.icon),H=Ie.interval_type||"hours";return o.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:o.jsx(z,{className:"w-5 h-5 text-bambu-gray"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-white truncate",children:Ie.name}),o.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?o.jsx(Qr,{className:"w-3 h-3"}):o.jsx(Zu,{className:"w-3 h-3"}),Pk(Ie.default_interval_hours,H)]})]})]})},Ie.id)}),fe.map(Ie=>{const z=M0(Ie.icon),H=Ie.interval_type||"hours";if(V?.id===Ie.id)return o.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:o.jsxs("div",{className:"space-y-3",children:[o.jsx("input",{type:"text",value:W,onChange:ue=>J(ue.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}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("select",{value:B,onChange:ue=>G(ue.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:[o.jsx("option",{value:"hours",children:"Print Hours"}),o.jsx("option",{value:"days",children:"Calendar Days"})]}),o.jsx("input",{type:"number",value:ee,onChange:ue=>Z(ue.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"})]}),o.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(t0).map(ue=>{const Ee=t0[ue];return o.jsx("button",{type:"button",onClick:()=>te(ue),className:`p-1.5 rounded transition-colors ${Q===ue?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:o.jsx(Ee,{className:"w-3.5 h-3.5"})},ue)})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{size:"sm",onClick:oe,disabled:!W.trim(),children:"Save"}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>K(null),children:"Cancel"})]})]})},Ie.id);const $=q(Ie.id),Y=j(Ie.id),se=R===Ie.id;return o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:o.jsx(z,{className:"w-5 h-5 text-bambu-green"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-white truncate",children:Ie.name}),o.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),o.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?o.jsx(Qr,{className:"w-3 h-3"}):o.jsx(Zu,{className:"w-3 h-3"}),Pk(Ie.default_interval_hours,H)]})]}),o.jsxs("button",{onClick:()=>I(se?null:Ie.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${$.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:`${$.length} printer(s) assigned - click to manage`,children:[o.jsx(Vi,{className:"w-3 h-3"}),o.jsx("span",{className:"text-xs font-medium",children:$.length}),o.jsx(Cl,{className:`w-3 h-3 transition-transform ${se?"rotate-180":""}`})]}),o.jsx("button",{onClick:()=>he(Ie),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:o.jsx(Qh,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>{confirm(`Delete "${Ie.name}"?`)&&a(Ie.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:o.jsx(En,{className:"w-4 h-4"})})]}),se&&o.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),$.length===0?o.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):o.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:$.map(ue=>o.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[ue.printerName,o.jsx("button",{onClick:()=>ue.itemId&&l(ue.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},ue.printerId))}),Y.length>0&&o.jsxs("div",{className:"flex flex-wrap gap-1",children:[o.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Y.map(ue=>o.jsxs("button",{onClick:()=>s(ue.id,Ie.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",ue.name]},ue.id))]})]})]},Ie.id)})]})]}),ce.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"mb-4",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),o.jsx("div",{className:"space-y-4",children:ce.map(Ie=>o.jsx(wt,{children:o.jsxs(Et,{className:"py-4",children:[o.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:Ie.printerName}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:Ie.items.map(z=>{const H=M0(z.maintenance_type_icon),re=e.find(Ee=>Ee.id===z.maintenance_type_id),$=re?.default_interval_hours||z.interval_hours,Y=re?.interval_type||"hours",se=z.interval_type||"hours",ue=c===z.id;return o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[o.jsx(H,{className:"w-4 h-4 text-bambu-gray shrink-0"}),o.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:z.maintenance_type_name}),ue?o.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?o.jsx(Qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):o.jsx(Zu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),o.jsxs("select",{value:g,onChange:Ee=>p(Ee.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[o.jsx("option",{value:"hours",children:"Print Hours"}),o.jsx("option",{value:"days",children:"Calendar Days"})]}),o.jsx("input",{type:"number",value:d,onChange:Ee=>f(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&xe(z.id,$,Y),Ee.key==="Escape"&&u(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),o.jsx(ke,{size:"sm",onClick:()=>xe(z.id,$,Y),children:"OK"})]}):o.jsxs("button",{onClick:()=>{u(z.id),f(z.interval_hours.toString()),p(se)},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:[se==="days"?o.jsx(Qr,{className:"w-3 h-3"}):o.jsx(Zu,{className:"w-3 h-3"}),Pk(z.interval_hours,se),o.jsx(Qh,{className:"w-3 h-3 text-bambu-gray"})]})]},z.id)})})]})},Ie.printerId))})]}),ce.length===0&&o.jsx(wt,{children:o.jsxs(Et,{className:"text-center py-12",children:[o.jsx(rr,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),o.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),o.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function mWe(){const t=mn(),{showToast:e}=Sr(),[n,r]=M.useState("status"),{data:i,isLoading:a}=gt({queryKey:["maintenanceOverview"],queryFn:Se.getMaintenanceOverview}),{data:s}=gt({queryKey:["maintenanceTypes"],queryFn:Se.getMaintenanceTypes}),l=vt({mutationFn:({id:w,notes:T})=>Se.performMaintenance(w,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:w=>{e(w.message,"error")}}),c=vt({mutationFn:({id:w,data:T})=>Se.updateMaintenanceItem(w,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:w=>{e(w.message,"error")}}),u=vt({mutationFn:({id:w,data:T})=>Se.updateMaintenanceType(w,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:w=>{e(w.message,"error")}}),d=vt({mutationFn:Se.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:w=>{e(w.message,"error")}}),f=vt({mutationFn:({printerId:w,hours:T})=>Se.setPrinterHours(w,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:w=>{e(w.message,"error")}}),g=vt({mutationFn:({printerId:w,typeId:T})=>Se.assignMaintenanceType(w,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:w=>{e(w.message,"error")}}),p=vt({mutationFn:Se.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:w=>{e(w.message,"error")}}),x=w=>{l.mutate({id:w})},v=(w,T)=>{c.mutate({id:w,data:{enabled:T}})},y=(w,T)=>{f.mutate({printerId:w,hours:T})};if(a)return o.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const b=i?.reduce((w,T)=>w+T.due_count,0)||0,E=i?.reduce((w,T)=>w+T.warning_count,0)||0;return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"mb-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),o.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?o.jsxs(o.Fragment,{children:[b>0&&o.jsxs("span",{className:"text-red-400",children:[b," task",b!==1?"s":""," overdue"]}),b>0&&E>0&&" · ",E>0&&o.jsxs("span",{className:"text-amber-400",children:[E," due soon"]}),b===0&&E===0&&o.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),o.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[o.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"}),o.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"?o.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((w,T)=>{const A=w.due_count*10+w.warning_count,C=T.due_count*10+T.warning_count;return A!==C?C-A:w.printer_name.localeCompare(T.printer_name)}).map(w=>o.jsx(hWe,{overview:w,onPerform:x,onToggle:v,onSetHours:y},w.printer_id)):o.jsx(wt,{children:o.jsxs(Et,{className:"text-center py-16",children:[o.jsx(gd,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),o.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),o.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):o.jsx(fWe,{overview:i,types:s||[],onUpdateInterval:(w,T)=>c.mutate({id:w,data:T}),onAddType:async(w,T)=>{const A=await Se.createMaintenanceType(w);for(const C of T)await Se.assignMaintenanceType(C,A.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(w,T)=>u.mutate({id:w,data:T}),onDeleteType:w=>d.mutate(w),onAssignType:(w,T)=>g.mutate({printerId:w,typeId:T}),onRemoveItem:w=>p.mutate(w)})]})}const q9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Wte({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=M.useState(t?.name||""),[s,l]=M.useState(t?.description||""),[c,u]=M.useState(t?.color||q9[0]),[d,f]=M.useState(t?.target_count?.toString()||""),[g,p]=M.useState(t?.status||"active"),[x,v]=M.useState(t?.tags||""),[y,b]=M.useState(t?.due_date?.split("T")[0]||""),[E,w]=M.useState(t?.priority||"normal"),T=A=>{A.preventDefault(),n({name:i.trim(),description:s.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,tags:x.trim()||void 0,due_date:y||void 0,priority:E,...t&&{status:g}})};return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[o.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),o.jsxs("form",{onSubmit:T,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),o.jsx("input",{type:"text",value:i,onChange:A=>a(A.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})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),o.jsx("textarea",{value:s,onChange:A=>l(A.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})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),o.jsx("div",{className:"flex gap-2 flex-wrap",children:q9.map(A=>o.jsx("button",{type:"button",onClick:()=>u(A),className:`w-8 h-8 rounded-full transition-transform ${c===A?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:A}},A))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),o.jsx("input",{type:"number",value:d,onChange:A=>f(A.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),o.jsx("input",{type:"text",value:x,onChange:A=>v(A.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., voron, functional, gift"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),o.jsx("input",{type:"date",value:y,onChange:A=>b(A.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"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),o.jsxs("select",{value:E,onChange:A=>w(A.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:[o.jsx("option",{value:"low",children:"Low"}),o.jsx("option",{value:"normal",children:"Normal"}),o.jsx("option",{value:"high",children:"High"}),o.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),o.jsxs("select",{value:g,onChange:A=>p(A.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:[o.jsx("option",{value:"active",children:"Active"}),o.jsx("option",{value:"completed",children:"Completed"}),o.jsx("option",{value:"archived",children:"Archived"})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(ke,{type:"submit",disabled:!i.trim()||r,children:r?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function pWe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,a=t.status==="completed",s=t.status==="archived",[l,c]=M.useState(!1),d=a?{icon:sR,color:"text-bambu-green",bg:"bg-bambu-green/10"}:s?{icon:oo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:rr,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Uo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return o.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[o.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),o.jsxs("div",{className:"p-5 pl-6",children:[o.jsxs("div",{className:"flex items-start justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("div",{className:`p-2 rounded-lg ${d.bg} flex-shrink-0`,children:o.jsx(d.icon,{className:`w-5 h-5 ${d.color}`})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_count?o.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${i>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," parts"]}):t.archive_count>0?o.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.archive_count," print",t.archive_count!==1?"s":""]}):null,a&&o.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),s&&o.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&o.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const f=[...new Set(t.archives.map(p=>p.filament_type).filter(Boolean))],g=[...new Set(t.archives.map(p=>p.filament_color).filter(Boolean))];return f.length===0&&g.length===0?null:o.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[f.slice(0,3).map(p=>o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:p},p)),g.length>0&&o.jsxs("div",{className:"flex items-center gap-0.5",children:[g.slice(0,5).map(p=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:p.startsWith("#")?p:`#${p}`},title:p},p)),g.length>5&&o.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",g.length-5]})]})]})})()]})]}),o.jsxs("div",{className:"relative",onClick:f=>f.stopPropagation(),children:[o.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>c(!l),children:o.jsx(cR,{className:"w-4 h-4"})}),l&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>c(!1)}),o.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[o.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),c(!1)},children:[o.jsx(Qh,{className:"w-4 h-4"}),"Edit"]}),o.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),c(!1)},children:[o.jsx(En,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),o.jsx("div",{className:"mb-4",children:t.target_count?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[o.jsx("span",{className:"text-bambu-gray",children:"Progress"}),o.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),o.jsx("div",{className:"h-2.5 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:o.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=100?"#22c55e":t.color||"#6b7280"}60`}})}),o.jsxs("div",{className:"text-right text-xs text-bambu-gray/60 mt-1",children:[i.toFixed(0),"% complete"]})]}):t.archive_count>0?o.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[o.jsx(oo,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[t.archive_count," print",t.archive_count!==1?"s":""," completed"]})]}),t.queue_count>0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[o.jsx(rr,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):o.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&o.jsxs("div",{className:"mb-4",children:[o.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(f=>o.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:f.print_name||"Unknown",children:[f.thumbnail_path?o.jsx("img",{src:Se.getArchiveThumbnail(f.id),alt:f.print_name||"",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:o.jsx(Fc,{className:"w-6 h-6"})}),f.status==="failed"&&o.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:o.jsx(Gn,{className:"w-4 h-4 text-white"})})]},f.id))}),t.archive_count>4&&o.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[o.jsxs("div",{className:"flex items-center gap-1.5",title:"Completed prints",children:[o.jsx(oo,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:t.archive_count})]}),t.queue_count>0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",title:"In queue",children:[o.jsx(Zk,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:t.queue_count})]})]}),o.jsx(Xc,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function gWe(){const t=wb(),e=mn(),{showToast:n}=Sr(),[r,i]=M.useState(!1),[a,s]=M.useState(),[l,c]=M.useState("active"),[u,d]=M.useState(null),{data:f,isLoading:g}=gt({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>Se.getProjects(l==="all"?void 0:l)}),p=vt({mutationFn:C=>Se.createProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:C=>{n(C.message,"error")}}),x=vt({mutationFn:({id:C,data:N})=>Se.updateProject(C,N),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),s(void 0),n("Project updated","success")},onError:C=>{n(C.message,"error")}}),v=vt({mutationFn:C=>Se.deleteProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),d(null),n("Project deleted","success")},onError:C=>{n(C.message,"error")}}),y=C=>{a?x.mutate({id:a.id,data:C}):p.mutate(C)},b=C=>{s(C),i(!0)},E=C=>{t(`/projects/${C.id}`)},w=C=>{d(C)},T=()=>{u!==null&&v.mutate(u)},A=f?.reduce((C,N)=>(C[N.status]=(C[N.status]||0)+1,C.all=(C.all||0)+1,C),{})||{};return o.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[o.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:o.jsx(Uo,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),o.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),o.jsxs(ke,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[o.jsx(sr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),o.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:rr},{key:"completed",label:"Completed",icon:sR},{key:"archived",label:"Archived",icon:oo},{key:"all",label:"All",icon:Uo}].map(({key:C,label:N,icon:F})=>o.jsxs("button",{onClick:()=>c(C),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===C?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[o.jsx(F,{className:"w-4 h-4"}),o.jsx("span",{children:N}),A[C]>0&&o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===C?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:A[C]})]},C))}),g?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsxs("div",{className:"flex flex-col items-center gap-3",children:[o.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[o.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:o.jsx(Uo,{className:"w-12 h-12 text-bambu-gray/50"})}),o.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),o.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&o.jsxs(ke,{onClick:()=>i(!0),children:[o.jsx(sr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(C=>o.jsx(pWe,{project:C,onClick:()=>E(C),onEdit:()=>b(C),onDelete:()=>w(C.id)},C.id))}),u!==null&&o.jsx(kr,{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:T,onCancel:()=>d(null)}),r&&o.jsx(Wte,{project:a,onClose:()=>{i(!1),s(void 0)},onSave:y,isLoading:p.isPending||x.isPending})]})}function xWe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function bWe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function yWe({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return o.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function o1({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-gray"}){return o.jsx(wt,{children:o.jsx(Et,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${i}`,children:o.jsx(t,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:e}),o.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&o.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function vWe({archives:t}){return t.length===0?o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(Fc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),o.jsx("p",{children:"No prints in this project yet"})]}):o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>o.jsxs(_c,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?o.jsx("img",{src:Se.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:o.jsx(Fc,{className:"w-8 h-8"})}),e.status==="failed"&&o.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:o.jsx(Pa,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&o.jsx("div",{className:"absolute top-1 right-1",children:o.jsx(Cr,{className:"w-4 h-4 text-bambu-green"})}),o.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function _We({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return o.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&o.jsx(Gn,{className:"w-3 h-3"}),r]})}function wWe(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}function jk(t){if(!t)return null;const e=new Date(t),n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function SWe(){const{id:t}=Zj(),e=wb(),n=mn(),{showToast:r}=Sr(),[i,a]=M.useState(!1),[s,l]=M.useState(!1),[c,u]=M.useState(""),[d,f]=M.useState(!1),g=M.useRef(null),p=parseInt(t||"0",10),{data:x,isLoading:v,error:y}=gt({queryKey:["project",p],queryFn:()=>Se.getProject(p),enabled:p>0}),{data:b,isLoading:E}=gt({queryKey:["project-archives",p],queryFn:()=>Se.getProjectArchives(p),enabled:p>0}),{data:w,isLoading:T}=gt({queryKey:["project-bom",p],queryFn:()=>Se.getProjectBOM(p),enabled:p>0}),{data:A,isLoading:C}=gt({queryKey:["project-timeline",p],queryFn:()=>Se.getProjectTimeline(p,20),enabled:p>0}),{data:N}=gt({queryKey:["settings"],queryFn:Se.getSettings}),F=N?.currency||"$",k=vt({mutationFn:U=>Se.updateProject(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project",p]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:U=>{r(U.message,"error")}}),R=()=>{u(x?.notes||""),l(!0)},I=()=>{k.mutate({notes:c})},L=()=>{l(!1),u("")},q=async U=>{const O=U.target.files?.[0];if(O){f(!0);try{const ne=await Se.uploadProjectAttachment(p,O);n.invalidateQueries({queryKey:["project",p]}),r(`Uploaded: ${ne.original_name}`,"success")}catch(ne){r(ne.message,"error")}finally{f(!1),g.current&&(g.current.value="")}}},j=(U,O)=>{Ce({isOpen:!0,title:"Delete Attachment",message:`Are you sure you want to delete "${O}"?`,onConfirm:async()=>{Ce(ne=>({...ne,isOpen:!1}));try{await Se.deleteProjectAttachment(p,U),n.invalidateQueries({queryKey:["project",p]}),r("Attachment deleted","success")}catch(ne){r(ne.message,"error")}}})},V=U=>U<1024?`${U} B`:U<1024*1024?`${(U/1024).toFixed(1)} KB`:`${(U/(1024*1024)).toFixed(1)} MB`,[K,W]=M.useState(""),[J,ee]=M.useState(1),[Z,B]=M.useState(""),[G,Q]=M.useState(""),[te,he]=M.useState(""),[oe,xe]=M.useState(!1),[Te,me]=M.useState(!1),[ce,Ce]=M.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),fe=vt({mutationFn:U=>Se.createBOMItem(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),W(""),ee(1),B(""),Q(""),he(""),xe(!1),r("Part added","success")},onError:U=>r(U.message,"error")}),Ie=vt({mutationFn:({itemId:U,data:O})=>Se.updateBOMItem(p,U,O),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]})},onError:U=>r(U.message,"error")}),z=vt({mutationFn:U=>Se.deleteBOMItem(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),r("Part removed","success")},onError:U=>r(U.message,"error")}),H=U=>{U.preventDefault(),K.trim()&&fe.mutate({name:K.trim(),quantity_needed:J,unit_price:Z?parseFloat(Z):void 0,sourcing_url:G.trim()||void 0,remarks:te.trim()||void 0})},re=U=>{const O=U.is_complete?0:U.quantity_needed;Ie.mutate({itemId:U.id,data:{quantity_acquired:O}})},$=(U,O)=>{Ce({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${O}"?`,onConfirm:()=>{Ce(ne=>({...ne,isOpen:!1})),z.mutate(U)}})},Y=vt({mutationFn:()=>Se.createTemplateFromProject(p),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:U=>r(U.message,"error")}),se=U=>new Date(U).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(v)return o.jsx("div",{className:"flex items-center justify-center py-24",children:o.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!x)return o.jsxs("div",{className:"text-center py-24",children:[o.jsx("p",{className:"text-bambu-gray",children:y?`Error: ${y.message}`:"Project not found"}),o.jsx(ke,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const ue=x.stats,Ee=ue?.progress_percent??0,Me=ue&&ue.total_archives>0?(ue.completed_prints/ue.total_archives*100).toFixed(0):null;return o.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(_c,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),o.jsx(Xc,{className:"w-4 h-4"}),o.jsx("span",{className:"text-white",children:x.name})]}),o.jsxs("div",{className:"flex items-start justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:o.jsx(Eoe,{className:"w-5 h-5 text-bambu-gray"})}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#6b7280"}}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:x.name}),x.description&&o.jsx("p",{className:"text-bambu-gray mt-1",children:x.description})]})]}),o.jsx(yWe,{status:x.status})]}),o.jsxs(ke,{onClick:()=>a(!0),children:[o.jsx(Qh,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),x.target_count&&o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Progress"}),o.jsxs("span",{className:"text-sm font-medium text-white",children:[ue?.completed_prints||0," / ",x.target_count," prints"]})]}),o.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ee,100)}%`,backgroundColor:Ee>=100?"#22c55e":x.color||"#6b7280"}})}),o.jsxs("div",{className:"flex justify-between mt-1",children:[o.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ee.toFixed(0),"% complete"]}),x.target_count-(ue?.completed_prints||0)>0&&o.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[x.target_count-(ue?.completed_prints||0)," remaining"]})]})]})}),ue&&o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(o1,{icon:Fc,label:"Total Prints",value:ue.total_archives,subValue:Me?`${Me}% success rate`:void 0,color:"text-bambu-green"}),o.jsx(o1,{icon:Cr,label:"Completed",value:ue.completed_prints,subValue:ue.failed_prints>0?`${ue.failed_prints} failed`:void 0,color:"text-blue-400"}),o.jsx(o1,{icon:rr,label:"Print Time",value:xWe(ue.total_print_time_hours),color:"text-yellow-400"}),o.jsx(o1,{icon:Vi,label:"Filament Used",value:bWe(ue.total_filament_grams),color:"text-purple-400"})]}),ue&&(ue.estimated_cost>0||x.budget)&&o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),o.jsxs("p",{className:"text-lg font-semibold text-white",children:[F,ue.estimated_cost.toFixed(2)]})]}),ue.total_energy_kwh>0&&o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),o.jsxs("p",{className:"text-lg font-semibold text-white",children:[ue.total_energy_kwh.toFixed(2)," kWh",ue.total_energy_cost>0&&o.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",F,ue.total_energy_cost.toFixed(2),")"]})]})]}),x.budget&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),o.jsxs("p",{className:"text-lg font-semibold text-white",children:[F,x.budget.toFixed(2)]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),o.jsxs("p",{className:`text-lg font-semibold ${x.budget-ue.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[F,(x.budget-ue.estimated_cost).toFixed(2)]})]})]})]})]})}),x.children&&x.children.length>0&&o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[o.jsx(Wle,{className:"w-5 h-5"}),"Sub-projects (",x.children.length,")"]}),o.jsx("div",{className:"space-y-2",children:x.children.map(U=>o.jsxs(_c,{to:`/projects/${U.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:U.color||"#6b7280"}}),o.jsx("span",{className:"text-white",children:U.name}),o.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${U.status==="completed"?"bg-bambu-green/20 text-bambu-green":U.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:U.status})]}),U.progress_percent!==null&&o.jsxs("span",{className:"text-sm text-bambu-gray",children:[U.progress_percent.toFixed(0),"%"]})]},U.id))})]})}),x.parent_id&&x.parent_name&&o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx(pd,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),o.jsx(_c,{to:`/projects/${x.parent_id}`,className:"text-bambu-green hover:underline",children:x.parent_name})]}),(x.tags||x.due_date||x.priority!=="normal")&&o.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[x.priority&&x.priority!=="normal"&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),o.jsx(_We,{priority:x.priority})]}),x.due_date&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Qr,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:"text-sm text-white",children:wWe(x.due_date)}),jk(x.due_date)&&o.jsxs("span",{className:`text-xs ${jk(x.due_date).color}`,children:["(",jk(x.due_date).label,")"]})]}),x.tags&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ap,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("div",{className:"flex flex-wrap gap-1",children:x.tags.split(",").map((U,O)=>o.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:U.trim()},O))})]})]}),o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Es,{className:"w-5 h-5"}),"Notes"]}),s?o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:L,disabled:k.isPending,children:[o.jsx(Gt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),o.jsxs(ke,{size:"sm",onClick:I,disabled:k.isPending,children:[k.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-1"}):o.jsx(Ts,{className:"w-4 h-4 mr-1"}),"Save"]})]}):o.jsxs(ke,{variant:"secondary",size:"sm",onClick:R,children:[o.jsx(Qh,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),s?o.jsx(zj,{content:c,onChange:u,placeholder:"Add notes about this project..."}):x.notes?o.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:x.notes}}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Zce,{className:"w-5 h-5"}),"Attachments (",x.attachments?.length||0,")"]}),o.jsxs("div",{children:[o.jsx("input",{ref:g,type:"file",onChange:q,className:"hidden"}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>g.current?.click(),disabled:d,children:[d?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-1"}):o.jsx(oa,{className:"w-4 h-4 mr-1"}),"Upload"]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Upload any file: images (PNG, JPG), PDFs, STL files, or documents."}),x.attachments&&x.attachments.length>0?o.jsx("div",{className:"space-y-2",children:x.attachments.map(U=>o.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx(uR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm text-white truncate",children:U.original_name}),o.jsx("p",{className:"text-xs text-bambu-gray",children:V(U.size)})]})]}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o.jsx("a",{href:Se.getProjectAttachmentUrl(p,U.filename),download:U.original_name,className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Download",children:o.jsx(is,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>j(U.filename,U.original_name),className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-red-400",title:"Delete",children:o.jsx(En,{className:"w-4 h-4"})})]})]},U.filename))}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No attachments yet. Click Upload to add files."})]})}),o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(UG,{className:"w-5 h-5"}),"Bill of Materials",ue&&ue.bom_total_items>0&&o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ue.bom_completed_items,"/",ue.bom_total_items," acquired)"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[w&&w.some(U=>U.is_complete)&&o.jsx("button",{onClick:()=>me(!Te),className:`text-xs px-2 py-1 rounded transition-colors ${Te?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:Te?"Show all":"Hide done"}),!oe&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>xe(!0),children:[o.jsx(sr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),oe&&o.jsxs("form",{onSubmit:H,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o.jsx("input",{type:"text",value:K,onChange:U=>W(U.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name (e.g., M3x8 screws)",autoFocus:!0}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"number",value:J,onChange:U=>ee(parseInt(U.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),o.jsx("input",{type:"number",step:"0.01",value:Z,onChange:U=>B(U.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${F})`})]})]}),o.jsx("input",{type:"url",value:G,onChange:U=>Q(U.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),o.jsx("input",{type:"text",value:te,onChange:U=>he(U.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ke,{type:"button",variant:"secondary",size:"sm",onClick:()=>xe(!1),children:"Cancel"}),o.jsx(ke,{type:"submit",size:"sm",disabled:!K.trim()||fe.isPending,children:fe.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),T?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):w&&w.length>0?o.jsxs("div",{className:"space-y-2",children:[w.filter(U=>!Te||!U.is_complete).map(U=>o.jsx("div",{className:`p-3 rounded-lg transition-colors ${U.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("button",{onClick:()=>re(U),disabled:Ie.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${U.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:U.is_complete&&o.jsx(Cr,{className:"w-3 h-3"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsxs("p",{className:`text-sm font-medium ${U.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[U.name,o.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",U.quantity_needed]})]}),U.unit_price!==null&&o.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[F,(U.unit_price*U.quantity_needed).toFixed(2)]})]}),o.jsx("button",{onClick:()=>$(U.id,U.name),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0",title:"Delete",children:o.jsx(En,{className:"w-4 h-4"})})]}),U.sourcing_url&&o.jsxs("a",{href:U.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:O=>O.stopPropagation(),children:[o.jsx(ba,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:(()=>{try{return new URL(U.sourcing_url).hostname.replace("www.","")}catch{return U.sourcing_url}})()})]}),U.remarks&&o.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:U.remarks})]})]})},U.id)),w.some(U=>U.unit_price!==null)&&o.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[o.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),o.jsxs("span",{className:"text-white font-medium",children:[F,w.reduce((U,O)=>U+(O.unit_price||0)*O.quantity_needed,0).toFixed(2)]})]})]}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."})]})}),o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsx("div",{className:"flex items-center justify-between mb-3",children:o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(U1,{className:"w-5 h-5"}),"Activity Timeline"]})}),C?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):A&&A.length>0?o.jsx("div",{className:"space-y-3",children:A.slice(0,10).map((U,O)=>o.jsxs("div",{className:"flex gap-3",children:[o.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${U.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":U.event_type==="print_failed"?"bg-red-500/20 text-red-400":U.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[U.event_type==="print_completed"&&o.jsx(Cr,{className:"w-4 h-4"}),U.event_type==="print_failed"&&o.jsx(Pa,{className:"w-4 h-4"}),U.event_type==="print_started"&&o.jsx(Vi,{className:"w-4 h-4"}),U.event_type==="queued"&&o.jsx(Zk,{className:"w-4 h-4"}),U.event_type==="project_created"&&o.jsx(sr,{className:"w-4 h-4"})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-white",children:U.title}),U.description&&o.jsx("p",{className:"text-xs text-bambu-gray truncate",children:U.description}),o.jsx("p",{className:"text-xs text-bambu-gray/70",children:se(U.timestamp)})]})]},O))}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!x.is_template&&o.jsx("div",{className:"flex justify-end",children:o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>Y.mutate(),disabled:Y.isPending,children:[Y.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(md,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),ue&&(ue.queued_prints>0||ue.in_progress_prints>0)&&o.jsx(wt,{children:o.jsxs(Et,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Zk,{className:"w-5 h-5"}),"Queue"]}),o.jsx(_c,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[ue.in_progress_prints>0&&o.jsxs("span",{className:"text-yellow-400",children:[ue.in_progress_prints," printing"]}),ue.queued_prints>0&&o.jsxs("span",{className:"text-bambu-gray",children:[ue.queued_prints," queued"]})]})]})}),o.jsxs("div",{children:[o.jsx("div",{className:"flex items-center justify-between mb-4",children:o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Fc,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),E?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):o.jsx(vWe,{archives:b||[]})]}),i&&o.jsx(Wte,{project:{...x,archive_count:ue?.total_archives||0,queue_count:ue?.queued_prints||0,progress_percent:ue?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:U=>k.mutate(U),isLoading:k.isPending}),ce.isOpen&&o.jsx(kr,{title:ce.title,message:ce.message,confirmText:"Delete",variant:"danger",onConfirm:ce.onConfirm,onCancel:()=>Ce(U=>({...U,isOpen:!1}))})]})}const Rk=5,MWe=2e3,EWe=3e4;function TWe(){const{printerId:t}=Zj(),e=parseInt(t||"0",10),[n,r]=M.useState("stream"),[i,a]=M.useState(!1),[s,l]=M.useState(!0),[c,u]=M.useState(Date.now()),[d,f]=M.useState(!1),[g,p]=M.useState(!1),[x,v]=M.useState(0),[y,b]=M.useState(!1),[E,w]=M.useState(0),T=M.useRef(null),A=M.useRef(null),C=M.useRef(null),N=M.useRef(null),{data:F}=gt({queryKey:["printer",e],queryFn:()=>Se.getPrinter(e),enabled:e>0});M.useEffect(()=>(F&&(document.title=`${F.name} - Camera`),()=>{document.title="Bambuddy"}),[F]),M.useEffect(()=>{const J=`/api/v1/printers/${e}/camera/stop`,ee=()=>{e>0&&navigator.sendBeacon(J)},Z=()=>{document.visibilityState==="hidden"&&e>0&&navigator.sendBeacon(J)};return window.addEventListener("beforeunload",ee),document.addEventListener("visibilitychange",Z),()=>{window.removeEventListener("beforeunload",ee),document.removeEventListener("visibilitychange",Z),T.current&&(T.current.src=""),e>0&&navigator.sendBeacon(J)}},[e]),M.useEffect(()=>{if(s&&!d){const ee=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(ee)}},[n,s,c,d]),M.useEffect(()=>{const J=()=>{p(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",J),()=>document.removeEventListener("fullscreenchange",J)},[]),M.useEffect(()=>{if(!window.opener)return;let J;const ee=()=>{clearTimeout(J),J=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};window.addEventListener("resize",ee);const Z=setInterval(()=>{const B=localStorage.getItem("cameraWindowState");if(B){const G=JSON.parse(B);(G.left!==window.screenX||G.top!==window.screenY)&&ee()}},1e3);return()=>{clearTimeout(J),clearInterval(Z),window.removeEventListener("resize",ee)}},[]),M.useEffect(()=>()=>{C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current)},[]);const k=M.useCallback(()=>{if(x>=Rk){b(!1),a(!0);return}const J=Math.min(MWe*Math.pow(2,x),EWe);b(!0),w(Math.ceil(J/1e3)),N.current=setInterval(()=>{w(ee=>ee<=1?(N.current&&clearInterval(N.current),0):ee-1)},1e3),C.current=setTimeout(()=>{v(ee=>ee+1),b(!1),l(!0),a(!1),T.current&&(T.current.src=""),u(Date.now())},J)},[x]),R=()=>{l(!1),n==="stream"&&x<Rk?k():a(!0)},I=()=>{if(l(!1),a(!1),v(0),b(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),window.opener&&T.current&&!localStorage.getItem("cameraWindowState")){const J=T.current,ee=J.naturalWidth,Z=J.naturalHeight;if(ee>0&&Z>0){const Q=window.outerWidth-window.innerWidth,te=window.outerHeight-window.innerHeight,he=ee+16+Q,oe=Z+45+16+te;window.resizeTo(he,oe)}}},L=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},q=J=>{n===J||d||(f(!0),l(!0),a(!1),v(0),b(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),T.current&&(T.current.src=""),n==="stream"&&L(),setTimeout(()=>{r(J),u(Date.now()),f(!1)},100))},j=()=>{d||(f(!0),l(!0),a(!1),v(0),b(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),T.current&&(T.current.src=""),n==="stream"&&L(),setTimeout(()=>{u(Date.now()),f(!1)},100))},V=()=>{A.current&&(document.fullscreenElement?document.exitFullscreen():A.current.requestFullscreen())},K=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,W=s||d||y;return e?o.jsxs("div",{ref:A,className:"min-h-screen bg-black flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[o.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[o.jsx(C0,{className:"w-4 h-4"}),F?.name||`Printer ${e}`]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[o.jsx("button",{onClick:()=>q("stream"),disabled:W,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"}),o.jsx("button",{onClick:()=>q("snapshot"),disabled:W,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"})]}),o.jsx("button",{onClick:j,disabled:W,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:o.jsx(_a,{className:`w-4 h-4 text-bambu-gray ${W?"animate-spin":""}`})}),o.jsx("button",{onClick:V,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?o.jsx(Vce,{className:"w-4 h-4 text-bambu-gray"}):o.jsx(Lce,{className:"w-4 h-4 text-bambu-gray"})})]})]}),o.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:o.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(s||d)&&!y&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:o.jsxs("div",{className:"text-center",children:[o.jsx(_a,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),y&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:o.jsxs("div",{className:"text-center p-4",children:[o.jsx(Ab,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),o.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),o.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",E,"s... (attempt ",x+1,"/",Rk,")"]}),o.jsx("button",{onClick:j,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!y&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:o.jsxs("div",{className:"text-center p-4",children:[o.jsx(Gn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),o.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),o.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),o.jsx("button",{onClick:j,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),o.jsx("img",{ref:T,src:K,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:K?R:void 0,onLoad:K?I:void 0},c)]})})]}):o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function AWe(){const{id:t}=Zj(),{mode:e}=ag(),{data:n,isLoading:r,error:i}=gt({queryKey:["external-link",t],queryFn:()=>Se.getExternalLink(Number(t)),enabled:!!t});return r?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[o.jsx(Gn,{className:"w-12 h-12"}),o.jsx("p",{children:"Link not found"})]}):o.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 Xr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return o.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[o.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:o.jsx(t,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:e}),o.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&o.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function K9({percent:t,color:e="bg-bambu-green"}){return o.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function uh({title:t,icon:e,children:n}){return o.jsxs(wt,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx(e,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function NWe(){const{t}=eg(),{data:e,isLoading:n,refetch:r,isFetching:i}=gt({queryKey:["systemInfo"],queryFn:Se.getSystemInfo,refetchInterval:3e4});if(n)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!e)return o.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 o.jsxs("div",{className:"p-6 space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),o.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),o.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:[o.jsx(_a,{className:`w-4 h-4 ${i?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),o.jsx(uh,{title:t("system.application","Application"),icon:dh,children:o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsx(Xr,{icon:dh,label:t("system.version","Version"),value:`v${e.app.version}`}),o.jsx(Xr,{icon:rr,label:t("system.uptime","System Uptime"),value:e.system.uptime_formatted}),o.jsx(Xr,{icon:dh,label:t("system.hostname","Hostname"),value:e.system.hostname})]})}),o.jsxs(uh,{title:t("system.database","Database"),icon:wp,children:[o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[o.jsx(Xr,{icon:oo,label:t("system.totalArchives","Total Archives"),value:e.database.archives}),o.jsx(Xr,{icon:sR,label:t("system.completed","Completed"),value:e.database.archives_completed,color:"text-green-500"}),o.jsx(Xr,{icon:Pa,label:t("system.failed","Failed"),value:e.database.archives_failed,color:"text-red-500"}),o.jsx(Xr,{icon:xt,label:t("system.printing","Printing"),value:e.database.archives_printing,color:"text-yellow-500"})]}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Xr,{icon:Vi,label:t("system.printers","Printers"),value:e.database.printers}),o.jsx(Xr,{icon:mR,label:t("system.filaments","Filaments"),value:e.database.filaments}),o.jsx(Xr,{icon:Uo,label:t("system.projects","Projects"),value:e.database.projects}),o.jsx(Xr,{icon:lo,label:t("system.smartPlugs","Smart Plugs"),value:e.database.smart_plugs})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[o.jsx(Xr,{icon:rr,label:t("system.totalPrintTime","Total Print Time"),value:e.database.total_print_time_formatted}),o.jsx(Xr,{icon:oo,label:t("system.totalFilament","Total Filament Used"),value:`${e.database.total_filament_kg} kg`,subValue:`${e.database.total_filament_grams.toLocaleString()} g`})]})]}),o.jsxs(uh,{title:t("system.connectedPrinters","Connected Printers"),icon:Vi,children:[o.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[o.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:e.printers.connected}),o.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:e.printers.total})})]}),e.printers.connected_list.length>0?o.jsx("div",{className:"space-y-2",children:e.printers.connected_list.map(l=>o.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),o.jsx("span",{className:"font-medium text-white",children:l.name})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[o.jsx("span",{children:l.model}),o.jsx("span",{className:`px-2 py-0.5 rounded ${l.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":l.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:l.state})]})]},l.id))}):o.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),o.jsx(uh,{title:t("system.storage","Storage"),icon:hR,children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[o.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),o.jsxs("span",{className:"text-white",children:[e.storage.disk_used_formatted," / ",e.storage.disk_total_formatted]})]}),o.jsx(K9,{percent:e.storage.disk_percent_used,color:a}),o.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),"%)"]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(Xr,{icon:oo,label:t("system.archiveStorage","Archive Storage"),value:e.storage.archive_size_formatted}),o.jsx(Xr,{icon:wp,label:t("system.databaseSize","Database Size"),value:e.storage.database_size_formatted})]})]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsx(uh,{title:t("system.memory","Memory"),icon:Fce,children:o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[o.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),o.jsxs("span",{className:"text-white",children:[e.memory.used_formatted," / ",e.memory.total_formatted]})]}),o.jsx(K9,{percent:e.memory.percent_used,color:s}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.memory.available_formatted," ",t("system.available","available")]})]})})}),o.jsx(uh,{title:t("system.cpu","CPU"),icon:Tv,children:o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(Xr,{icon:Tv,label:t("system.cores","Cores"),value:e.cpu.count,subValue:`${e.cpu.count_logical} logical`}),o.jsx(Xr,{icon:Tv,label:t("system.usage","Usage"),value:`${e.cpu.percent}%`})]})})})]}),o.jsx(uh,{title:t("system.systemDetails","System Details"),icon:dh,children:o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Xr,{icon:dh,label:t("system.os","Operating System"),value:e.system.platform,subValue:e.system.platform_release}),o.jsx(Xr,{icon:Tv,label:t("system.architecture","Architecture"),value:e.system.architecture}),o.jsx(Xr,{icon:dh,label:t("system.python","Python"),value:e.system.python_version}),o.jsx(Xr,{icon:rr,label:t("system.bootTime","Boot Time"),value:new Date(e.system.boot_time).toLocaleString()})]})})]})}function CWe(){const t=M.useRef(null),e=M.useRef(null),n=mn(),[r,i]=M.useState(!1),a=M.useRef(new Set),s=M.useRef(null),l=M.useRef(new Map),c=M.useRef(null),u=M.useRef([]),d=M.useRef(!1),f=M.useRef(()=>{}),g=M.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const E=()=>{const w=u.current.shift();w?requestAnimationFrame(()=>{f.current(w),u.current.length>0?setTimeout(E,16):d.current=!1}):d.current=!1};E()},[]),p=M.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(w);let A=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),A=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=C=>{try{const N=JSON.parse(C.data);N.type==="printer_status"&&N.printer_id!==void 0&&N.data?f.current(N):(u.current.push(N),g())}catch{}},T.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),A&&(clearInterval(A),A=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},T.onerror=C=>{console.error("[WebSocket] Error",C),T.close()},t.current=T},[]),x=M.useCallback((E,w)=>{const T=l.current.get(E)||{};l.current.set(E,{...T,...w}),c.current||(c.current=window.setTimeout(()=>{const A=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{A.forEach((C,N)=>{n.setQueryData(["printerStatus",N],F=>{const k={...F,...C};return k.wifi_signal==null&&F?.wifi_signal!=null&&(k.wifi_signal=F.wifi_signal),k})})})},100))},[n]),v=M.useCallback(E=>{a.current.add(E),s.current&&clearTimeout(s.current),s.current=window.setTimeout(()=>{const w=Array.from(a.current);a.current.clear(),s.current=null;let T=0;w.forEach(A=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[A]})})},T),T+=500})},3e3)},[n]),y=M.useCallback(E=>{switch(E.type){case"printer_status":E.printer_id!==void 0&&E.data&&x(E.printer_id,E.data);break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break}},[n,v,x]);M.useEffect(()=>{f.current=y},[y]),M.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),s.current&&clearTimeout(s.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const b=M.useCallback(E=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(E))},[]);return{isConnected:r,sendMessage:b}}const kWe=new ioe({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function PWe({children:t}){return CWe(),o.jsx(o.Fragment,{children:t})}function jWe(){return o.jsx(Ede,{children:o.jsx(Lde,{children:o.jsx(aoe,{client:kWe,children:o.jsx(PWe,{children:o.jsx(Tse,{children:o.jsxs(rse,{children:[o.jsx(Xa,{path:"/camera/:printerId",element:o.jsx(TWe,{})}),o.jsxs(Xa,{path:"/",element:o.jsx(Rde,{}),children:[o.jsx(Xa,{index:!0,element:o.jsx(tCe,{})}),o.jsx(Xa,{path:"archives",element:o.jsx(O7e,{})}),o.jsx(Xa,{path:"queue",element:o.jsx(vGe,{})}),o.jsx(Xa,{path:"stats",element:o.jsx(DGe,{})}),o.jsx(Xa,{path:"profiles",element:o.jsx(uWe,{})}),o.jsx(Xa,{path:"maintenance",element:o.jsx(mWe,{})}),o.jsx(Xa,{path:"projects",element:o.jsx(gWe,{})}),o.jsx(Xa,{path:"projects/:id",element:o.jsx(SWe,{})}),o.jsx(Xa,{path:"settings",element:o.jsx(JGe,{})}),o.jsx(Xa,{path:"system",element:o.jsx(NWe,{})}),o.jsx(Xa,{path:"external/:id",element:o.jsx(AWe,{})})]})]})})})})})})}oie.createRoot(document.getElementById("root")).render(o.jsx(M.StrictMode,{children:o.jsx(jWe,{})}));
|